[jboss-cvs] JBossAS SVN: r87162 - in projects/webbeans-ri-int/trunk: deployer and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Apr 11 10:30:17 EDT 2009
Author: alesj
Date: 2009-04-11 10:30:17 -0400 (Sat, 11 Apr 2009)
New Revision: 87162
Added:
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DynamicDependencyCreator.java
Removed:
projects/webbeans-ri-int/trunk/deployer/resources/
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/microcontainer/
Modified:
projects/webbeans-ri-int/trunk/deployer/pom.xml
projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockBootDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockEjbServices.java
projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/test/BootDeployerTestCase.java
projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/webbeans/deployers/test/BootDeployerTestCase.xml
projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossEjbServices.java
projects/webbeans-ri-int/trunk/pom.xml
Log:
[WBINT-3]; make bootstrap depend on ejbs.
Fix poms, remove duplicated resources.
Modified: projects/webbeans-ri-int/trunk/deployer/pom.xml
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/pom.xml 2009-04-11 11:03:55 UTC (rev 87161)
+++ projects/webbeans-ri-int/trunk/deployer/pom.xml 2009-04-11 14:30:17 UTC (rev 87162)
@@ -48,11 +48,6 @@
<artifactId>webbeans-core</artifactId>
</dependency>
- <dependency>
- <groupId>org.jboss.webbeans.integration</groupId>
- <artifactId>webbeans-jboss-int-jboss-ejb</artifactId>
- </dependency>
-
<dependency>
<groupId>org.jboss.webbeans</groupId>
<artifactId>jsr299-api</artifactId>
@@ -185,6 +180,7 @@
<artifactId>jboss-deployers-vfs</artifactId>
<type>test-jar</type>
<scope>test</scope>
+ <!--
<exclusions>
<exclusion>
<groupId>org.jboss.deployers</groupId>
@@ -203,6 +199,7 @@
<artifactId>jboss-classloading</artifactId>
</exclusion>
</exclusions>
+ -->
</dependency>
<dependency>
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml 2009-04-11 11:03:55 UTC (rev 87161)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml 2009-04-11 14:30:17 UTC (rev 87162)
@@ -12,7 +12,10 @@
<!-- Responsible for discovering Web Bean classes -->
<bean name="WebBeansDiscoveryDeployer" class="org.jboss.webbeans.integration.deployer.env.WebBeanDiscoveryDeployer"/>
-
+
+ <!-- Responsible for dynamic ejb dependency creation -->
+ <bean name="DynamicDependencyCreator" class="org.jboss.webbeans.integration.deployer.env.DynamicDependencyCreator"/>
+
<!-- Responsible for booting Web Beans -->
<bean name="WebBeansBootstrapDeployer" class="org.jboss.webbeans.integration.deployer.env.WebBeansBootstrapDeployer"/>
Added: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DynamicDependencyCreator.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DynamicDependencyCreator.java (rev 0)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/DynamicDependencyCreator.java 2009-04-11 14:30:17 UTC (rev 87162)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.webbeans.integration.deployer.env;
+
+import org.jboss.beans.metadata.api.annotations.Constructor;
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
+
+/**
+ * Bean which knows how to create dynamic dependencies to bootstrap bean.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class DynamicDependencyCreator
+{
+ /** The controller */
+ private Controller controller;
+
+ @Constructor
+ public DynamicDependencyCreator(@Inject(bean = KernelConstants.KERNEL_CONTROLLER_NAME) Controller controller)
+ {
+ this.controller = controller;
+ }
+
+ /**
+ * Create dependencies to bootstrap bean.
+ *
+ * @param bootstrapName the bootstrap bean name
+ * @param dependencies dependencies names
+ * @param whenRequiredState when required state
+ * @param dependentState dependencies dependent state
+ */
+ public void createDepenencies(Object bootstrapName, Iterable<String> dependencies, String whenRequiredState, String dependentState)
+ {
+ if (bootstrapName == null)
+ throw new IllegalArgumentException("Null bootstrap name");
+ if (dependencies == null)
+ throw new IllegalArgumentException("Null dependecies");
+
+ ControllerContext bootstrapControllerContext = controller.getContext(bootstrapName, null);
+ if (bootstrapControllerContext == null)
+ throw new IllegalArgumentException("No such bootstrap bean installed: " + bootstrapName);
+
+ ControllerState whenRequired;
+ if (whenRequiredState == null)
+ whenRequired = ControllerState.INSTALLED;
+ else
+ whenRequired = new ControllerState(whenRequiredState);
+
+ ControllerState currentBootstrapState = bootstrapControllerContext.getState();
+ if (controller.getStates().isBeforeState(currentBootstrapState, whenRequired) == false)
+ throw new IllegalArgumentException("Bootstrap bean is already past " + whenRequiredState + " state");
+
+ ControllerState dependent = new ControllerState(dependentState);
+ DependencyInfo di = bootstrapControllerContext.getDependencyInfo();
+ for (Object dependency : dependencies)
+ {
+ DependencyItem item = new AbstractDependencyItem(bootstrapName, dependency, whenRequired, dependent);
+ di.addIDependOn(item);
+ }
+ }
+}
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java 2009-04-11 11:03:55 UTC (rev 87161)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java 2009-04-11 14:30:17 UTC (rev 87162)
@@ -24,6 +24,7 @@
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.beans.metadata.spi.builder.ParameterMetaDataBuilder;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
@@ -33,6 +34,7 @@
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
import org.jboss.webbeans.integration.deployer.DeployersUtils;
+import org.jboss.dependency.spi.ControllerState;
/**
* Deploy WebBeans boostrap service.
@@ -62,7 +64,8 @@
BeanMetaDataBuilder bootstrap = BeanMetaDataBuilder.createBuilder(bootstrapName, "org.jboss.webbeans.bootstrap.api.helpers.BootstrapBean");
bootstrap.addConstructorParameter(Bootstrap.class.getName(), createBootstrap(unit));
bootstrap.addPropertyMetaData("webBeanDiscovery", bootstrap.createInject(envName));
- bootstrap.addPropertyMetaData("ejbServices", createEjbConnector("JBossEjbServices", "org.jboss.webbeans.integration.ejb.JBossEjbServices", unit));
+ ValueMetaData ejbServicesValue = createEjbConnector("JBossEjbServices", "org.jboss.webbeans.integration.ejb.JBossEjbServices", unit);
+ bootstrap.addPropertyMetaData("ejbServices", ejbServicesValue);
bootstrap.addPropertyMetaData("jpaServices", createEjbConnector("JBossJpaServices", "org.jboss.webbeans.integration.persistence.JBossJpaServices", unit));
bootstrap.addPropertyMetaData("resourceServices", bootstrap.createInject("JBossResourceServices"));
bootstrap.addPropertyMetaData("webServices", bootstrap.createInject("JBossWebServices"));
@@ -73,7 +76,14 @@
bootstrap.setCreate("initialize");
bootstrap.setStart("boot");
bootstrap.setDestroy("shutdown");
- bootstrap.addDependency("RealTransactionManager"); // so we know TM is present in JBossTransactionServices
+ bootstrap.addDependency("RealTransactionManager"); // so we know TM is present in JBossTransactionServices
+ // call dynamic dependency creator for EJBs
+ ParameterMetaDataBuilder install = bootstrap.addInstallWithParameters("createDepenencies", "DynamicDependencyCreator", null, ControllerState.CONFIGURED);
+ install.addParameterMetaData(Object.class.getName(), bootstrapName);
+ install.addParameterMetaData(Iterable.class.getName(), bootstrap.createInject(ejbServicesValue.getUnderlyingValue(), "ejbContainerNames"));
+ install.addParameterMetaData(String.class.getName(), "Start");
+ install.addParameterMetaData(String.class.getName(), "Start");
+
unit.addAttachment(bootstrapName + "_" + BeanMetaData.class.getSimpleName(), bootstrap.getBeanMetaData());
}
Modified: projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockBootDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockBootDeployer.java 2009-04-11 11:03:55 UTC (rev 87161)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockBootDeployer.java 2009-04-11 14:30:17 UTC (rev 87162)
@@ -24,6 +24,7 @@
import org.jboss.beans.metadata.spi.BeanMetaData;
import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.beans.metadata.spi.builder.ParameterMetaDataBuilder;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
@@ -32,6 +33,7 @@
import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
import org.jboss.webbeans.integration.deployer.DeployersUtils;
import org.jboss.webbeans.integration.deployer.env.WebBeanDiscoveryEnvironment;
+import org.jboss.dependency.spi.ControllerState;
/**
* Mock wb boot deployer.
@@ -59,13 +61,21 @@
String bootstrapName = DeployersUtils.getBootstrapBeanName(unit);
BeanMetaDataBuilder bootstrap = BeanMetaDataBuilder.createBuilder(bootstrapName, "org.jboss.test.webbeans.deployers.support.MockWBBootstrap");
bootstrap.addPropertyMetaData("webBeanDiscovery", bootstrap.createInject(envName));
- bootstrap.addPropertyMetaData("ejbServices", createEjbConnector("JBossEjbServices", "org.jboss.test.webbeans.deployers.support.MockEjbServices", unit));
+ ValueMetaData ejbServicesValue = createEjbConnector("JBossEjbServices", "org.jboss.test.webbeans.deployers.support.MockEjbServices", unit);
+ bootstrap.addPropertyMetaData("ejbServices", ejbServicesValue);
bootstrap.addPropertyMetaData("transactionServices", bootstrap.createInject("JBossTransactionServices"));
bootstrap.addPropertyMetaData("applicationContext", createBeanStore());
bootstrap.setCreate("initialize");
bootstrap.setStart("boot");
bootstrap.setDestroy("shutdown");
bootstrap.addDependency("RealTransactionManager"); // so we know TM is present in JBossTransactionServices
+ // call dynamic dependency creator for EJBs
+ ParameterMetaDataBuilder install = bootstrap.addInstallWithParameters("createDepenencies", "DynamicDependencyCreator", null, ControllerState.CONFIGURED);
+ install.addParameterMetaData(Object.class.getName(), bootstrapName);
+ install.addParameterMetaData(Iterable.class.getName(), bootstrap.createInject(ejbServicesValue.getUnderlyingValue(), "ejbContainerNames"));
+ install.addParameterMetaData(String.class.getName(), "Start");
+ install.addParameterMetaData(String.class.getName(), "Start");
+
unit.addAttachment(bootstrapName + "_" + BeanMetaData.class.getSimpleName(), bootstrap.getBeanMetaData());
}
Modified: projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockEjbServices.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockEjbServices.java 2009-04-11 11:03:55 UTC (rev 87161)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/support/MockEjbServices.java 2009-04-11 14:30:17 UTC (rev 87162)
@@ -73,4 +73,8 @@
return null;
}
+ public Iterable<String> getEjbContainerNames()
+ {
+ return Collections.singleton("EjbContainer#1");
+ }
}
Modified: projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/test/BootDeployerTestCase.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/test/BootDeployerTestCase.java 2009-04-11 11:03:55 UTC (rev 87161)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/java/org/jboss/test/webbeans/deployers/test/BootDeployerTestCase.java 2009-04-11 14:30:17 UTC (rev 87162)
@@ -22,7 +22,12 @@
package org.jboss.test.webbeans.deployers.test;
import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.test.webbeans.deployers.support.CheckableBootstrap;
import org.jboss.virtual.VirtualFile;
import org.jboss.webbeans.integration.deployer.DeployersUtils;
@@ -48,19 +53,32 @@
{
CheckableBootstrap bootstrap;
VirtualFile ear = createBasicEar();
- DeploymentUnit earDU = assertDeploy(ear);
+ Deployment deployment = createVFSDeployment(ear);
+ DeployerClient mainDeployer = getDeployerClient();
+ mainDeployer.addDeployment(deployment);
+ mainDeployer.process();
try
{
+ DeploymentUnit earDU = getMainDeployerStructure().getDeploymentUnit(deployment.getName());
String bootName = DeployersUtils.getBootstrapBeanName(earDU);
- Object boot = getBean(bootName);
+ Object boot = getBean(bootName, null);
bootstrap = assertInstanceOf(boot, CheckableBootstrap.class, false);
+ // waiting on ejb
assertTrue(bootstrap.isInit());
+ assertFalse(bootstrap.isBoot()); // not yet booted
+ assertFalse(bootstrap.isShutdown());
+ // install ejb
+ KernelControllerContext ejb = deploy(new AbstractBeanMetaData("EjbContainer#1", Object.class.getName()));
+ assertTrue(ejb.getState().equals(ControllerState.INSTALLED));
+ /// check boot
+ assertTrue(bootstrap.isInit());
assertTrue(bootstrap.isBoot());
- assertFalse(bootstrap.isShutdown());
+ assertFalse(bootstrap.isShutdown());
}
finally
{
- undeploy(earDU);
+ mainDeployer.removeDeployment(deployment);
+ mainDeployer.process();
}
assertTrue(bootstrap.isShutdown());
}
Modified: projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/webbeans/deployers/test/BootDeployerTestCase.xml
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/webbeans/deployers/test/BootDeployerTestCase.xml 2009-04-11 11:03:55 UTC (rev 87161)
+++ projects/webbeans-ri-int/trunk/deployer/src/test/resources/org/jboss/test/webbeans/deployers/test/BootDeployerTestCase.xml 2009-04-11 14:30:17 UTC (rev 87162)
@@ -6,6 +6,7 @@
<bean name="JWBMDDeployer" class="org.jboss.webbeans.integration.deployer.ext.JBossWebBeansMetaDataDeployer"/>
<bean name="WBFilesDeployer" class="org.jboss.webbeans.integration.deployer.metadata.WebBeansFilesDeployer"/>
<bean name="WBDiscoveryDeployer" class="org.jboss.webbeans.integration.deployer.env.WebBeanDiscoveryDeployer"/>
+ <bean name="DynamicDependencyCreator" class="org.jboss.webbeans.integration.deployer.env.DynamicDependencyCreator"/>
<bean name="BootDeployer" class="org.jboss.test.webbeans.deployers.support.MockBootDeployer"/>
Modified: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossEjbServices.java
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossEjbServices.java 2009-04-11 11:03:55 UTC (rev 87161)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/ejb/JBossEjbServices.java 2009-04-11 14:30:17 UTC (rev 87162)
@@ -191,10 +191,14 @@
{
return ejbs;
}
-
+
+ /**
+ * Get the names of all ejb container.
+ *
+ * @return all ejb container names
+ */
public Iterable<String> getEjbContainerNames()
{
return Collections.unmodifiableCollection(ejbContainerNames);
}
-
}
Modified: projects/webbeans-ri-int/trunk/pom.xml
===================================================================
--- projects/webbeans-ri-int/trunk/pom.xml 2009-04-11 11:03:55 UTC (rev 87161)
+++ projects/webbeans-ri-int/trunk/pom.xml 2009-04-11 14:30:17 UTC (rev 87162)
@@ -189,12 +189,6 @@
<dependencies>
<dependency>
- <groupId>org.jboss.webbeans.integration</groupId>
- <artifactId>webbeans-jboss-int-jboss-ejb</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-client</artifactId>
<version>${version.jboss.deployers}</version>
More information about the jboss-cvs-commits
mailing list