[jboss-cvs] JBossAS SVN: r107524 - in branches/infinispan-int: component-matrix and 20 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 10 11:04:21 EDT 2010


Author: smarlow at redhat.com
Date: 2010-08-10 11:04:17 -0400 (Tue, 10 Aug 2010)
New Revision: 107524

Added:
   branches/infinispan-int/testsuite/imports/config/tests-secured.xml
   branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/
   branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestJmxAuthenticationUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestStatusServletAuthenticationUnitTestCase.java
   branches/infinispan-int/weld-int/.settings/
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/cl/WeldMcExtensionsIntegrationDeployer.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveDiscoveryDeployer.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveInfoDeployer.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossDeploymentDeployer.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveCollection.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveFactory.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveInfo.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveLifecycleListener.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveToClasspath.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Classpath.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathFactory.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathImpl.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/NoDuplicatesClasspath.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/MockArchiveManifest.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractSingleArchiveTest.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/DeploymentEnvironmentTestCase.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentSmokeTestCase.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/JBossDeploymentSmokeTestCase.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java
   branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.xml
   branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.xml
   branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.xml
   branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/DeploymentEnvironmentTestCase.xml
   branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/JBossDeploymentSmokeTestCase.xml
   branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.xml
Removed:
   branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestJmxAuthenticationUnitTestCase.java
   branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestStatusServletAuthenticationUnitTestCase.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveCollection.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveFactory.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveInfo.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveLifecycleListener.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveToClasspath.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Classpath.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathFactory.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathImpl.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/NoDuplicatesClasspath.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java
Modified:
   branches/infinispan-int/build/build.xml
   branches/infinispan-int/component-matrix/pom.xml
   branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
   branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java
   branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/TxConnectionManager.java
   branches/infinispan-int/ejb3/pom.xml
   branches/infinispan-int/server/src/bin/service.bat
   branches/infinispan-int/testsuite/build.xml
   branches/infinispan-int/testsuite/imports/config/configs.xml
   branches/infinispan-int/webservices/pom.xml
   branches/infinispan-int/weld-int/assembly/pom.xml
   branches/infinispan-int/weld-int/assembly/src/main/assembly/assembly.xml
   branches/infinispan-int/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml
   branches/infinispan-int/weld-int/deployer/pom.xml
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/injection/NonContextualObjectInjectionHelper.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java
   branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractWeldTest.java
Log:
merge from trunk revision 107514

Modified: branches/infinispan-int/build/build.xml
===================================================================
--- branches/infinispan-int/build/build.xml	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/build/build.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -720,7 +720,6 @@
       </fileset>
     	<fileset refid="org.jboss.ejb3.embedded:jboss-ejb3-embedded-impl-as:jar"/>
     	<fileset refid="org.jboss.shrinkwrap:shrinkwrap-extension-vdf:jar" />
-      <fileset refid="org.jboss.ejb3.timerservice:jboss-ejb3-timerservice-mk2:jar"/>
 	  <fileset dir="${ejb3.module.output}/resources/META-INF">
         <include name="singleton-container-aop.xml"/>
       </fileset>
@@ -729,6 +728,11 @@
       
     </copy>
 
+      <mkdir dir="${install.server}/all/deploy/jboss-ejb3-timerservice-mk2.jar"/>
+      <unjar dest="${install.server}/all/deploy/jboss-ejb3-timerservice-mk2.jar">
+          <fileset refid="org.jboss.ejb3.timerservice:jboss-ejb3-timerservice-mk2:jar"/>
+      </unjar>
+
     <!-- Copy across client jars -->
     <mkdir dir="${install.client}"/>
     <copy file="${ejb3.module.output}/jboss-as-ejb3-client.jar"
@@ -2133,7 +2137,6 @@
       <fileset refid="org.jboss.ejb3:jboss-ejb3-security:jar"/>
       <fileset refid="org.jboss.ejb3:jboss-ejb3-timerservice-spi:jar"/>
       <fileset refid="org.jboss.ejb3:jboss-ejb3-transactions:jar"/>
-      <fileset refid="org.jboss.ejb3:jboss-ejb3_1:jar"/>
       <fileset refid="org.jboss.ejb3.proxy:proxy-spi:jar"/>
       <fileset refid="org.jboss.ejb3.proxy:proxy-javassist:jar"/>
 	  <fileset refid="org.jboss.ejb3.proxy:proxy-reflect:jar"/>

Modified: branches/infinispan-int/component-matrix/pom.xml
===================================================================
--- branches/infinispan-int/component-matrix/pom.xml	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/component-matrix/pom.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -42,6 +42,7 @@
     <version.asm>2.2.3</version.asm>
     <version.beanvalidation.integration>1.0.0-Beta-1</version.beanvalidation.integration>
     <version.commons.beanutils>1.8.0</version.commons.beanutils>
+    <version.com.google.guava>r06</version.com.google.guava>
     <version.fastinfoset>1.2.2</version.fastinfoset>
     <version.hornetq>2.1.1.Final</version.hornetq>
     <version.rhq>1.4.0.B01</version.rhq>
@@ -107,7 +108,7 @@
     <version.org.jboss.cluster.server.ispn>1.0.0.Alpha2</version.org.jboss.cluster.server.ispn>
     <version.org.jboss.common.core>2.2.17.GA</version.org.jboss.common.core>
     <version.org.jboss.deployers>2.2.0.Alpha6</version.org.jboss.deployers>
-    <version.org.jboss.ejb3.bom>0.2.0-SNAPSHOT</version.org.jboss.ejb3.bom>
+    <version.org.jboss.ejb3.depchain>1.0.0-alpha-1</version.org.jboss.ejb3.depchain>
     <!-- This to move into the EJB3 BOM -->
     <version.org.jboss.ejb3.embedded>1.0.0-alpha-1</version.org.jboss.ejb3.embedded>
     <version.org.jboss.ejb.api>1.0-alpha-1</version.org.jboss.ejb.api>
@@ -124,9 +125,9 @@
     <version.org.jboss.jpa.mcint>1.0.0-alpha-2</version.org.jboss.jpa.mcint>
     <version.org.jboss.jpa.spi>1.0.0</version.org.jboss.jpa.spi>
     <version.org.jboss.kernel>2.2.0.Alpha10</version.org.jboss.kernel>
-    <version.org.jboss.logging>3.0.0.Beta2</version.org.jboss.logging>
-    <version.org.jboss.logging-service-metadata>1.0.0.CR8</version.org.jboss.logging-service-metadata>
-    <version.org.jboss.logmanager>1.2.0.CR2</version.org.jboss.logmanager>
+    <version.org.jboss.logging>3.0.0.Beta4</version.org.jboss.logging>
+    <version.org.jboss.logging-service-metadata>1.0.0.CR9</version.org.jboss.logging-service-metadata>
+    <version.org.jboss.logmanager>1.2.0.CR4</version.org.jboss.logmanager>
     <version.org.jboss.man>2.1.1.SP2</version.org.jboss.man>
     <version.org.jboss.marshalling>1.3.0.CR3</version.org.jboss.marshalling>
     <version.org.jboss.mc-int>2.2.0.Alpha2</version.org.jboss.mc-int>
@@ -257,6 +258,12 @@
       </dependency>
 
       <dependency>
+          <groupId>com.google.guava</groupId>
+          <artifactId>guava</artifactId>
+          <version>${version.com.google.guava}</version>
+      </dependency>
+
+      <dependency>
       <groupId>org.jboss.jbossas</groupId>
       <artifactId>weld-int-assembly</artifactId>
       <type>pom</type>
@@ -1708,7 +1715,7 @@
       <dependency>
         <groupId>org.jboss.slf4j</groupId>
         <artifactId>slf4j-jboss-logmanager</artifactId>
-        <version>1.0.0.CR2</version>
+        <version>1.0.0.CR3</version>
       </dependency>
 
       <dependency>
@@ -2860,9 +2867,9 @@
         </dependency>
         
       <dependency>
-        <groupId>org.jboss.ejb3.bom</groupId>
-        <artifactId>bom-as6</artifactId>
-        <version>${version.org.jboss.ejb3.bom}</version>
+        <groupId>org.jboss.ejb3.depchain</groupId>
+        <artifactId>jboss-ejb3-depchain-as6</artifactId>
+        <version>${version.org.jboss.ejb3.depchain}</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
@@ -3991,10 +3998,10 @@
                         <exclude>sun-jaxws:streambuffer</exclude>
                         <exclude>sun-jaxws:jsr181-api</exclude>
                         <exclude>sun-jaxws:jaxws-api</exclude>
-			               <!-- JBAS-7531 org.jboss.ejb3:jboss-ejb3-as-int is retired.
-			                    Use org.jboss.ejb3:jboss-ejb3_1 instead
--->
+			                  <!-- JBAS-7531 org.jboss.ejb3:jboss-ejb3-as-int is retired. -->
 			                  <exclude>org.jboss.ejb3:jboss-ejb3-as-int</exclude>
+			                  <!-- JBAS-8307 Use org.jboss.ejb3.depchain:jboss-ejb3-depchain-as6 -->
+			                  <exclude>org.jboss.ejb3:jboss-ejb3_1</exclude>
 			                  <exclude>org.jboss.microcontainer:jboss-aop-mc-int</exclude>
 			                  <exclude>org.jboss.microcontainer:jboss-dependency</exclude>
 			                  <exclude>org.jboss.microcontainer:jboss-guice-int</exclude>

Modified: branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
===================================================================
--- branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -87,6 +87,9 @@
 
    /** Whether trace is enabled */
    private final boolean trace;
+   
+   /** The subpool */
+   private JBossManagedConnectionPool.SubPoolContext subPoolContext;
 
    /** Stats */
    private final Counter connectionCounter = new Counter();
@@ -114,6 +117,7 @@
     */
    protected InternalManagedConnectionPool(ManagedConnectionFactory mcf, ConnectionListenerFactory clf, Subject subject,
                                            ConnectionRequestInfo cri, PoolParams poolParams, JBossManagedConnectionPool jmcp,
+                                           JBossManagedConnectionPool.SubPoolContext subPoolContext,
                                            Logger log)
    {
       this.mcf = mcf;
@@ -124,6 +128,7 @@
       this.maxSize = poolParams.maxSize;
       this.jmcp = jmcp;
       this.log = log;
+      this.subPoolContext = subPoolContext;
       this.trace = log.isTraceEnabled();
       this.cls = new ArrayList(this.maxSize);
       this.permits = new Semaphore(this.maxSize, true);
@@ -844,6 +849,11 @@
       return poolParams.minSize;
    }
 
+   public JBossManagedConnectionPool.SubPoolContext getSubPoolContext()
+   {
+      return subPoolContext;
+   }
+
    public static class PoolParams
    {
 	   public int minSize = 0;

Modified: branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java
===================================================================
--- branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -562,7 +562,7 @@
       public SubPoolContext(TransactionManager tm, ManagedConnectionFactory mcf, ConnectionListenerFactory clf, Subject subject,
                             ConnectionRequestInfo cri, PoolParams poolParams, JBossManagedConnectionPool jmcp, Logger log)
       {
-         subPool = new InternalManagedConnectionPool(mcf, clf, subject, cri, poolParams, jmcp, log);
+         subPool = new InternalManagedConnectionPool(mcf, clf, subject, cri, poolParams, jmcp, this, log);
          if (tm != null)
             trackByTx = new TransactionLocal(tm);
       }

Modified: branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/TxConnectionManager.java
===================================================================
--- branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/TxConnectionManager.java	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/connector/src/main/java/org/jboss/resource/connectionmanager/TxConnectionManager.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -50,6 +50,7 @@
 import org.jboss.resource.JBossResourceException;
 import org.jboss.resource.connectionmanager.xa.XAResourceWrapperImpl;
 import org.jboss.tm.LastResource;
+import org.jboss.tm.TransactionLocal;
 import org.jboss.tm.TransactionTimeoutConfiguration;
 import org.jboss.tm.TxUtils;
 import org.jboss.util.NestedRuntimeException;
@@ -424,6 +425,29 @@
          {
             cls.add(cl);
             cl.enlist();
+            if(!isInterleaving())
+            {
+            	cl.setTrackByTx(true);
+            	InternalManagedConnectionPool imcp = (InternalManagedConnectionPool)cl.getContext();
+            	JBossManagedConnectionPool.SubPoolContext subPool = imcp.getSubPoolContext();
+            	TransactionLocal trackByTx = subPool.getTrackByTx();
+            	try
+            	{
+            		trackByTx.lock();
+            	}
+            	catch (Throwable t)
+                {
+            		rethrowAsSystemException("Unable to begin transaction with JCA lazy enlistment scenario", trackByTx.getTransaction(), t);
+                }            	
+            	try
+            	{
+            		trackByTx.set(cl);
+            	}
+            	finally
+            	{
+            		trackByTx.unlock();
+            	}
+            }
          }
       }
    }

Modified: branches/infinispan-int/ejb3/pom.xml
===================================================================
--- branches/infinispan-int/ejb3/pom.xml	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/ejb3/pom.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -5,6 +5,7 @@
     <groupId>org.jboss.jbossas</groupId>
     <artifactId>jboss-as-parent</artifactId>
     <version>6.0.0-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
   </parent>
   
   <modelVersion>4.0.0</modelVersion>
@@ -236,8 +237,9 @@
     </dependency>
     
     <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3_1</artifactId>
+      <groupId>org.jboss.ejb3.depchain</groupId>
+      <artifactId>jboss-ejb3-depchain-as6</artifactId>
+      <version>${version.org.jboss.ejb3.depchain}</version>
       <exclusions>
         <!-- JBAS-679, may be removed when as-int is >= 1.1.5 -->
         <exclusion>
@@ -245,6 +247,10 @@
           <artifactId>jboss-ejb3-proxy</artifactId>
         </exclusion>
         <exclusion>
+          <groupId> org.jboss.microcontainer</groupId>
+          <artifactId>jboss-aop-mc-int</artifactId>
+        </exclusion>
+        <exclusion>
           <groupId>org.jboss.cache</groupId>
           <artifactId>jbosscache-core</artifactId>
         </exclusion>
@@ -318,6 +324,7 @@
           <artifactId>jaxws-api</artifactId>
         </exclusion>
       </exclusions>
+      <type>pom</type>
     </dependency>
     
     <dependency>

Modified: branches/infinispan-int/server/src/bin/service.bat
===================================================================
--- branches/infinispan-int/server/src/bin/service.bat	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/server/src/bin/service.bat	2010-08-10 15:04:17 UTC (rev 107524)
@@ -14,7 +14,7 @@
 set DIRNAME=%CD%
 
 rem Read an optional configuration file.
-if "x%RUN_CONF%" == "x" (   
+if "x%RUN_CONF%" == "x" (
    set "RUN_CONF=%DIRNAME%\run.conf.bat"
 )
 if exist "%RUN_CONF%" (
@@ -25,7 +25,7 @@
 REM VERSION, VERSION_MAJOR and VERSION_MINOR are populated
 REM during the build with ant filter.
 REM
-if "x%SVCNAME" == "x" (
+if "x%SVCNAME%" == "x" (
     set "SVCNAME=JBAS60SVC"
 )
 set SVCDISP=JBoss Application Server 6.0

Modified: branches/infinispan-int/testsuite/build.xml
===================================================================
--- branches/infinispan-int/testsuite/build.xml	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/testsuite/build.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1027,6 +1027,7 @@
       <exclude name="**/test/web/security/authorization/XACMLWeb*.class"/>
       <exclude name="**/test/security/test/client/*UnitTestCase.class"/>
       <exclude name="**/test/passwordinjection/test/*UnitTestCase.class"/>
+      <exclude name="**/test/security/test/authorization/secured/*UnitTestCase.class"/>
    </patternset>
    <!-- A patternset that requires jboss to run with a security manager -->
    <patternset id="securitymgr.includes">

Modified: branches/infinispan-int/testsuite/imports/config/configs.xml
===================================================================
--- branches/infinispan-int/testsuite/imports/config/configs.xml	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/testsuite/imports/config/configs.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -15,5 +15,6 @@
 <import file="tests-bootstrap-dependencies.xml"/>
 <import file="tests-password-mask.xml"/>
 <import file="tests-jts.xml"/>
+<import file="tests-secured.xml"/>
 
 </project>

Copied: branches/infinispan-int/testsuite/imports/config/tests-secured.xml (from rev 107515, trunk/testsuite/imports/config/tests-secured.xml)
===================================================================
--- branches/infinispan-int/testsuite/imports/config/tests-secured.xml	                        (rev 0)
+++ branches/infinispan-int/testsuite/imports/config/tests-secured.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+
+<!--
+   | Targets that run the Secured Mask tests
+-->
+ 
+<project name="main.server.config.secured" xmlns:server="http://jboss.org/ns/test/ant/server">
+
+  <!--
+  |  Define the Pattern Sets Here
+  --> 
+  <patternset id="secured.mask.includes">
+    <include name="org/jboss/test/security/test/authorization/secured/*TestCase.class"/>
+  </patternset>
+
+  <!--
+    | Targets
+  -->
+   <target name="tests-secured" 
+           description="Run tests on secured profiles">
+<!--     
+     <server:start name="default"/>
+       <run-junit junit.patternset="secured.mask.includes"/>
+     <server:stop name="default"/>
+-->     
+
+     <server:start name="all"/>
+       <run-junit junit.patternset="secured.mask.includes"/>
+     <server:stop name="all"/>
+
+  </target>
+</project>
+

Copied: branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured (from rev 107515, trunk/testsuite/src/main/org/jboss/test/security/test/authorization/secured)

Deleted: branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestJmxAuthenticationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestJmxAuthenticationUnitTestCase.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestJmxAuthenticationUnitTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,114 +0,0 @@
-package org.jboss.test.security.test.authorization.secured;
-
-import java.net.*;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.jboss.test.JBossTestCase;
-import org.jboss.test.JBossTestSetup;
-
-/**
- * Test verifies that there is no jmx-console security baypass in secured profiles.
- * Reused test from JBPAPP-3952, JBPAPP-4160.
- *
- * @author bshim at redhat.com
- * @author rsvoboda at redhat.com
- */
-public class HttpRequestJmxAuthenticationUnitTestCase extends JBossTestCase {
-	
-	private URL u;
-	private HttpURLConnection con;
-	private static final String GET = "GET";
-	private static final String POST = "POST";
-	private static final String HEAD = "HEAD";
-	private static final String OPTIONS = "OPTIONS";
-	private static final String PUT = "PUT";
-	private static final String DELETE = "DELETE";
-	private static final String TRACE = "TRACE"; 
-	
-	public HttpRequestJmxAuthenticationUnitTestCase(String name){
-		super(name);
-	}
-	
-	public static Test suite() throws Exception {
-		TestSuite suite = new TestSuite();
-		suite.addTest(new TestSuite(HttpRequestJmxAuthenticationUnitTestCase.class));
-		// Create an initializer for the test suite
-		TestSetup wrapper = new JBossTestSetup(suite)
-	      		{
-         		@Override
-        	 	protected void setUp() throws Exception
-	         	{
-            			super.setUp();
-         		}
-
-        	 	@Override
-	         	protected void tearDown() throws Exception
-         		{
-        	    		super.tearDown();
-        		}
-      		};
-      		return wrapper;
-	}
-
-	public void testGet() throws Exception {
-		con.setRequestMethod(GET);
-		con.connect();			
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	public void testPost() throws Exception {
-		con.setRequestMethod(POST);
-		con.connect();
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	public void testHead() throws Exception {
-		con.setRequestMethod(HEAD);
-		con.connect();			
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	public void testOptions() throws Exception {
-		con.setRequestMethod(OPTIONS);
-		con.connect();
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	public void testPut() throws Exception {
-		con.setRequestMethod(PUT);
-		con.connect();			
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	public void testTrace()  throws Exception {
-		con.setRequestMethod(TRACE);
-		con.connect();
-                assertEquals(HttpURLConnection.HTTP_BAD_METHOD, con.getResponseCode());
-	}
-	
-	public void testDelete()  throws Exception {
-		con.setRequestMethod(DELETE);
-		con.connect();
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	protected void setUp() throws Exception {
-		super.setUp();
-		u = new URL("http://" + getServerHost() + ":8080/jmx-console");
-		con = (HttpURLConnection) u.openConnection();
-		try {
-			con.setDoInput(true);
-			con.setRequestProperty("Cookie","MODIFY ME IF NEEDED");
-		} finally {
-			con.disconnect();
-		}
-	}
-	
-	protected void tearDown(){
-		if (con != null)
-			con.disconnect();
-	}
-}

Copied: branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestJmxAuthenticationUnitTestCase.java (from rev 107515, trunk/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestJmxAuthenticationUnitTestCase.java)
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestJmxAuthenticationUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestJmxAuthenticationUnitTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,114 @@
+package org.jboss.test.security.test.authorization.secured;
+
+import java.net.*;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.JBossTestSetup;
+
+/**
+ * Test verifies that there is no jmx-console security baypass in secured profiles.
+ * Reused test from JBPAPP-3952, JBPAPP-4160.
+ *
+ * @author bshim at redhat.com
+ * @author rsvoboda at redhat.com
+ */
+public class HttpRequestJmxAuthenticationUnitTestCase extends JBossTestCase {
+	
+	private URL u;
+	private HttpURLConnection con;
+	private static final String GET = "GET";
+	private static final String POST = "POST";
+	private static final String HEAD = "HEAD";
+	private static final String OPTIONS = "OPTIONS";
+	private static final String PUT = "PUT";
+	private static final String DELETE = "DELETE";
+	private static final String TRACE = "TRACE"; 
+	
+	public HttpRequestJmxAuthenticationUnitTestCase(String name){
+		super(name);
+	}
+	
+	public static Test suite() throws Exception {
+		TestSuite suite = new TestSuite();
+		suite.addTest(new TestSuite(HttpRequestJmxAuthenticationUnitTestCase.class));
+		// Create an initializer for the test suite
+		TestSetup wrapper = new JBossTestSetup(suite)
+	      		{
+         		@Override
+        	 	protected void setUp() throws Exception
+	         	{
+            			super.setUp();
+         		}
+
+        	 	@Override
+	         	protected void tearDown() throws Exception
+         		{
+        	    		super.tearDown();
+        		}
+      		};
+      		return wrapper;
+	}
+
+	public void testGet() throws Exception {
+		con.setRequestMethod(GET);
+		con.connect();			
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	public void testPost() throws Exception {
+		con.setRequestMethod(POST);
+		con.connect();
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	public void testHead() throws Exception {
+		con.setRequestMethod(HEAD);
+		con.connect();			
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	public void testOptions() throws Exception {
+		con.setRequestMethod(OPTIONS);
+		con.connect();
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	public void testPut() throws Exception {
+		con.setRequestMethod(PUT);
+		con.connect();			
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	public void testTrace()  throws Exception {
+		con.setRequestMethod(TRACE);
+		con.connect();
+                assertEquals(HttpURLConnection.HTTP_BAD_METHOD, con.getResponseCode());
+	}
+	
+	public void testDelete()  throws Exception {
+		con.setRequestMethod(DELETE);
+		con.connect();
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	protected void setUp() throws Exception {
+		super.setUp();
+		u = new URL("http://" + getServerHost() + ":8080/jmx-console");
+		con = (HttpURLConnection) u.openConnection();
+		try {
+			con.setDoInput(true);
+			con.setRequestProperty("Cookie","MODIFY ME IF NEEDED");
+		} finally {
+			con.disconnect();
+		}
+	}
+	
+	protected void tearDown(){
+		if (con != null)
+			con.disconnect();
+	}
+}

Deleted: branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestStatusServletAuthenticationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestStatusServletAuthenticationUnitTestCase.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestStatusServletAuthenticationUnitTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,112 +0,0 @@
-package org.jboss.test.security.test.authorization.secured;
-
-import java.net.HttpURLConnection;
-import java.net.URL;
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.jboss.test.JBossTestCase;
-import org.jboss.test.JBossTestSetup;
-
-/**
- * Test verifies that there is no /status servlet security baypass in secured profiles.
- *
- * @author rsvoboda at redhat.com
- */
-public class HttpRequestStatusServletAuthenticationUnitTestCase extends JBossTestCase {
-	
-	private URL u;
-	private HttpURLConnection con;
-	private static final String GET = "GET";
-	private static final String POST = "POST";
-	private static final String HEAD = "HEAD";
-	private static final String OPTIONS = "OPTIONS";
-	private static final String PUT = "PUT";
-	private static final String DELETE = "DELETE";
-	private static final String TRACE = "TRACE"; 
-	
-	public HttpRequestStatusServletAuthenticationUnitTestCase(String name){
-		super(name);
-	}
-	
-	public static Test suite() throws Exception {
-		TestSuite suite = new TestSuite();
-		suite.addTest(new TestSuite(HttpRequestStatusServletAuthenticationUnitTestCase.class));
-		// Create an initializer for the test suite
-		TestSetup wrapper = new JBossTestSetup(suite)
-	      		{
-         		@Override
-        	 	protected void setUp() throws Exception
-	         	{
-            			super.setUp();
-         		}
-
-        	 	@Override
-	         	protected void tearDown() throws Exception
-         		{
-        	    		super.tearDown();
-        		}
-      		};
-      		return wrapper;
-	}
-
-	public void testGet() throws Exception {
-		con.setRequestMethod(GET);
-		con.connect();			
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	public void testPost() throws Exception {
-		con.setRequestMethod(POST);
-		con.connect();
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	public void testHead() throws Exception {
-		con.setRequestMethod(HEAD);
-		con.connect();			
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	public void testOptions() throws Exception {
-		con.setRequestMethod(OPTIONS);
-		con.connect();
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	public void testPut() throws Exception {
-		con.setRequestMethod(PUT);
-		con.connect();			
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	public void testTrace()  throws Exception {
-		con.setRequestMethod(TRACE);
-		con.connect();
-                assertEquals(HttpURLConnection.HTTP_BAD_METHOD, con.getResponseCode());
-	}
-	
-	public void testDelete()  throws Exception {
-		con.setRequestMethod(DELETE);
-		con.connect();
-		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
-	}
-	
-	protected void setUp() throws Exception {
-		super.setUp();
-		u = new URL("http://" + getServerHost() + ":8080/status");
-		con = (HttpURLConnection) u.openConnection();
-		try {
-			con.setDoInput(true);
-			con.setRequestProperty("Cookie","MODIFY ME IF NEEDED");
-		} finally {
-			con.disconnect();
-		}
-	}
-	
-	protected void tearDown(){
-		if (con != null)
-			con.disconnect();
-	}
-}

Copied: branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestStatusServletAuthenticationUnitTestCase.java (from rev 107515, trunk/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestStatusServletAuthenticationUnitTestCase.java)
===================================================================
--- branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestStatusServletAuthenticationUnitTestCase.java	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/main/org/jboss/test/security/test/authorization/secured/HttpRequestStatusServletAuthenticationUnitTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,112 @@
+package org.jboss.test.security.test.authorization.secured;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.JBossTestSetup;
+
+/**
+ * Test verifies that there is no /status servlet security baypass in secured profiles.
+ *
+ * @author rsvoboda at redhat.com
+ */
+public class HttpRequestStatusServletAuthenticationUnitTestCase extends JBossTestCase {
+	
+	private URL u;
+	private HttpURLConnection con;
+	private static final String GET = "GET";
+	private static final String POST = "POST";
+	private static final String HEAD = "HEAD";
+	private static final String OPTIONS = "OPTIONS";
+	private static final String PUT = "PUT";
+	private static final String DELETE = "DELETE";
+	private static final String TRACE = "TRACE"; 
+	
+	public HttpRequestStatusServletAuthenticationUnitTestCase(String name){
+		super(name);
+	}
+	
+	public static Test suite() throws Exception {
+		TestSuite suite = new TestSuite();
+		suite.addTest(new TestSuite(HttpRequestStatusServletAuthenticationUnitTestCase.class));
+		// Create an initializer for the test suite
+		TestSetup wrapper = new JBossTestSetup(suite)
+	      		{
+         		@Override
+        	 	protected void setUp() throws Exception
+	         	{
+            			super.setUp();
+         		}
+
+        	 	@Override
+	         	protected void tearDown() throws Exception
+         		{
+        	    		super.tearDown();
+        		}
+      		};
+      		return wrapper;
+	}
+
+	public void testGet() throws Exception {
+		con.setRequestMethod(GET);
+		con.connect();			
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	public void testPost() throws Exception {
+		con.setRequestMethod(POST);
+		con.connect();
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	public void testHead() throws Exception {
+		con.setRequestMethod(HEAD);
+		con.connect();			
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	public void testOptions() throws Exception {
+		con.setRequestMethod(OPTIONS);
+		con.connect();
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	public void testPut() throws Exception {
+		con.setRequestMethod(PUT);
+		con.connect();			
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	public void testTrace()  throws Exception {
+		con.setRequestMethod(TRACE);
+		con.connect();
+                assertEquals(HttpURLConnection.HTTP_BAD_METHOD, con.getResponseCode());
+	}
+	
+	public void testDelete()  throws Exception {
+		con.setRequestMethod(DELETE);
+		con.connect();
+		assertEquals(HttpURLConnection.HTTP_UNAUTHORIZED, con.getResponseCode());
+	}
+	
+	protected void setUp() throws Exception {
+		super.setUp();
+		u = new URL("http://" + getServerHost() + ":8080/status");
+		con = (HttpURLConnection) u.openConnection();
+		try {
+			con.setDoInput(true);
+			con.setRequestProperty("Cookie","MODIFY ME IF NEEDED");
+		} finally {
+			con.disconnect();
+		}
+	}
+	
+	protected void tearDown(){
+		if (con != null)
+			con.disconnect();
+	}
+}

Modified: branches/infinispan-int/webservices/pom.xml
===================================================================
--- branches/infinispan-int/webservices/pom.xml	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/webservices/pom.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -179,8 +179,8 @@
       </exclusions>
     </dependency>
     <dependency>
-      <groupId>org.jboss.ejb3</groupId>
-      <artifactId>jboss-ejb3_1</artifactId>
+      <groupId>org.jboss.ejb3.depchain</groupId>
+      <artifactId>jboss-ejb3-depchain-as6</artifactId>
       <exclusions>
         <exclusion>
           <groupId>org.jboss.ejb3</groupId>
@@ -259,7 +259,13 @@
           <groupId>sun-jaxws</groupId>
           <artifactId>jaxws-api</artifactId>
         </exclusion>
+        <exclusion>
+          <groupId> org.jboss.microcontainer</groupId>
+          <artifactId>jboss-aop-mc-int</artifactId>
+        </exclusion>
       </exclusions>
+      <type>pom</type>
+      <version>${version.org.jboss.ejb3.depchain}</version>
     </dependency>
     <dependency>
       <groupId>org.jboss.ejb3</groupId>

Copied: branches/infinispan-int/weld-int/.settings (from rev 107515, trunk/weld-int/.settings)

Modified: branches/infinispan-int/weld-int/assembly/pom.xml
===================================================================
--- branches/infinispan-int/weld-int/assembly/pom.xml	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/weld-int/assembly/pom.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -11,8 +11,7 @@
    <packaging>jar</packaging>
    <name>JBoss Application Server Weld Integration Assembly</name>
    <description>Weld deployer assembly for JBoss AS</description>
-
-
+    
     <build>
         <plugins>
             <plugin>
@@ -128,6 +127,10 @@
               <groupId>org.jboss.interceptor</groupId>
               <artifactId>jboss-interceptor-api</artifactId>
           </exclusion>
+          <exclusion>
+              <groupId>com.google.collections</groupId>
+              <artifactId>google-collections</artifactId>
+          </exclusion>
       </exclusions>
     </dependency>
 
@@ -154,7 +157,13 @@
       <artifactId>weld-spi</artifactId>
       <optional>true</optional>
     </dependency>
-      
+
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+    </dependency>
+
+
    </dependencies>
    
 </project>

Modified: branches/infinispan-int/weld-int/assembly/src/main/assembly/assembly.xml
===================================================================
--- branches/infinispan-int/weld-int/assembly/src/main/assembly/assembly.xml	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/weld-int/assembly/src/main/assembly/assembly.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -23,15 +23,14 @@
       <dependencySet>
          <outputFileNameMapping>${artifact.artifactId}.${artifact.extension}</outputFileNameMapping>
          <includes>
-            <include>com.google.collections:google-collections</include>
+            <include>com.google.guava:guava</include>
             <include>org.slf4j:slf4j-ext:jar</include>
             <include>ch.qos.cal10n:cal10n-api</include>
             <include>org.jboss.weld:weld-spi</include>
             <include>org.jboss.jbossas:weld-int-ejb</include>
             <include>org.jboss.jbossas:weld-int-deployer</include>
             <include>org.jboss.jbossas:weld-int-deployer-mc-int</include>
-            <include>org.jboss.kernel:jboss-weld-int</include>
-            
+
             <include>org.jboss.interceptor:jboss-interceptor</include>
          </includes>
       </dependencySet>
@@ -41,7 +40,9 @@
          <outputDirectory>lib-int</outputDirectory>
          <includes>
             <include>org.jboss.weld:weld-core</include>
-            <include>org.jboss.jbossas:weld-int-webtier</include>            
+            <include>org.jboss.jbossas:weld-int-webtier</include>
+            <include>org.jboss.kernel:jboss-weld-int</include>
+
          </includes>
       </dependencySet>
    </dependencySets>

Modified: branches/infinispan-int/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml
===================================================================
--- branches/infinispan-int/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -38,6 +38,8 @@
   <!-- Responsible for pushing Weld onto the application classpath -->
   <bean name="WeldCoreIntegrationDeployer" class="org.jboss.weld.integration.deployer.cl.WeldCoreIntegrationDeployer"/>
 
+  <bean name="WeldMcExtensionsIntegrationDeployer" class="org.jboss.weld.integration.deployer.cl.WeldMcExtensionsIntegrationDeployer"/>
+
   <!-- Responsible for inserting the Weld EJB interceptor -->
   <bean name="PostEjbJarMetadataDeployer" class="org.jboss.weld.integration.deployer.metadata.WeldEjbInterceptorMetadataDeployer"/>
   

Modified: branches/infinispan-int/weld-int/deployer/pom.xml
===================================================================
--- branches/infinispan-int/weld-int/deployer/pom.xml	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/weld-int/deployer/pom.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -347,75 +347,93 @@
       <artifactId>jboss-logging</artifactId>
       <scope>provided</scope>
     </dependency>
-       
-       <dependency>
-         <groupId>org.jboss.ejb3</groupId>
-         <artifactId>jboss-ejb3-core</artifactId>
-         <scope>provided</scope>
-         <exclusions>
-           <exclusion>
-              <groupId>org.jboss.microcontainer</groupId>
-              <artifactId>jboss-kernel</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>apache-xerces</groupId>
-             <artifactId>xml-apis</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>org.jboss.microcontainer</groupId>
-             <artifactId>jboss-dependency</artifactId>
-           </exclusion>
-            <exclusion>
-               <groupId>org.jboss.microcontainer</groupId>
-               <artifactId>jboss-aop-mc-int</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>org.jboss.javaee</groupId>
-             <artifactId>jboss-jaspi-api</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>org.jboss.javaee</groupId>
-             <artifactId>jboss-jca-api</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>org.jboss.javaee</groupId>
-             <artifactId>jboss-jacc-api</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>org.jboss.javaee</groupId>
-             <artifactId>jboss-transaction-api</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>org.jboss.javaee</groupId>
-             <artifactId>jboss-jms-api</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>org.jboss.javaee</groupId>
-             <artifactId>jboss-ejb-api</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>org.jboss.logging</groupId>
-             <artifactId>jboss-logging-spi</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>org.jboss.logging</groupId>
-             <artifactId>jboss-logging-log4j</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>sun-jaxws</groupId>
-             <artifactId>jsr181-api</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>quartz</groupId>
-             <artifactId>quartz</artifactId>
-           </exclusion>
-           <exclusion>
-             <groupId>sun-jaxws</groupId>
-             <artifactId>jaxws-api</artifactId>
-           </exclusion>
-         </exclusions>
-       </dependency>
-      
+
+    <dependency>
+       <groupId>org.jboss.shrinkwrap</groupId>
+       <artifactId>shrinkwrap-impl-base</artifactId>
+       <scope>test</scope>
+    </dependency>
+
+    <dependency>
+       <groupId>org.jboss.shrinkwrap</groupId>
+       <artifactId>shrinkwrap-extension-vfs3</artifactId>
+       <scope>test</scope>
+        <exclusions>
+          <exclusion>
+            <groupId>org.jboss</groupId>
+            <artifactId>jboss-vfs</artifactId>
+          </exclusion>
+        </exclusions>
+    </dependency>
+
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-core</artifactId>
+      <scope>provided</scope>
+      <exclusions>
+        <exclusion>
+           <groupId>org.jboss.microcontainer</groupId>
+           <artifactId>jboss-kernel</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>apache-xerces</groupId>
+          <artifactId>xml-apis</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-dependency</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.microcontainer</groupId>
+          <artifactId>jboss-aop-mc-int</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.javaee</groupId>
+          <artifactId>jboss-jaspi-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.javaee</groupId>
+          <artifactId>jboss-jca-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.javaee</groupId>
+          <artifactId>jboss-jacc-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.javaee</groupId>
+          <artifactId>jboss-transaction-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.javaee</groupId>
+          <artifactId>jboss-jms-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.javaee</groupId>
+          <artifactId>jboss-ejb-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.logging</groupId>
+          <artifactId>jboss-logging-spi</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.logging</groupId>
+          <artifactId>jboss-logging-log4j</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>sun-jaxws</groupId>
+          <artifactId>jsr181-api</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>quartz</groupId>
+          <artifactId>quartz</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>sun-jaxws</groupId>
+          <artifactId>jaxws-api</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    
    </dependencies>
 
 </project>

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/cl/WeldMcExtensionsIntegrationDeployer.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/cl/WeldMcExtensionsIntegrationDeployer.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/cl/WeldMcExtensionsIntegrationDeployer.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/cl/WeldMcExtensionsIntegrationDeployer.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,34 @@
+package org.jboss.weld.integration.deployer.cl;
+
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.weld.integration.deployer.DeployersUtils;
+import org.jboss.weld.integration.deployer.ext.JBossWeldMetaData;
+
+/**
+ * Web Beans  core integration deployer.
+ *
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class WeldMcExtensionsIntegrationDeployer extends WeldUrlIntegrationDeployer<JBossWeldMetaData>
+{
+   public WeldMcExtensionsIntegrationDeployer()
+   {
+      super(JBossWeldMetaData.class);
+      setTopLevelOnly(true); // only top level, as that's where Bootstrap bean is gonna be
+      setInputs(DeployersUtils.WELD_FILES);
+      setIntegrationURLs(getURLs());
+   }
+
+   @Override // we override this, as we want any beans.xml
+   protected boolean isIntegrationDeployment(VFSDeploymentUnit unit)
+   {
+      return DeployersUtils.checkForWeldFiles(unit);
+   }
+
+   @Override
+   protected String getShortLibName()
+   {
+      return "jboss-weld-int.jar";
+   }
+}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveDiscoveryDeployer.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveDiscoveryDeployer.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveDiscoveryDeployer.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveDiscoveryDeployer.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,145 @@
+/*
+ * 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.weld.integration.deployer.env;
+
+import java.net.URL;
+import java.util.Collection;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.visitor.ClassFilter;
+import org.jboss.classloading.spi.visitor.ResourceContext;
+import org.jboss.classloading.spi.visitor.ResourceFilter;
+import org.jboss.classloading.spi.visitor.ResourceVisitor;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.vfs.spi.deployer.AbstractOptionalVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.util.NotImplementedException;
+import org.jboss.vfs.VirtualFile;
+import org.jboss.weld.integration.deployer.DeployersUtils;
+import org.jboss.weld.integration.deployer.env.bda.ArchiveInfo;
+import org.jboss.weld.integration.deployer.ext.JBossWeldMetaData;
+
+/**
+ * ArchiveDiscovery deployer.
+ * Deploys information into ArchiveInfo's environment.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class ArchiveDiscoveryDeployer extends AbstractOptionalVFSRealDeployer<JBossWeldMetaData>
+{
+   public ArchiveDiscoveryDeployer()
+   {
+      super(JBossWeldMetaData.class);
+      addInput(DeployersUtils.WELD_FILES);
+      addInput(DeployersUtils.WELD_CLASSPATH);
+      addInput(ArchiveInfo.class);
+      addOutput(ArchiveInfo.class);
+      setStage(DeploymentStages.PRE_REAL);
+   }
+
+   public void deploy(VFSDeploymentUnit unit, JBossWeldMetaData deployment) throws DeploymentException
+   {
+      @SuppressWarnings("unchecked")
+      Collection<VirtualFile> wbFiles = unit.getAttachment(DeployersUtils.WELD_FILES, Collection.class);
+      boolean hasWB = (wbFiles != null && wbFiles.isEmpty() == false);
+
+      @SuppressWarnings("unchecked")
+      Collection<VirtualFile> cpFiles = unit.getAttachment(DeployersUtils.WELD_CLASSPATH, Collection.class);
+      boolean hasCp = (cpFiles != null && cpFiles.isEmpty() == false);
+
+      if (!hasWB && !hasCp)
+      {
+         return;
+      }
+      
+      try
+      {
+         ArchiveInfo archive = null;
+         if (hasCp)
+         {
+            VFSDeploymentUnit moduleUnit = unit;
+            Module module = moduleUnit.getAttachment(Module.class);
+            while (moduleUnit != null && module == null)
+            {
+               moduleUnit = moduleUnit.getParent();
+               module = moduleUnit.getAttachment(Module.class);
+            }
+            if (module == null)
+               throw new DeploymentException("No module in deployment unit's hierarchy: " + unit.getName());
+
+            URL[] urls = new URL[cpFiles.size()];
+            int i = 0;
+            for (VirtualFile file : cpFiles)
+            {
+               urls[i++] = file.toURL();
+            }
+            
+            archive = moduleUnit.getAttachment(ArchiveInfo.class);
+            if (archive == null)
+            {
+               throw new IllegalStateException("Archive attachment expected for unit " + unit);
+            }
+            WeldDiscoveryEnvironment environment = archive.getEnvironment();
+            WBDiscoveryVisitor visitor = new WBDiscoveryVisitor(environment);
+            module.visit(visitor, ClassFilter.INSTANCE, null, urls);
+            if (hasWB)
+            {
+               for (VirtualFile file : wbFiles)
+                  environment.addWeldXmlURL(file.toURL());
+               
+            }
+         }
+         else if (hasWB)
+         {
+            // FIXME
+            throw new NotImplementedException();
+         }
+      }
+      catch (Exception e)
+      {
+         throw DeploymentException.rethrowAsDeploymentException("Cannot build WB env.", e);
+      }
+   }
+
+   
+   private static class WBDiscoveryVisitor implements ResourceVisitor
+   {
+      private WeldDiscoveryEnvironment wbdi;
+
+      private WBDiscoveryVisitor(WeldDiscoveryEnvironment wbdi)
+      {
+         this.wbdi = wbdi;
+      }
+
+      public ResourceFilter getFilter()
+      {
+         return ClassFilter.INSTANCE;
+      }
+
+      public void visit(ResourceContext resource)
+      {
+         wbdi.addWeldClass(resource.loadClass());
+      }
+   }
+}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveInfoDeployer.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveInfoDeployer.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveInfoDeployer.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/ArchiveInfoDeployer.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,62 @@
+/*
+ * 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.weld.integration.deployer.env;
+
+import org.jboss.classloading.spi.RealClassLoader;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.vfs.spi.deployer.AbstractOptionalVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.util.NotImplementedException;
+import org.jboss.weld.integration.deployer.env.bda.ArchiveInfo;
+import org.jboss.weld.integration.deployer.ext.JBossWeldMetaData;
+
+/**
+ * ArchiveInfo deployer.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class ArchiveInfoDeployer extends AbstractOptionalVFSRealDeployer<JBossWeldMetaData>
+{
+   public ArchiveInfoDeployer()
+   {
+      super(JBossWeldMetaData.class);
+      addOutput(ArchiveInfo.class);
+      setStage(DeploymentStages.POST_CLASSLOADER);
+   }
+
+   public void deploy(VFSDeploymentUnit unit, JBossWeldMetaData deployment) throws DeploymentException
+   {
+      ClassLoader classLoader = unit.getClassLoader();
+      if (!unit.isTopLevel() && unit.getParent().getClassLoader() == classLoader)
+      {
+         return;
+      }
+      if (classLoader instanceof RealClassLoader)
+      {
+         unit.addAttachment(ArchiveInfo.class, new ArchiveInfo(classLoader));
+      }
+      else
+         // FIXME
+         throw new NotImplementedException();
+   }
+}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossDeploymentDeployer.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossDeploymentDeployer.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossDeploymentDeployer.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossDeploymentDeployer.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,85 @@
+/*
+ * 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.weld.integration.deployer.env;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.integration.deployer.env.bda.ArchiveInfo;
+import org.jboss.weld.integration.deployer.env.bda.DeploymentImpl;
+
+/**
+ * JBoss Deployment Deployer.
+ * Creates metadata for creation of a Deployment.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class JBossDeploymentDeployer extends AbstractDeploymentDeployer
+{
+   public JBossDeploymentDeployer()
+   {
+      super();
+      addInput(ArchiveInfo.class);
+   }
+
+   @Override
+   protected boolean isRelevant(DeploymentUnit unit)
+   {
+      return unit.isAttachmentPresent(ArchiveInfo.class);
+   }
+
+   protected Class<? extends Deployment> getDeploymentClass()
+   {
+      return DeploymentImpl.class;
+   }
+
+   protected void buildDeployment(DeploymentUnit unit, BootstrapInfo info, BeanMetaDataBuilder builder)
+   {
+      builder.addConstructorParameter(String.class.getName(), unit.getName());
+      builder.addConstructorParameter(Collection.class.getName(), getArchiveInfos(unit));
+      builder.addConstructorParameter(Collection.class.getName(), builder.createInject(info.getEjbServices().getUnderlyingValue(), "ejbs"));
+      builder.addUninstall("undeploy");
+   }
+   
+   private Collection<ArchiveInfo> getArchiveInfos(DeploymentUnit unit)
+   {
+      Collection<ArchiveInfo> archiveInfos = new ArrayList<ArchiveInfo>();
+      fill(archiveInfos, unit);
+      return archiveInfos;
+   }
+   
+   private void fill(Collection<ArchiveInfo> archiveInfos, DeploymentUnit unit)
+   {
+      ArchiveInfo archiveInfo = unit.getAttachment(ArchiveInfo.class);
+      if (archiveInfo != null)
+      {
+         archiveInfos.add(archiveInfo);
+      }
+      for (DeploymentUnit child: unit.getChildren())
+      {
+         fill(archiveInfos, child);
+      }
+   }
+}
\ No newline at end of file

Modified: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldDiscoveryEnvironment.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -64,7 +64,9 @@
     */
    public Collection<Class<?>> getWeldClasses()
    {
-      return Collections.unmodifiableCollection(classes);
+      // FIXME WELDINT-1 old classes that use this method should get an Unmodifiable
+      // collection; if those classes are not deleted this method needs to be reviewed
+      return classes;
    }
 
    /**

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda)

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,254 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.ejb.spi.EjbDescriptor;
-
-/**
- * An archive is an abstract representation of one or more deployed archives.
- * It mainly contains a list of classes and an optional list of bean.xml file URLs
- * (only when those files are available).
- * <br>
- * Every archive can provide a corresponding BeanDeploymentArchive when requested. Notice
- * that the provided BeanDeploymentArchive is simply a different view of the archive.
- * <br>
- * As for class loading related issues, every archive is associated with the class loader
- * responsible for loading it during deployment and is also associated with a classpath.
- * This classpath contains a list of all archives visible to an archive and is used for
- * iterating over both the archive graph and the corresponding BeanDeploymentArchive graph.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- * @see Classpath
- */
-class Archive
-{
-
-   // the classes contained in this archive
-   private final Collection<Class<?>> classes;
-
-   // the bean.xml URLs contained in this archive
-   private final Collection<URL> xmlURLs;
-
-   // the classloader that loaded this archive
-   private final ClassLoader classLoader;
-   
-   // the classpath of this archive
-   private final Classpath classpath;
-
-   // the bda view of this archive, if available
-   private BeanDeploymentArchiveImpl bda;
-
-   // the ejbs
-   private final Collection<EjbDescriptor<?>> ejbs;
-
-   // the list of all bdaLifecycleListeners
-   private final Collection<ArchiveLifecycleListener> lifecycleListeners;
-
-   /**
-    * Constructor. Can only be called by ArchiveFactory.
-    * 
-    * @param archiveInfo contains all information necessary for the initialization of this
-    *                    archive
-    * @param ejbs        the list of ejb descriptors
-    * @see ArchiveFactory#createArchive(ArchiveInfo, Collection)
-    */
-   public Archive(ArchiveInfo archiveInfo, Collection<EjbDescriptor<?>> ejbs)
-   {
-      this.lifecycleListeners = new ArrayList<ArchiveLifecycleListener>();
-      this.classes = archiveInfo.getEnvironment().getWeldClasses();
-      this.xmlURLs = archiveInfo.getEnvironment().getWeldXml();
-      this.classLoader = archiveInfo.getClassLoader();
-      this.classpath = archiveInfo.getClasspath();
-      this.classpath.addArchive(this);
-      this.ejbs = ejbs;
-   }
-
-   /**
-    * Returns all classes contained in this archive.
-    * 
-    * @return the classes contained in this archive
-    */
-   public Collection<Class<?>> getClasses()
-   {
-      return classes;
-   }
-
-   /**
-    * Indicates whether this archive contains the requested class.
-    * 
-    * @param beanClass a class that could be contained in this archive
-    * @return          {@code true} only if this archive contains {@code beanClass}
-    */
-   public boolean containsClass(Class<?> beanClass)
-   {
-      return beanClass.getClassLoader() == this.classLoader;
-   }
-   
-   /**
-    * Indicates whether {@code beanClass} is visible to this BDA
-    * @param   beanClass the beanClass
-    * @return  {@code true} if {@code beanClass} is visible to this BDA
-    */
-   public boolean isClassVisible(Class<?> beanClass)
-   {
-      Class<?> loadedClass = null;
-      try
-      {
-         loadedClass = this.getClassLoader().loadClass(beanClass.getName());
-      }
-      catch (ClassNotFoundException e)
-      {
-         return false;
-      }
-      return loadedClass == beanClass;
-   }
-   
-   
-   /**
-    * Adds a class to this archive.
-    * 
-    * @param beanClass a class whose ClassLoader is associated with this archive
-    */
-   public void addClass(Class<?> beanClass)
-   {
-      classes.add(beanClass);
-   }
-
-   /**
-    * Returns the URLs of all bean.xml files contained in this archive.
-    * 
-    * @return the URLs of the bean.xml files
-    */
-   public Collection<URL> getXmlURLs()
-   {
-      return xmlURLs;
-   }
-
-   /**
-    * Indicates whether this archive has one or more bean.xml files
-    * 
-    * @return {@code true} if this archive contains a bean.xml file
-    */
-   public boolean hasXml()
-   {
-      return xmlURLs != null && !xmlURLs.isEmpty();
-   }
-
-   /**
-    * Returns the classloader that loaded this archive.
-    * 
-    * @return the classloader that loaded this archive
-    */
-   public ClassLoader getClassLoader()
-   {
-      return classLoader;
-   }
-
-   /**
-    * Returns the classpath of this archive, that contains all archives visible to this
-    * archive. This classpath can also be used to retrieve the bdas visible to the bda
-    * associated with this archive, when this bda is avaialble.
-    * 
-    * @return the classpath
-    */
-   public Classpath getClasspath()
-   {
-      return classpath;
-   }
-
-   /**
-    * Returns the BeanDeploymentArchive that corresponds to this archive.
-    * 
-    * @return the BeanDeploymentArchive representing this archive. May be {@code null} if
-    *         it has not been created
-    */
-   public BeanDeploymentArchive getBeanDeploymentArchive()
-   {
-      return bda;
-   }
-
-   /**
-    * Creates the BeanDeploymentArchive that corresponds to this archive. This method
-    * never returns duplicates.
-    * 
-    * @return the BeanDeploymentArchive representing this archive. If this bda has not
-    *         been created, it is created and returned
-    */
-   public BeanDeploymentArchive createBeanDeploymentArchive()
-   {
-      if (bda == null)
-      {
-         bda = new BeanDeploymentArchiveImpl(classLoader.toString(), this);
-         for (ArchiveLifecycleListener listener: lifecycleListeners)
-         {
-            // notifies the listener that this archive became visible as a BDA
-            listener.archiveVisible(this, bda);
-         }
-      }
-      return bda;
-   }
-
-   /**
-    * Adds an ArchiveLifecycleListener. When called prior to BDA creation, this listener
-    * will be notified when this archive becomes visible through the BDA view. The
-    * listener will also be notified when this archive (and its BDA, if available) is
-    * destroyed (undeployment)
-    * 
-    * @param listener an ArchiveLifecycleListener
-    */
-   public void addLifecycleListener(ArchiveLifecycleListener listener)
-   {
-      this.lifecycleListeners.add(listener);
-   }
-
-   /**
-    * Return the collection of EJBDescriptors.
-    * 
-    * @return the ejbs associated with this Archive
-    */
-   public Collection<EjbDescriptor<?>> getEjbs()
-   {
-      return ejbs;
-   }
-
-   /**
-    * Notifies this archive that it is being undeployed.
-    */
-   public void undeploy()
-   {
-      for (ArchiveLifecycleListener listener: lifecycleListeners)
-      {
-         listener.archiveDestroyed(this);
-      }
-   }
-
-   public String toString()
-   {
-      return "Archive[" + classLoader + "]";
-   }
-}

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,254 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+
+/**
+ * An archive is an abstract representation of one or more deployed archives.
+ * It mainly contains a list of classes and an optional list of bean.xml file URLs
+ * (only when those files are available).
+ * <br>
+ * Every archive can provide a corresponding BeanDeploymentArchive when requested. Notice
+ * that the provided BeanDeploymentArchive is simply a different view of the archive.
+ * <br>
+ * As for class loading related issues, every archive is associated with the class loader
+ * responsible for loading it during deployment and is also associated with a classpath.
+ * This classpath contains a list of all archives visible to an archive and is used for
+ * iterating over both the archive graph and the corresponding BeanDeploymentArchive graph.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ * @see Classpath
+ */
+class Archive
+{
+
+   // the classes contained in this archive
+   private final Collection<Class<?>> classes;
+
+   // the bean.xml URLs contained in this archive
+   private final Collection<URL> xmlURLs;
+
+   // the classloader that loaded this archive
+   private final ClassLoader classLoader;
+   
+   // the classpath of this archive
+   private final Classpath classpath;
+
+   // the bda view of this archive, if available
+   private BeanDeploymentArchiveImpl bda;
+
+   // the ejbs
+   private final Collection<EjbDescriptor<?>> ejbs;
+
+   // the list of all bdaLifecycleListeners
+   private final Collection<ArchiveLifecycleListener> lifecycleListeners;
+
+   /**
+    * Constructor. Can only be called by ArchiveFactory.
+    * 
+    * @param archiveInfo contains all information necessary for the initialization of this
+    *                    archive
+    * @param ejbs        the list of ejb descriptors
+    * @see ArchiveFactory#createArchive(ArchiveInfo, Collection)
+    */
+   public Archive(ArchiveInfo archiveInfo, Collection<EjbDescriptor<?>> ejbs)
+   {
+      this.lifecycleListeners = new ArrayList<ArchiveLifecycleListener>();
+      this.classes = archiveInfo.getEnvironment().getWeldClasses();
+      this.xmlURLs = archiveInfo.getEnvironment().getWeldXml();
+      this.classLoader = archiveInfo.getClassLoader();
+      this.classpath = archiveInfo.getClasspath();
+      this.classpath.addArchive(this);
+      this.ejbs = ejbs;
+   }
+
+   /**
+    * Returns all classes contained in this archive.
+    * 
+    * @return the classes contained in this archive
+    */
+   public Collection<Class<?>> getClasses()
+   {
+      return classes;
+   }
+
+   /**
+    * Indicates whether this archive contains the requested class.
+    * 
+    * @param beanClass a class that could be contained in this archive
+    * @return          {@code true} only if this archive contains {@code beanClass}
+    */
+   public boolean containsClass(Class<?> beanClass)
+   {
+      return beanClass.getClassLoader() == this.classLoader;
+   }
+   
+   /**
+    * Indicates whether {@code beanClass} is visible to this BDA
+    * @param   beanClass the beanClass
+    * @return  {@code true} if {@code beanClass} is visible to this BDA
+    */
+   public boolean isClassVisible(Class<?> beanClass)
+   {
+      Class<?> loadedClass = null;
+      try
+      {
+         loadedClass = this.getClassLoader().loadClass(beanClass.getName());
+      }
+      catch (ClassNotFoundException e)
+      {
+         return false;
+      }
+      return loadedClass == beanClass;
+   }
+   
+   
+   /**
+    * Adds a class to this archive.
+    * 
+    * @param beanClass a class whose ClassLoader is associated with this archive
+    */
+   public void addClass(Class<?> beanClass)
+   {
+      classes.add(beanClass);
+   }
+
+   /**
+    * Returns the URLs of all bean.xml files contained in this archive.
+    * 
+    * @return the URLs of the bean.xml files
+    */
+   public Collection<URL> getXmlURLs()
+   {
+      return xmlURLs;
+   }
+
+   /**
+    * Indicates whether this archive has one or more bean.xml files
+    * 
+    * @return {@code true} if this archive contains a bean.xml file
+    */
+   public boolean hasXml()
+   {
+      return xmlURLs != null && !xmlURLs.isEmpty();
+   }
+
+   /**
+    * Returns the classloader that loaded this archive.
+    * 
+    * @return the classloader that loaded this archive
+    */
+   public ClassLoader getClassLoader()
+   {
+      return classLoader;
+   }
+
+   /**
+    * Returns the classpath of this archive, that contains all archives visible to this
+    * archive. This classpath can also be used to retrieve the bdas visible to the bda
+    * associated with this archive, when this bda is avaialble.
+    * 
+    * @return the classpath
+    */
+   public Classpath getClasspath()
+   {
+      return classpath;
+   }
+
+   /**
+    * Returns the BeanDeploymentArchive that corresponds to this archive.
+    * 
+    * @return the BeanDeploymentArchive representing this archive. May be {@code null} if
+    *         it has not been created
+    */
+   public BeanDeploymentArchive getBeanDeploymentArchive()
+   {
+      return bda;
+   }
+
+   /**
+    * Creates the BeanDeploymentArchive that corresponds to this archive. This method
+    * never returns duplicates.
+    * 
+    * @return the BeanDeploymentArchive representing this archive. If this bda has not
+    *         been created, it is created and returned
+    */
+   public BeanDeploymentArchive createBeanDeploymentArchive()
+   {
+      if (bda == null)
+      {
+         bda = new BeanDeploymentArchiveImpl(classLoader.toString(), this);
+         for (ArchiveLifecycleListener listener: lifecycleListeners)
+         {
+            // notifies the listener that this archive became visible as a BDA
+            listener.archiveVisible(this, bda);
+         }
+      }
+      return bda;
+   }
+
+   /**
+    * Adds an ArchiveLifecycleListener. When called prior to BDA creation, this listener
+    * will be notified when this archive becomes visible through the BDA view. The
+    * listener will also be notified when this archive (and its BDA, if available) is
+    * destroyed (undeployment)
+    * 
+    * @param listener an ArchiveLifecycleListener
+    */
+   public void addLifecycleListener(ArchiveLifecycleListener listener)
+   {
+      this.lifecycleListeners.add(listener);
+   }
+
+   /**
+    * Return the collection of EJBDescriptors.
+    * 
+    * @return the ejbs associated with this Archive
+    */
+   public Collection<EjbDescriptor<?>> getEjbs()
+   {
+      return ejbs;
+   }
+
+   /**
+    * Notifies this archive that it is being undeployed.
+    */
+   public void undeploy()
+   {
+      for (ArchiveLifecycleListener listener: lifecycleListeners)
+      {
+         listener.archiveDestroyed(this);
+      }
+   }
+
+   public String toString()
+   {
+      return "Archive[" + classLoader + "]";
+   }
+}

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveCollection.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveCollection.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveCollection.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,97 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-
-/**
- * A collection of archives.
- * This collection contains not only the archives added to it, as it also contains
- * an updated list of the bdas corresponding to those archives when available.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- */
-class ArchiveCollection implements ArchiveLifecycleListener, Iterable<Archive>
-{
-   // the archives collection
-   protected Collection<Archive> archives = new ArrayList<Archive>();
-   
-   // the bdas collection
-   protected Collection<BeanDeploymentArchive> bdas = new ArrayList<BeanDeploymentArchive>();
-
-   /**
-    * Adds an archive to this collection.
-    * 
-    * @param archive the archive to be added
-    */
-   public synchronized void add(Archive archive)
-   {
-      archives.add(archive);
-      archive.addLifecycleListener(this);
-   }
-
-   /**
-    * For concurrent safe iteration, synchronize the iteration block using this collection
-    * as a synchronization lock.
-    */
-   public Iterator<Archive> iterator()
-   {
-      return archives.iterator();
-   }
-
-   /**
-    * Returns the BeanDeploymentArchive collection corresponding to this archive collection
-    *  
-    * @return a collection of all previously created BeanDeploymentArchives that represent
-    *         the archives in this collection
-    */
-   public Collection<BeanDeploymentArchive> getBDAs()
-   {
-      return this.bdas;
-   }
-
-   public synchronized void archiveVisible(Archive archive, BeanDeploymentArchive bda)
-   {
-      synchronized(bdas)
-      {
-         bdas.add(bda);
-      }
-   }
-
-   public synchronized void archiveDestroyed(Archive archive)
-   {
-      synchronized(bdas)
-      {
-         archives.remove(archive);
-         BeanDeploymentArchive bda = archive.getBeanDeploymentArchive();
-         if (bda != null)
-         {
-            bdas.remove(bda);
-         }
-      }
-   }
-}

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveCollection.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveCollection.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveCollection.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveCollection.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,97 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+
+/**
+ * A collection of archives.
+ * This collection contains not only the archives added to it, as it also contains
+ * an updated list of the bdas corresponding to those archives when available.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class ArchiveCollection implements ArchiveLifecycleListener, Iterable<Archive>
+{
+   // the archives collection
+   protected Collection<Archive> archives = new ArrayList<Archive>();
+   
+   // the bdas collection
+   protected Collection<BeanDeploymentArchive> bdas = new ArrayList<BeanDeploymentArchive>();
+
+   /**
+    * Adds an archive to this collection.
+    * 
+    * @param archive the archive to be added
+    */
+   public synchronized void add(Archive archive)
+   {
+      archives.add(archive);
+      archive.addLifecycleListener(this);
+   }
+
+   /**
+    * For concurrent safe iteration, synchronize the iteration block using this collection
+    * as a synchronization lock.
+    */
+   public Iterator<Archive> iterator()
+   {
+      return archives.iterator();
+   }
+
+   /**
+    * Returns the BeanDeploymentArchive collection corresponding to this archive collection
+    *  
+    * @return a collection of all previously created BeanDeploymentArchives that represent
+    *         the archives in this collection
+    */
+   public Collection<BeanDeploymentArchive> getBDAs()
+   {
+      return this.bdas;
+   }
+
+   public synchronized void archiveVisible(Archive archive, BeanDeploymentArchive bda)
+   {
+      synchronized(bdas)
+      {
+         bdas.add(bda);
+      }
+   }
+
+   public synchronized void archiveDestroyed(Archive archive)
+   {
+      synchronized(bdas)
+      {
+         archives.remove(archive);
+         BeanDeploymentArchive bda = archive.getBeanDeploymentArchive();
+         if (bda != null)
+         {
+            bdas.remove(bda);
+         }
+      }
+   }
+}

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveFactory.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveFactory.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveFactory.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,61 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.util.Collection;
-
-import org.jboss.weld.ejb.spi.EjbDescriptor;
-
-/**
- * An archive factory.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- * @see Archive
- */
-class ArchiveFactory
-{
-   /**
-    * Creates an Archive, and performs some initialization operations required for
-    * consistency and cleanup of the ArchiveInfo.
-    * <br>
-    * This factory method can be called only when {@code ejbs} become
-    * available. Prior to this stage, use {@link ArchiveInfo} to keep data during deployment.
-    * 
-    * @param archiveInfo contains all information necessary for the initialization of the
-    *                    archive
-    * @param ejbs        the list of EJB descriptors
-    */
-   public static Archive createArchive(ArchiveInfo archiveInfo, Collection<EjbDescriptor<?>> ejbs)
-   {
-      Archive archive = new Archive(archiveInfo, ejbs);
-      if (archiveInfo.hasClasspathAdapter())
-      {
-         // initialize adapter
-         ArchiveToClasspath classpathAdapter = archiveInfo.getClasspathAdapter();
-         classpathAdapter.addArchive(archive);
-      }
-      // dispose archiveInfo
-      archiveInfo.cleanUp();
-      return archive;
-   }
-}

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveFactory.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveFactory.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveFactory.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveFactory.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,61 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.util.Collection;
+
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+
+/**
+ * An archive factory.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ * @see Archive
+ */
+class ArchiveFactory
+{
+   /**
+    * Creates an Archive, and performs some initialization operations required for
+    * consistency and cleanup of the ArchiveInfo.
+    * <br>
+    * This factory method can be called only when {@code ejbs} become
+    * available. Prior to this stage, use {@link ArchiveInfo} to keep data during deployment.
+    * 
+    * @param archiveInfo contains all information necessary for the initialization of the
+    *                    archive
+    * @param ejbs        the list of EJB descriptors
+    */
+   public static Archive createArchive(ArchiveInfo archiveInfo, Collection<EjbDescriptor<?>> ejbs)
+   {
+      Archive archive = new Archive(archiveInfo, ejbs);
+      if (archiveInfo.hasClasspathAdapter())
+      {
+         // initialize adapter
+         ArchiveToClasspath classpathAdapter = archiveInfo.getClasspathAdapter();
+         classpathAdapter.addArchive(archive);
+      }
+      // dispose archiveInfo
+      archiveInfo.cleanUp();
+      return archive;
+   }
+}

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveInfo.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveInfo.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveInfo.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,149 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.jboss.weld.integration.deployer.env.WeldDiscoveryEnvironment;
-
-/**
- * Contains information necessary for the creation of an Archive.
- * All the information contained in a ArchiveInfo is gathered during deployment and is
- * not considered initialized (i.e., this information is not ready to be used for
- * BeanDeploymentArchive and Deployment creation) 
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- */
-public class ArchiveInfo
-{
-   // creates the classpaths for the archive
-   private static final ClasspathFactory classpathFactory = ClasspathFactory.getInstance();
-
-   // keeps track of the instances that are currently under use by deployers
-   private static final Map<ClassLoader, ArchiveInfo> instances = new WeakHashMap<ClassLoader, ArchiveInfo>();
-   
-   /**
-    * Returns the ArchiveInfo instance that corresponds to the given class loader.
-    * Only ArchiveInfo instances under use can be returned.
-    * 
-    * @param classLoader the class loader
-    * @return            the ArchiveInfo instance that contains {@code classLoader}
-    */
-   public static final ArchiveInfo getInstance(ClassLoader classLoader)
-   {
-      return instances.get(classLoader);
-   }
-   
-   // adapts an Archive to a Classpath
-   private ArchiveToClasspath classpathAdapter;
-   // the classpath
-   private Classpath classpath;
-   // the class loader
-   private ClassLoader classLoader;
-   // the discovery environment
-   private final WeldDiscoveryEnvironment environment;
-   
-   /**
-    * Creates an ArchiveInfo to keep track of all data related to an archive
-    * during deployment.
-    * 
-    * @param classLoader the classLoader that is loading the archive under deployment.
-    */
-   public ArchiveInfo(ClassLoader classLoader)
-   {
-      instances.put(classLoader, this);
-      this.classLoader = classLoader;
-      this.classpath = classpathFactory.create(classLoader);
-      this.environment = new WeldDiscoveryEnvironment();
-   }
-
-   /**
-    * Returns the classloader that is loading the archive under deployment.
-    * 
-    * @return the classloader
-    */
-   public ClassLoader getClassLoader()
-   {
-      return this.classLoader;
-   }
-
-   /**
-    * The classpath of the archive under deployment.
-    * 
-    * @return the claspath
-    */
-   public Classpath getClasspath()
-   {
-      return classpath;
-   }
-
-   /**
-    * Returns the archive environment information.
-    * 
-    * @return the environment information
-    */
-   public WeldDiscoveryEnvironment getEnvironment()
-   {
-      return this.environment;
-   }
-
-   /**
-    * Returns a classpath adapter, indicating that the archive under deployment will be
-    * used as a classpath itself.
-    * 
-    * @return a classpath adapter
-    */
-   ArchiveToClasspath getClasspathAdapter()
-   {
-      if (classpathAdapter == null)
-      {
-         classpathAdapter = new ArchiveToClasspath();
-      }
-      return classpathAdapter;
-   }
-   
-   /**
-    * Indicates whether a classpath adapter for this archive has been created.
-    * 
-    * @return {@code true} if a classpath adapter has been created
-    */
-   boolean hasClasspathAdapter()
-   {
-      return this.classpathAdapter != null;
-   }
-
-   /**
-    * Performs cleanup of this archive, indicating that it is no longer in use and will
-    * be discarded.
-    */
-   void cleanUp()
-   {
-      instances.remove(this.classLoader);
-   }
-   
-   public String toString()
-   {
-      return "ArchiveInfo[" + classLoader + "]";
-   }
-}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveInfo.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveInfo.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveInfo.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveInfo.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,149 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.jboss.weld.integration.deployer.env.WeldDiscoveryEnvironment;
+
+/**
+ * Contains information necessary for the creation of an Archive.
+ * All the information contained in a ArchiveInfo is gathered during deployment and is
+ * not considered initialized (i.e., this information is not ready to be used for
+ * BeanDeploymentArchive and Deployment creation) 
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ArchiveInfo
+{
+   // creates the classpaths for the archive
+   private static final ClasspathFactory classpathFactory = ClasspathFactory.getInstance();
+
+   // keeps track of the instances that are currently under use by deployers
+   private static final Map<ClassLoader, ArchiveInfo> instances = new WeakHashMap<ClassLoader, ArchiveInfo>();
+   
+   /**
+    * Returns the ArchiveInfo instance that corresponds to the given class loader.
+    * Only ArchiveInfo instances under use can be returned.
+    * 
+    * @param classLoader the class loader
+    * @return            the ArchiveInfo instance that contains {@code classLoader}
+    */
+   public static final ArchiveInfo getInstance(ClassLoader classLoader)
+   {
+      return instances.get(classLoader);
+   }
+   
+   // adapts an Archive to a Classpath
+   private ArchiveToClasspath classpathAdapter;
+   // the classpath
+   private Classpath classpath;
+   // the class loader
+   private ClassLoader classLoader;
+   // the discovery environment
+   private final WeldDiscoveryEnvironment environment;
+   
+   /**
+    * Creates an ArchiveInfo to keep track of all data related to an archive
+    * during deployment.
+    * 
+    * @param classLoader the classLoader that is loading the archive under deployment.
+    */
+   public ArchiveInfo(ClassLoader classLoader)
+   {
+      instances.put(classLoader, this);
+      this.classLoader = classLoader;
+      this.classpath = classpathFactory.create(classLoader);
+      this.environment = new WeldDiscoveryEnvironment();
+   }
+
+   /**
+    * Returns the classloader that is loading the archive under deployment.
+    * 
+    * @return the classloader
+    */
+   public ClassLoader getClassLoader()
+   {
+      return this.classLoader;
+   }
+
+   /**
+    * The classpath of the archive under deployment.
+    * 
+    * @return the claspath
+    */
+   public Classpath getClasspath()
+   {
+      return classpath;
+   }
+
+   /**
+    * Returns the archive environment information.
+    * 
+    * @return the environment information
+    */
+   public WeldDiscoveryEnvironment getEnvironment()
+   {
+      return this.environment;
+   }
+
+   /**
+    * Returns a classpath adapter, indicating that the archive under deployment will be
+    * used as a classpath itself.
+    * 
+    * @return a classpath adapter
+    */
+   ArchiveToClasspath getClasspathAdapter()
+   {
+      if (classpathAdapter == null)
+      {
+         classpathAdapter = new ArchiveToClasspath();
+      }
+      return classpathAdapter;
+   }
+   
+   /**
+    * Indicates whether a classpath adapter for this archive has been created.
+    * 
+    * @return {@code true} if a classpath adapter has been created
+    */
+   boolean hasClasspathAdapter()
+   {
+      return this.classpathAdapter != null;
+   }
+
+   /**
+    * Performs cleanup of this archive, indicating that it is no longer in use and will
+    * be discarded.
+    */
+   void cleanUp()
+   {
+      instances.remove(this.classLoader);
+   }
+   
+   public String toString()
+   {
+      return "ArchiveInfo[" + classLoader + "]";
+   }
+}
\ No newline at end of file

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveLifecycleListener.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveLifecycleListener.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveLifecycleListener.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,51 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-
-
-/**
- * Observes the lifecyle of a BeanDeploymentArchive.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision: 1.1 
- * @see Archive#addLifecycleListener(BDALifecycleListener)
- */
-interface ArchiveLifecycleListener
-{
-   /**
-    * Notifies this listener that an Archive is visible to Weld classes in the form of
-    * a BDA.
-    * 
-    * @param archive the archive whose corresponding BDA was created
-    * @param bda     a Weld spi view that represents {@code archive}
-    */
-   public void archiveVisible(Archive archive, BeanDeploymentArchive bda);
-   
-   /**
-    * Notifies that {@code archive} is being destroyed.
-    * 
-    * @param archive the archive
-    */
-   public void archiveDestroyed(Archive archive);
-}

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveLifecycleListener.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveLifecycleListener.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveLifecycleListener.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveLifecycleListener.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,51 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+
+
+/**
+ * Observes the lifecyle of a BeanDeploymentArchive.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision: 1.1 
+ * @see Archive#addLifecycleListener(BDALifecycleListener)
+ */
+interface ArchiveLifecycleListener
+{
+   /**
+    * Notifies this listener that an Archive is visible to Weld classes in the form of
+    * a BDA.
+    * 
+    * @param archive the archive whose corresponding BDA was created
+    * @param bda     a Weld spi view that represents {@code archive}
+    */
+   public void archiveVisible(Archive archive, BeanDeploymentArchive bda);
+   
+   /**
+    * Notifies that {@code archive} is being destroyed.
+    * 
+    * @param archive the archive
+    */
+   public void archiveDestroyed(Archive archive);
+}

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveToClasspath.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveToClasspath.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveToClasspath.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,98 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-
-/**
- * A Classpath adapter for an archive.
- * This is used when a single Archive is used as classpath for another Archive.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- * @see Classpath
- */
-class ArchiveToClasspath implements Classpath, ArchiveLifecycleListener
-{
-   // the archive
-   private Archive archive;
-   // the bda corresponding to archive, if available
-   private Collection<BeanDeploymentArchive> bda;
-   // an unitary collection containing archive
-   private Collection<Archive> archives;
-
-   public String getName()
-   {
-      return archive.toString();
-   }
-
-   /**
-    * This method performs initialization of this classpath, setting the archive it
-    * represents.
-    * This classpath is not functional until this method is invoked.
-    */
-   public void addArchive(Archive archive)
-   {
-      this.archive = archive;
-      archives = new ArrayList<Archive>();
-      archives.add(archive);
-   }
-
-   public Iterator<Archive> iterator()
-   {
-      return archives.iterator();
-   }
-   
-   public Classpath getClasspath()
-   {
-      return archive.getClasspath();
-   }
-
-   public Collection<BeanDeploymentArchive> getBDAs(BeanDeploymentArchive bda)
-   {
-      if (this.bda == null)
-      {
-         return archive.getClasspath().getBDAs(bda);
-      }
-      return this.bda;
-   }
-
-   public void archiveVisible(Archive archive, BeanDeploymentArchive bda)
-   {
-      this.bda = new ArrayList<BeanDeploymentArchive>();
-      this.bda.add(bda);
-   }
-
-   public void archiveDestroyed(Archive archive)
-   {
-      // do nothing, as this instance is also being destroyed
-   }
-   
-   public String toString()
-   {
-      return archive.toString();
-   }
-}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveToClasspath.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveToClasspath.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveToClasspath.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ArchiveToClasspath.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,98 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+
+/**
+ * A Classpath adapter for an archive.
+ * This is used when a single Archive is used as classpath for another Archive.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ * @see Classpath
+ */
+class ArchiveToClasspath implements Classpath, ArchiveLifecycleListener
+{
+   // the archive
+   private Archive archive;
+   // the bda corresponding to archive, if available
+   private Collection<BeanDeploymentArchive> bda;
+   // an unitary collection containing archive
+   private Collection<Archive> archives;
+
+   public String getName()
+   {
+      return archive.toString();
+   }
+
+   /**
+    * This method performs initialization of this classpath, setting the archive it
+    * represents.
+    * This classpath is not functional until this method is invoked.
+    */
+   public void addArchive(Archive archive)
+   {
+      this.archive = archive;
+      archives = new ArrayList<Archive>();
+      archives.add(archive);
+   }
+
+   public Iterator<Archive> iterator()
+   {
+      return archives.iterator();
+   }
+   
+   public Classpath getClasspath()
+   {
+      return archive.getClasspath();
+   }
+
+   public Collection<BeanDeploymentArchive> getBDAs(BeanDeploymentArchive bda)
+   {
+      if (this.bda == null)
+      {
+         return archive.getClasspath().getBDAs(bda);
+      }
+      return this.bda;
+   }
+
+   public void archiveVisible(Archive archive, BeanDeploymentArchive bda)
+   {
+      this.bda = new ArrayList<BeanDeploymentArchive>();
+      this.bda.add(bda);
+   }
+
+   public void archiveDestroyed(Archive archive)
+   {
+      // do nothing, as this instance is also being destroyed
+   }
+   
+   public String toString()
+   {
+      return archive.toString();
+   }
+}
\ No newline at end of file

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,106 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.net.URL;
-import java.util.Collection;
-
-import org.jboss.weld.bootstrap.api.ServiceRegistry;
-import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.ejb.spi.EjbDescriptor;
-
-/**
- * {@link BeanDeploymentArchive} implementation for JBoss AS.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- */
-class BeanDeploymentArchiveImpl implements BeanDeploymentArchive
-{
-   // identifies this BDA
-   private final String id;
-
-   // the Archive that this BDA represents
-   private final Archive archive;
-
-   // the services provided by this BDA
-   private final ServiceRegistry services;
-
-   /**
-    * Constructor.
-    * 
-    * @param id      the identifier name of this BeanDeploymentArchive
-    * @param archive the archive that this BeanDeploymentArchive represents
-    */
-   public BeanDeploymentArchiveImpl(String id, Archive archive)
-   {
-      this.id = id;
-      this.archive = archive;
-      this.services = new SimpleServiceRegistry();
-   }
-
-   public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
-   {
-      return archive.getClasspath().getBDAs(this);
-   }
-
-   public Collection<Class<?>> getBeanClasses()
-   {
-      return archive.getClasses();
-   }
-
-   public Collection<URL> getBeansXml()
-   {
-      return archive.getXmlURLs();
-   }
-
-   public Collection<EjbDescriptor<?>> getEjbs()
-   {
-      return archive.getEjbs();
-   }
-
-   public ServiceRegistry getServices()
-   {
-      return services;
-   }
-
-   public String getId()
-   {
-      return id;
-   }
-
-   /**
-    * Returns the archive that this BDA represents.
-    * 
-    * @return the archive
-    */
-   public Archive getArchive()
-   {
-      return archive;
-   }
-   
-   public String toString()
-   {
-      return archive.toString();
-   }
-}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,106 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.net.URL;
+import java.util.Collection;
+
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+
+/**
+ * {@link BeanDeploymentArchive} implementation for JBoss AS.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class BeanDeploymentArchiveImpl implements BeanDeploymentArchive
+{
+   // identifies this BDA
+   private final String id;
+
+   // the Archive that this BDA represents
+   private final Archive archive;
+
+   // the services provided by this BDA
+   private final ServiceRegistry services;
+
+   /**
+    * Constructor.
+    * 
+    * @param id      the identifier name of this BeanDeploymentArchive
+    * @param archive the archive that this BeanDeploymentArchive represents
+    */
+   public BeanDeploymentArchiveImpl(String id, Archive archive)
+   {
+      this.id = id;
+      this.archive = archive;
+      this.services = new SimpleServiceRegistry();
+   }
+
+   public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
+   {
+      return archive.getClasspath().getBDAs(this);
+   }
+
+   public Collection<Class<?>> getBeanClasses()
+   {
+      return archive.getClasses();
+   }
+
+   public Collection<URL> getBeansXml()
+   {
+      return archive.getXmlURLs();
+   }
+
+   public Collection<EjbDescriptor<?>> getEjbs()
+   {
+      return archive.getEjbs();
+   }
+
+   public ServiceRegistry getServices()
+   {
+      return services;
+   }
+
+   public String getId()
+   {
+      return id;
+   }
+
+   /**
+    * Returns the archive that this BDA represents.
+    * 
+    * @return the archive
+    */
+   public Archive getArchive()
+   {
+      return archive;
+   }
+   
+   public String toString()
+   {
+      return archive.toString();
+   }
+}
\ No newline at end of file

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Classpath.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Classpath.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Classpath.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,76 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-
-/**
- * An archive classpath keeps track of the archives that are visible to an archive.
- * It also works on BDA level, i.e., it can tell which BDAs are visible to a specific BDA.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- */
-public interface Classpath extends Iterable<Archive>
-{
-   /**
-    * Returns a name that identifies this classpath.
-    * 
-    * @return the name of this classpath
-    */
-   public String getName();
-
-   /**
-    * Adds an archive to this classpath. When an archive is added to a classpath, the
-    * corresponding BeanDeploymentArchive, when available, is automatically part of this
-    * classpath as well.
-    * 
-    * @param archive an archive
-    */
-   public void addArchive(Archive archive);
-
-   /**
-    * Returns an iterator over the set of archives contained in this classpath. 
-    * 
-    * @return an iterator for iterating over all archives that are part of this classpath
-    */
-   Iterator<Archive> iterator();
-   
-   /**
-    * Returns the parent classpath of this classpath.
-    * 
-    * @return the parent classpath of this classpath 
-    */
-   Classpath getClasspath();
-
-   /**
-    * Returns the collection of all BeanDeploymentArchive instances reachable from 
-    * {@code bda}.
-    * 
-    * @param bda the BeanDeploymentArchive that is performing this query
-    * @return    a collection of all BDAs visible to {@code bda}
-    */
-   public Collection<BeanDeploymentArchive> getBDAs(BeanDeploymentArchive bda);
-}

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Classpath.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Classpath.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Classpath.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Classpath.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,76 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+
+/**
+ * An archive classpath keeps track of the archives that are visible to an archive.
+ * It also works on BDA level, i.e., it can tell which BDAs are visible to a specific BDA.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public interface Classpath extends Iterable<Archive>
+{
+   /**
+    * Returns a name that identifies this classpath.
+    * 
+    * @return the name of this classpath
+    */
+   public String getName();
+
+   /**
+    * Adds an archive to this classpath. When an archive is added to a classpath, the
+    * corresponding BeanDeploymentArchive, when available, is automatically part of this
+    * classpath as well.
+    * 
+    * @param archive an archive
+    */
+   public void addArchive(Archive archive);
+
+   /**
+    * Returns an iterator over the set of archives contained in this classpath. 
+    * 
+    * @return an iterator for iterating over all archives that are part of this classpath
+    */
+   Iterator<Archive> iterator();
+   
+   /**
+    * Returns the parent classpath of this classpath.
+    * 
+    * @return the parent classpath of this classpath 
+    */
+   Classpath getClasspath();
+
+   /**
+    * Returns the collection of all BeanDeploymentArchive instances reachable from 
+    * {@code bda}.
+    * 
+    * @param bda the BeanDeploymentArchive that is performing this query
+    * @return    a collection of all BDAs visible to {@code bda}
+    */
+   public Collection<BeanDeploymentArchive> getBDAs(BeanDeploymentArchive bda);
+}

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathFactory.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathFactory.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathFactory.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,151 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.lang.ref.WeakReference;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.Loader;
-import org.jboss.classloading.spi.dependency.Module;
-
-/**
- * Given the ClassLoader that is loading an archive during deployment, this factory
- * creates the corresponding classpath.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- */
-class ClasspathFactory
-{
-   private static final ClasspathFactory instance = new ClasspathFactory();
-   
-   /**
-    * Returns the singleton instance.
-    * 
-    * @return the ClasspathFactory instance
-    */
-   public static final ClasspathFactory getInstance()
-   {
-      return instance;
-   }
-   
-   // the default classpath, corresponds to DefaultDomain
-   public static final Classpath DEFAULT = new  ClasspathImpl("DefaultDomain");
-   
-   private static final ClassLoaderDomain DEFAULT_DOMAIN = ClassLoaderSystem.getInstance().getDefaultDomain();
-   
-   // the ClassLoaderSystem
-   private final ClassLoaderSystem system;
-
-   // a list of domains
-   private final Map<Loader, WeakReference<Classpath>> domainToClasspath;
-
-   private ClasspathFactory()
-   {
-      domainToClasspath = new WeakHashMap<Loader, WeakReference<Classpath>>();
-      system = ClassLoaderSystem.getInstance();
-   }
-
-   /**
-    * Creates the Classpath corresponding to ClassLoader.
-    * 
-    * @param classLoader the ClassLoader
-    * @return            a classpath that contains a list of the archives visible to
-    *                    ClassLoader.
-    */
-   public Classpath create(ClassLoader classLoader)
-   {
-      Module module = SecurityActions.getModuleForClassLoader(classLoader);
-      ClassLoaderDomain domain = null;
-      if (module != null && module.getDeterminedParentDomainName() != null)
-      {
-         domain = system.getDomain(module.getDeterminedDomainName());
-      }
-      return getClasspath(classLoader, domain);
-   }
-   
-   // FIXME: remove classLoader parameter!
-   private Classpath getClasspath(ClassLoader cl, Loader domain)
-   {
-      if (domain == null || domain == DEFAULT_DOMAIN)
-      {
-         return DEFAULT;
-      }
-      synchronized(domain)
-      {
-         Classpath classpath = getClasspath(domain);
-         if (classpath == null)
-         {
-            if (domain instanceof ClassLoaderToLoaderAdapter)
-            {
-               ClassLoaderToLoaderAdapter cl2la = (ClassLoaderToLoaderAdapter) domain;
-               ClassLoader unitLoader = SecurityActions.getClassLoader(cl2la);
-               ArchiveInfo archiveInfo = unitLoader == null? null: ArchiveInfo.getInstance(unitLoader);
-               if (archiveInfo == null)
-               {
-                  classpath = new ClasspathImpl(domain.toString());
-               }
-               else
-               {
-                  classpath = archiveInfo.getClasspathAdapter();
-               }
-            }
-            else
-            {
-               if (domain instanceof ClassLoaderDomain)
-               {
-                  ClassLoaderDomain clDomain = (ClassLoaderDomain) domain;
-                  Classpath parentClasspath = getClasspath(null, clDomain.getParent());
-                  classpath = new ClasspathImpl(clDomain.getName(), parentClasspath);
-               }
-               else
-               {
-                  throw new RuntimeException("Domain is of unexpected type: " + domain + " - " + domain.getClass());
-               }
-            }
-            addClasspath(domain, classpath);
-         }
-         return classpath;
-      }
-   }
-
-   // FIXME: getCachedClassPath
-   private Classpath getClasspath(Loader domain)
-   {
-      WeakReference<Classpath> ref = domainToClasspath.get(domain);
-      if (ref == null)
-      {
-         return null;
-      }
-      return ref.get();
-   }
-   
-   // FIXME addClasspathToCache
-   private void addClasspath(Loader domain, Classpath domainClasspath)
-   {
-      domainToClasspath.put(domain, new WeakReference<Classpath>(domainClasspath));
-   }
-}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathFactory.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathFactory.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathFactory.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathFactory.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,151 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.lang.ref.WeakReference;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.jboss.classloader.plugins.loader.ClassLoaderToLoaderAdapter;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloader.spi.Loader;
+import org.jboss.classloading.spi.dependency.Module;
+
+/**
+ * Given the ClassLoader that is loading an archive during deployment, this factory
+ * creates the corresponding classpath.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class ClasspathFactory
+{
+   private static final ClasspathFactory instance = new ClasspathFactory();
+   
+   /**
+    * Returns the singleton instance.
+    * 
+    * @return the ClasspathFactory instance
+    */
+   public static final ClasspathFactory getInstance()
+   {
+      return instance;
+   }
+   
+   // the default classpath, corresponds to DefaultDomain
+   public static final Classpath DEFAULT = new  ClasspathImpl("DefaultDomain");
+   
+   private static final ClassLoaderDomain DEFAULT_DOMAIN = ClassLoaderSystem.getInstance().getDefaultDomain();
+   
+   // the ClassLoaderSystem
+   private final ClassLoaderSystem system;
+
+   // a list of domains
+   private final Map<Loader, WeakReference<Classpath>> domainToClasspath;
+
+   private ClasspathFactory()
+   {
+      domainToClasspath = new WeakHashMap<Loader, WeakReference<Classpath>>();
+      system = ClassLoaderSystem.getInstance();
+   }
+
+   /**
+    * Creates the Classpath corresponding to ClassLoader.
+    * 
+    * @param classLoader the ClassLoader
+    * @return            a classpath that contains a list of the archives visible to
+    *                    ClassLoader.
+    */
+   public Classpath create(ClassLoader classLoader)
+   {
+      Module module = SecurityActions.getModuleForClassLoader(classLoader);
+      ClassLoaderDomain domain = null;
+      if (module != null && module.getDeterminedParentDomainName() != null)
+      {
+         domain = system.getDomain(module.getDeterminedDomainName());
+      }
+      return getClasspath(classLoader, domain);
+   }
+   
+   // FIXME: remove classLoader parameter!
+   private Classpath getClasspath(ClassLoader cl, Loader domain)
+   {
+      if (domain == null || domain == DEFAULT_DOMAIN)
+      {
+         return DEFAULT;
+      }
+      synchronized(domain)
+      {
+         Classpath classpath = getClasspath(domain);
+         if (classpath == null)
+         {
+            if (domain instanceof ClassLoaderToLoaderAdapter)
+            {
+               ClassLoaderToLoaderAdapter cl2la = (ClassLoaderToLoaderAdapter) domain;
+               ClassLoader unitLoader = SecurityActions.getClassLoader(cl2la);
+               ArchiveInfo archiveInfo = unitLoader == null? null: ArchiveInfo.getInstance(unitLoader);
+               if (archiveInfo == null)
+               {
+                  classpath = new ClasspathImpl(domain.toString());
+               }
+               else
+               {
+                  classpath = archiveInfo.getClasspathAdapter();
+               }
+            }
+            else
+            {
+               if (domain instanceof ClassLoaderDomain)
+               {
+                  ClassLoaderDomain clDomain = (ClassLoaderDomain) domain;
+                  Classpath parentClasspath = getClasspath(null, clDomain.getParent());
+                  classpath = new ClasspathImpl(clDomain.getName(), parentClasspath);
+               }
+               else
+               {
+                  throw new RuntimeException("Domain is of unexpected type: " + domain + " - " + domain.getClass());
+               }
+            }
+            addClasspath(domain, classpath);
+         }
+         return classpath;
+      }
+   }
+
+   // FIXME: getCachedClassPath
+   private Classpath getClasspath(Loader domain)
+   {
+      WeakReference<Classpath> ref = domainToClasspath.get(domain);
+      if (ref == null)
+      {
+         return null;
+      }
+      return ref.get();
+   }
+   
+   // FIXME addClasspathToCache
+   private void addClasspath(Loader domain, Classpath domainClasspath)
+   {
+      domainToClasspath.put(domain, new WeakReference<Classpath>(domainClasspath));
+   }
+}
\ No newline at end of file

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathImpl.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathImpl.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathImpl.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,139 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-
-/**
- * Naïve implementation of Classpath. This implementation retrieves the
- * BeanDeploymentArchives from the contained archives whenever the BDA collection is
- * requested, and allows for duplicates in the collection.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- */
-class ClasspathImpl implements Classpath, ArchiveLifecycleListener
-{
-   private Collection<Archive> archives = new ArrayList<Archive>();
-   private Classpath classpath;
-   private final String name;
-   
-   /**
-    * Constructor.
-    * 
-    * @param name     the name of this classpath
-    * @param archives the list of archives contained in this classpath
-    */
-   public ClasspathImpl (String name, Archive... archives)
-   {
-      this.name = name;
-      for (Archive archive: archives)
-      {
-         this.archives.add(archive);
-      }
-   }
-   
-   /**
-    * Constructor.
-    * 
-    * @param name      the name of this classpath
-    * @param classpath contain archives that are reachable from this classpath
-    * @param archives the list of archives contained in this classpath
-    */
-   public ClasspathImpl (String name, Classpath classpath, Archive... archives)
-   {
-      this(name, archives);
-      this.classpath = classpath;
-   }
-   
-   public String getName()
-   {
-      return this.name;
-   }
-
-   public void addArchive(Archive archive)
-   {
-      archives.add(archive);
-      archive.addLifecycleListener(this);
-   }
-
-   public Iterator<Archive> iterator()
-   {
-      return archives.iterator();
-   }
-   
-   public Classpath getClasspath()
-   {
-      return this.classpath;
-   }
-
-   public Collection<BeanDeploymentArchive> getBDAs(BeanDeploymentArchive bda)
-   {
-      if (archives.isEmpty() && classpath != null)
-      {
-         return classpath.getBDAs(bda);
-      }
-      Collection<BeanDeploymentArchive> bdas = getBDAsFromArchives();
-      if (bdas.isEmpty() && classpath != null)
-      {
-         return classpath.getBDAs(bda);
-      }
-      if (classpath != null)
-      {
-         bdas.addAll(classpath.getBDAs(bda));
-      }
-      return bdas;
-   }
-
-   public String toString()
-   {
-      return "Classpath[" + name + "]";
-   }
-
-   private Collection<BeanDeploymentArchive> getBDAsFromArchives()
-   {
-      Collection<BeanDeploymentArchive> bdas = new ArrayList<BeanDeploymentArchive>();
-      for (Archive archive: archives)
-      {
-         BeanDeploymentArchive bda = archive.getBeanDeploymentArchive();
-         if (bda != null)
-         {
-            bdas.add(bda);
-         }
-      }
-      return bdas;
-   }
-
-   public void archiveVisible(Archive archive, BeanDeploymentArchive bda)
-   {
-      // do nothing, as this classpath impl doesn't keep track of bdas created
-   }
-
-   public void archiveDestroyed(Archive archive)
-   {
-      archives.remove(archive);
-   }
-}

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathImpl.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathImpl.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathImpl.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ClasspathImpl.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,139 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+
+/**
+ * Naïve implementation of Classpath. This implementation retrieves the
+ * BeanDeploymentArchives from the contained archives whenever the BDA collection is
+ * requested, and allows for duplicates in the collection.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class ClasspathImpl implements Classpath, ArchiveLifecycleListener
+{
+   private Collection<Archive> archives = new ArrayList<Archive>();
+   private Classpath classpath;
+   private final String name;
+   
+   /**
+    * Constructor.
+    * 
+    * @param name     the name of this classpath
+    * @param archives the list of archives contained in this classpath
+    */
+   public ClasspathImpl (String name, Archive... archives)
+   {
+      this.name = name;
+      for (Archive archive: archives)
+      {
+         this.archives.add(archive);
+      }
+   }
+   
+   /**
+    * Constructor.
+    * 
+    * @param name      the name of this classpath
+    * @param classpath contain archives that are reachable from this classpath
+    * @param archives the list of archives contained in this classpath
+    */
+   public ClasspathImpl (String name, Classpath classpath, Archive... archives)
+   {
+      this(name, archives);
+      this.classpath = classpath;
+   }
+   
+   public String getName()
+   {
+      return this.name;
+   }
+
+   public void addArchive(Archive archive)
+   {
+      archives.add(archive);
+      archive.addLifecycleListener(this);
+   }
+
+   public Iterator<Archive> iterator()
+   {
+      return archives.iterator();
+   }
+   
+   public Classpath getClasspath()
+   {
+      return this.classpath;
+   }
+
+   public Collection<BeanDeploymentArchive> getBDAs(BeanDeploymentArchive bda)
+   {
+      if (archives.isEmpty() && classpath != null)
+      {
+         return classpath.getBDAs(bda);
+      }
+      Collection<BeanDeploymentArchive> bdas = getBDAsFromArchives();
+      if (bdas.isEmpty() && classpath != null)
+      {
+         return classpath.getBDAs(bda);
+      }
+      if (classpath != null)
+      {
+         bdas.addAll(classpath.getBDAs(bda));
+      }
+      return bdas;
+   }
+
+   public String toString()
+   {
+      return "Classpath[" + name + "]";
+   }
+
+   private Collection<BeanDeploymentArchive> getBDAsFromArchives()
+   {
+      Collection<BeanDeploymentArchive> bdas = new ArrayList<BeanDeploymentArchive>();
+      for (Archive archive: archives)
+      {
+         BeanDeploymentArchive bda = archive.getBeanDeploymentArchive();
+         if (bda != null)
+         {
+            bdas.add(bda);
+         }
+      }
+      return bdas;
+   }
+
+   public void archiveVisible(Archive archive, BeanDeploymentArchive bda)
+   {
+      // do nothing, as this classpath impl doesn't keep track of bdas created
+   }
+
+   public void archiveDestroyed(Archive archive)
+   {
+      archives.remove(archive);
+   }
+}

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,193 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.jboss.weld.bootstrap.api.ServiceRegistry;
-import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.bootstrap.spi.Deployment;
-import org.jboss.weld.ejb.spi.EjbDescriptor;
-
-/**
- * {@link Deployment} implementation for JBoss AS.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- */
-public class DeploymentImpl implements Deployment
-{
-   // the name of this deployment
-   private String name;
-
-   // the collection of archives contained in this deployment 
-   private final ArchiveCollection archives;
-
-   // the services provided by this deployment
-   private final ServiceRegistry services;
-
-   // a collection of all archives that have been loaded by this DeploymentImpl, i.e.
-   // created for the purpose of serving loadBeanDeploymentArchive
-   private Collection<Archive> loadedArchives;
-
-   /**
-    * Constructor.
-    * 
-    * @param name         a name that identifies this deployment
-    * @param archiveInfos the information that will be used for creation of the archives
-    *                     contained in this deployment
-    * @param ejbs         the ejb descriptors
-    */
-   public DeploymentImpl(String name, Collection<ArchiveInfo> archiveInfos, Collection<EjbDescriptor<?>> ejbs)
-   {
-      this.name = name;
-      this.archives = new ArchiveCollection();
-      for (ArchiveInfo archiveInfo: archiveInfos)
-      {
-         Archive archive = ArchiveFactory.createArchive(archiveInfo, ejbs);
-         archives.add(archive);
-         if (archive.hasXml())
-         {
-            archive.createBeanDeploymentArchive();
-         }
-      }
-      this.services = new SimpleServiceRegistry();
-   }
-   
-   public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
-   {
-      return archives.getBDAs();
-   }
-
-   public ServiceRegistry getServices()
-   {
-     return this.services;
-   }
-
-   public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
-   {
-      // collection to mark the archives we have already searched
-      Collection<Archive> searchedArchives = new HashSet<Archive>();
-      // collection to mark the classpaths we have already searched
-      Collection<Classpath> searchedClasspaths = new HashSet<Classpath>();
-      // TODO -- why the search? beanClass' ClassLoader should be mapped to Archive?
-      // need to throw an IllegalArgumentException if the Archive is not reachable from
-      // the archives contained in the archives of this deployment
-      Archive archive = findArchive(beanClass, archives, searchedArchives, searchedClasspaths);
-      if (archive == null)
-      {
-         boolean reachable = false;
-         for (Archive searchedArchive: searchedArchives)
-         {
-            if (searchedArchive.isClassVisible(beanClass))
-            {
-               reachable = true;
-               break;
-            }
-         }
-         if (!reachable)
-            throw new IllegalArgumentException("Bean class " + beanClass + " is not reachable from deployment " + this);
-         ArchiveInfo archiveInfo = new ArchiveInfo(SecurityActions.getClassLoader(beanClass));
-         archive = ArchiveFactory.createArchive(archiveInfo, new ArrayList<EjbDescriptor<?>>());
-         if (loadedArchives == null)
-         {
-            loadedArchives = new ArrayList<Archive>();
-         }
-         loadedArchives.add(archive);
-      }
-      archive.addClass(beanClass);
-      return archive.createBeanDeploymentArchive();
-   }
-   
-   public void undeploy()
-   {
-      for(Iterator<Archive> iterator = archives.iterator(); iterator.hasNext(); )
-      {
-         Archive archive = iterator.next();
-         iterator.remove();
-         archive.undeploy();
-      }
-      if (loadedArchives != null)
-      {
-         for (Archive archive: loadedArchives)
-         {
-            // FIXME this does not work ok
-            archive.undeploy();
-         }
-      }
-   }
-   
-   public String toString()
-   {
-      return "Deployment[" + name + "]";
-   }
-   
-   private Archive findArchive(Class<?> beanClass, Iterable<Archive> archives, Collection<Archive> searchedArchives, Collection<Classpath> searchedClasspaths)
-   {
-      synchronized(archives) // TODO potential for a deadlock?
-      {
-         for (Archive archive: archives)
-         {
-            if (!searchedArchives.contains(archive))
-            {
-               if (archive.containsClass(beanClass))
-               {
-                  return archive;
-               }
-               else
-               {
-                  searchedArchives.add(archive);
-                  Archive found = searchThroughClasspath(archive.getClasspath(), beanClass, searchedArchives, searchedClasspaths);
-                  if (found != null)
-                  {
-                     return found;
-                  }
-               }
-            }
-         }
-      }
-      return null;
-   }
-   
-   private Archive searchThroughClasspath(Classpath classpath, Class<?> beanClass, Collection<Archive> searchedArchives, Collection<Classpath> searchedClasspaths)
-   {
-      if (!searchedClasspaths.contains(classpath))
-      {
-         searchedClasspaths.add(classpath);
-         Archive found = findArchive(beanClass, classpath, searchedArchives, searchedClasspaths);
-         if (found != null)
-         {
-            return found;
-         }
-         Classpath parentClasspath = classpath.getClasspath();
-         if (parentClasspath != null)
-         {
-            return searchThroughClasspath(classpath.getClasspath(), beanClass, searchedArchives, searchedClasspaths);
-         }
-      }
-      return null;
-   }
-}

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,193 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+
+/**
+ * {@link Deployment} implementation for JBoss AS.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class DeploymentImpl implements Deployment
+{
+   // the name of this deployment
+   private String name;
+
+   // the collection of archives contained in this deployment 
+   private final ArchiveCollection archives;
+
+   // the services provided by this deployment
+   private final ServiceRegistry services;
+
+   // a collection of all archives that have been loaded by this DeploymentImpl, i.e.
+   // created for the purpose of serving loadBeanDeploymentArchive
+   private Collection<Archive> loadedArchives;
+
+   /**
+    * Constructor.
+    * 
+    * @param name         a name that identifies this deployment
+    * @param archiveInfos the information that will be used for creation of the archives
+    *                     contained in this deployment
+    * @param ejbs         the ejb descriptors
+    */
+   public DeploymentImpl(String name, Collection<ArchiveInfo> archiveInfos, Collection<EjbDescriptor<?>> ejbs)
+   {
+      this.name = name;
+      this.archives = new ArchiveCollection();
+      for (ArchiveInfo archiveInfo: archiveInfos)
+      {
+         Archive archive = ArchiveFactory.createArchive(archiveInfo, ejbs);
+         archives.add(archive);
+         if (archive.hasXml())
+         {
+            archive.createBeanDeploymentArchive();
+         }
+      }
+      this.services = new SimpleServiceRegistry();
+   }
+   
+   public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
+   {
+      return archives.getBDAs();
+   }
+
+   public ServiceRegistry getServices()
+   {
+     return this.services;
+   }
+
+   public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
+   {
+      // collection to mark the archives we have already searched
+      Collection<Archive> searchedArchives = new HashSet<Archive>();
+      // collection to mark the classpaths we have already searched
+      Collection<Classpath> searchedClasspaths = new HashSet<Classpath>();
+      // TODO -- why the search? beanClass' ClassLoader should be mapped to Archive?
+      // need to throw an IllegalArgumentException if the Archive is not reachable from
+      // the archives contained in the archives of this deployment
+      Archive archive = findArchive(beanClass, archives, searchedArchives, searchedClasspaths);
+      if (archive == null)
+      {
+         boolean reachable = false;
+         for (Archive searchedArchive: searchedArchives)
+         {
+            if (searchedArchive.isClassVisible(beanClass))
+            {
+               reachable = true;
+               break;
+            }
+         }
+         if (!reachable)
+            throw new IllegalArgumentException("Bean class " + beanClass + " is not reachable from deployment " + this);
+         ArchiveInfo archiveInfo = new ArchiveInfo(SecurityActions.getClassLoader(beanClass));
+         archive = ArchiveFactory.createArchive(archiveInfo, new ArrayList<EjbDescriptor<?>>());
+         if (loadedArchives == null)
+         {
+            loadedArchives = new ArrayList<Archive>();
+         }
+         loadedArchives.add(archive);
+      }
+      archive.addClass(beanClass);
+      return archive.createBeanDeploymentArchive();
+   }
+   
+   public void undeploy()
+   {
+      for(Iterator<Archive> iterator = archives.iterator(); iterator.hasNext(); )
+      {
+         Archive archive = iterator.next();
+         iterator.remove();
+         archive.undeploy();
+      }
+      if (loadedArchives != null)
+      {
+         for (Archive archive: loadedArchives)
+         {
+            // FIXME this does not work ok
+            archive.undeploy();
+         }
+      }
+   }
+   
+   public String toString()
+   {
+      return "Deployment[" + name + "]";
+   }
+   
+   private Archive findArchive(Class<?> beanClass, Iterable<Archive> archives, Collection<Archive> searchedArchives, Collection<Classpath> searchedClasspaths)
+   {
+      synchronized(archives) // TODO potential for a deadlock?
+      {
+         for (Archive archive: archives)
+         {
+            if (!searchedArchives.contains(archive))
+            {
+               if (archive.containsClass(beanClass))
+               {
+                  return archive;
+               }
+               else
+               {
+                  searchedArchives.add(archive);
+                  Archive found = searchThroughClasspath(archive.getClasspath(), beanClass, searchedArchives, searchedClasspaths);
+                  if (found != null)
+                  {
+                     return found;
+                  }
+               }
+            }
+         }
+      }
+      return null;
+   }
+   
+   private Archive searchThroughClasspath(Classpath classpath, Class<?> beanClass, Collection<Archive> searchedArchives, Collection<Classpath> searchedClasspaths)
+   {
+      if (!searchedClasspaths.contains(classpath))
+      {
+         searchedClasspaths.add(classpath);
+         Archive found = findArchive(beanClass, classpath, searchedArchives, searchedClasspaths);
+         if (found != null)
+         {
+            return found;
+         }
+         Classpath parentClasspath = classpath.getClasspath();
+         if (parentClasspath != null)
+         {
+            return searchThroughClasspath(classpath.getClasspath(), beanClass, searchedArchives, searchedClasspaths);
+         }
+      }
+      return null;
+   }
+}

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/NoDuplicatesClasspath.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/NoDuplicatesClasspath.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/NoDuplicatesClasspath.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,170 +0,0 @@
-/*
- * 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.weld.integration.deployer.env.bda;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-
-/**
- * Classpath implementation that avoids duplication and keeps an updated list of
- * BeanDeploymentArchives, thus avoiding the creation of this list every time it is
- * retrieved.
- * 
- * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- */
-class NoDuplicatesClasspath extends ArchiveCollection implements Classpath 
-{
-   // the classpath name
-   private final String name;
-
-   // A reference to this classpath. This reference BDA is returned as the single element
-   // in the BDA collection every time it is requested by the non-reference BDAs
-   private BeanDeploymentArchive reference = null;
-
-   // A collection containing the reference BDA
-   private Collection<BeanDeploymentArchive> referenceCollection = new ArrayList<BeanDeploymentArchive>();
-
-   // contains archives and BDAs reachable from this Classpath
-   private Classpath classpath;
-
-   /**
-    * Constructor.
-    * 
-    * @param name     a name that identifies this classpath
-    * @param archives the list of archives contained in this classpath
-    */
-   public NoDuplicatesClasspath (String name, Archive... archives)
-   {
-      this.name = name;
-      super.archives = new HashSet<Archive>();
-      for (Archive archive: archives)
-      {
-         add(archive);
-      }
-   }
-
-   /**
-    * Constructor.
-    * 
-    * @param name     a name that identifies this classpath
-    * @param archives the list of archives contained in this classpath
-    */
-   public NoDuplicatesClasspath (String name, Classpath classpath, Archive... archives)
-   {
-      this(name, archives);
-      this.classpath = classpath;
-   }
-
-   public String getName()
-   {
-      return this.name;
-   }
-
-   public void addArchive(Archive archive)
-   {
-      add(archive);
-   }
-
-   public Classpath getClasspath()
-   {
-      return this.classpath;
-   }
-
-   public Collection<BeanDeploymentArchive> getBDAs(BeanDeploymentArchive bda)
-   {
-      // if reference is null, it means that no BDA is contained in this classpath
-      if (reference == null && classpath != null)
-      {
-         return classpath.getBDAs(bda);
-      }
-      // only the reference BDA points to the other BDAs in this classpath
-      if (bda == reference)
-      {
-         return getBDAs();
-      }
-      else
-      {
-         // all other BDAs point only to reference BDA
-         return referenceCollection;
-      }
-   }
-
-   @Override
-   public void archiveVisible(Archive archive, BeanDeploymentArchive bda)
-   {
-      synchronized(bdas)
-      {
-         if (reference == null)
-         {
-            reference = bda;
-            referenceCollection.add(bda);
-         }
-         else
-         {
-            //only add to BDAs collection the BDAs that are not reference
-            super.archiveVisible(archive, bda);
-         }
-      }
-   }
-   
-   @Override
-   public void archiveDestroyed(Archive archive)
-   {
-      BeanDeploymentArchive bda = archive.getBeanDeploymentArchive();
-      if (bda != null)
-      {
-         synchronized(bdas)
-         {
-            if (reference == bda)
-            {
-               reference = null;
-               referenceCollection.clear();
-               if (!bdas.isEmpty())
-               {
-                  Iterator<BeanDeploymentArchive> iterator = bdas.iterator();
-                  reference = iterator.next();
-                  iterator.remove();
-                  referenceCollection.add(reference);
-               }
-            }
-            else
-            {
-               super.archiveDestroyed(archive);
-            }
-         }
-      }
-      synchronized(this)
-      {
-         archives.remove(archive);
-      }
-   }
-
-   public String toString()
-   {
-      return "Classpath[" + this.name + "]";
-   }
-}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/NoDuplicatesClasspath.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/NoDuplicatesClasspath.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/NoDuplicatesClasspath.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/NoDuplicatesClasspath.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,170 @@
+/*
+ * 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.weld.integration.deployer.env.bda;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+
+/**
+ * Classpath implementation that avoids duplication and keeps an updated list of
+ * BeanDeploymentArchives, thus avoiding the creation of this list every time it is
+ * retrieved.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class NoDuplicatesClasspath extends ArchiveCollection implements Classpath 
+{
+   // the classpath name
+   private final String name;
+
+   // A reference to this classpath. This reference BDA is returned as the single element
+   // in the BDA collection every time it is requested by the non-reference BDAs
+   private BeanDeploymentArchive reference = null;
+
+   // A collection containing the reference BDA
+   private Collection<BeanDeploymentArchive> referenceCollection = new ArrayList<BeanDeploymentArchive>();
+
+   // contains archives and BDAs reachable from this Classpath
+   private Classpath classpath;
+
+   /**
+    * Constructor.
+    * 
+    * @param name     a name that identifies this classpath
+    * @param archives the list of archives contained in this classpath
+    */
+   public NoDuplicatesClasspath (String name, Archive... archives)
+   {
+      this.name = name;
+      super.archives = new HashSet<Archive>();
+      for (Archive archive: archives)
+      {
+         add(archive);
+      }
+   }
+
+   /**
+    * Constructor.
+    * 
+    * @param name     a name that identifies this classpath
+    * @param archives the list of archives contained in this classpath
+    */
+   public NoDuplicatesClasspath (String name, Classpath classpath, Archive... archives)
+   {
+      this(name, archives);
+      this.classpath = classpath;
+   }
+
+   public String getName()
+   {
+      return this.name;
+   }
+
+   public void addArchive(Archive archive)
+   {
+      add(archive);
+   }
+
+   public Classpath getClasspath()
+   {
+      return this.classpath;
+   }
+
+   public Collection<BeanDeploymentArchive> getBDAs(BeanDeploymentArchive bda)
+   {
+      // if reference is null, it means that no BDA is contained in this classpath
+      if (reference == null && classpath != null)
+      {
+         return classpath.getBDAs(bda);
+      }
+      // only the reference BDA points to the other BDAs in this classpath
+      if (bda == reference)
+      {
+         return getBDAs();
+      }
+      else
+      {
+         // all other BDAs point only to reference BDA
+         return referenceCollection;
+      }
+   }
+
+   @Override
+   public void archiveVisible(Archive archive, BeanDeploymentArchive bda)
+   {
+      synchronized(bdas)
+      {
+         if (reference == null)
+         {
+            reference = bda;
+            referenceCollection.add(bda);
+         }
+         else
+         {
+            //only add to BDAs collection the BDAs that are not reference
+            super.archiveVisible(archive, bda);
+         }
+      }
+   }
+   
+   @Override
+   public void archiveDestroyed(Archive archive)
+   {
+      BeanDeploymentArchive bda = archive.getBeanDeploymentArchive();
+      if (bda != null)
+      {
+         synchronized(bdas)
+         {
+            if (reference == bda)
+            {
+               reference = null;
+               referenceCollection.clear();
+               if (!bdas.isEmpty())
+               {
+                  Iterator<BeanDeploymentArchive> iterator = bdas.iterator();
+                  reference = iterator.next();
+                  iterator.remove();
+                  referenceCollection.add(reference);
+               }
+            }
+            else
+            {
+               super.archiveDestroyed(archive);
+            }
+         }
+      }
+      synchronized(this)
+      {
+         archives.remove(archive);
+      }
+   }
+
+   public String toString()
+   {
+      return "Classpath[" + this.name + "]";
+   }
+}
\ No newline at end of file

Deleted: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java	2010-08-10 01:26:29 UTC (rev 107515)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,95 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.weld.integration.deployer.env.bda;
-
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-import org.jboss.classloader.spi.base.BaseClassLoaderSource;
-import org.jboss.classloading.spi.dependency.ClassLoading;
-import org.jboss.classloading.spi.dependency.Module;
-
-/**
- * Executes privileged actions.
- * 
- * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- */
-class SecurityActions
-{
-   private static final Method getClassLoader;
-
-   static
-   {
-      getClassLoader = AccessController.doPrivileged(new PrivilegedAction<Method>()
-      {
-         public Method run()
-         {
-            try
-            {
-               Method method = BaseClassLoaderSource.class.getDeclaredMethod("getClassLoader");
-               method.setAccessible(true);
-               return method;
-            }
-            catch (NoSuchMethodException e)
-            {
-               throw new RuntimeException("Cannot get classloader from " + BaseClassLoaderSource.class.getName(), e);
-            }
-         }
-      });
-   }
-
-   static ClassLoader getClassLoader(BaseClassLoaderSource clSource)
-   {
-      try
-      {
-         return (ClassLoader)getClassLoader.invoke(clSource);
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   public static ClassLoader getClassLoader(final Class<?> clazz)
-   {
-      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
-      {
-         public ClassLoader run()
-         {
-            return clazz.getClassLoader();
-         }
-      });
-   }
-   
-   public static Module getModuleForClassLoader(final ClassLoader classLoader)
-   {
-      return AccessController.doPrivileged(new PrivilegedAction<Module>()
-      {
-         public Module run()
-         {
-            return ClassLoading.getModuleForClassLoader(classLoader);
-         }
-      });
-   }
-}

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java (from rev 107515, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/SecurityActions.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.weld.integration.deployer.env.bda;
+
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.jboss.classloader.spi.base.BaseClassLoaderSource;
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.dependency.Module;
+
+/**
+ * Executes privileged actions.
+ * 
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class SecurityActions
+{
+   private static final Method getClassLoader;
+
+   static
+   {
+      getClassLoader = AccessController.doPrivileged(new PrivilegedAction<Method>()
+      {
+         public Method run()
+         {
+            try
+            {
+               Method method = BaseClassLoaderSource.class.getDeclaredMethod("getClassLoader");
+               method.setAccessible(true);
+               return method;
+            }
+            catch (NoSuchMethodException e)
+            {
+               throw new RuntimeException("Cannot get classloader from " + BaseClassLoaderSource.class.getName(), e);
+            }
+         }
+      });
+   }
+
+   static ClassLoader getClassLoader(BaseClassLoaderSource clSource)
+   {
+      try
+      {
+         return (ClassLoader)getClassLoader.invoke(clSource);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public static ClassLoader getClassLoader(final Class<?> clazz)
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+      {
+         public ClassLoader run()
+         {
+            return clazz.getClassLoader();
+         }
+      });
+   }
+   
+   public static Module getModuleForClassLoader(final ClassLoader classLoader)
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<Module>()
+      {
+         public Module run()
+         {
+            return ClassLoading.getModuleForClassLoader(classLoader);
+         }
+      });
+   }
+}

Modified: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/injection/NonContextualObjectInjectionHelper.java
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/injection/NonContextualObjectInjectionHelper.java	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/injection/NonContextualObjectInjectionHelper.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -1,9 +1,10 @@
 package org.jboss.weld.integration.injection;
 
 import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.BeanManager;
 import javax.enterprise.inject.spi.InjectionTarget;
 
+import org.jboss.weld.manager.api.WeldManager;
+
 /**
  * Helper class for injecting Web Beans into non-contextual objects
  *
@@ -12,13 +13,13 @@
 public class NonContextualObjectInjectionHelper
 {
    @SuppressWarnings("unchecked")
-   public static void injectNonContextualInstance(Object instance, BeanManager beanManager)
+   public static void injectNonContextualInstance(Object instance, WeldManager beanManager)
    {
       if (beanManager == null)
          throw new IllegalArgumentException("Null bean manager.");
 
       CreationalContext<Object> creationalContext =  beanManager.createCreationalContext(null);
-      InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>) beanManager.createInjectionTarget(beanManager.createAnnotatedType(instance.getClass()));
+      InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>) beanManager.fireProcessInjectionTarget(beanManager.createAnnotatedType(instance.getClass()));
       injectionTarget.inject(instance, creationalContext);
    }
 }
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/MockArchiveManifest.java (from rev 107515, trunk/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/MockArchiveManifest.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/MockArchiveManifest.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/support/MockArchiveManifest.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,107 @@
+/*
+ * 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.test.deployers.support;
+
+import java.util.Map;
+
+import org.jboss.shrinkwrap.api.ArchivePath;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Filter;
+import org.jboss.shrinkwrap.api.Node;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+
+/**
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+public class MockArchiveManifest
+{
+   private static Filter<ArchivePath> EAR_MODULE_FILTER = new Filter<ArchivePath>(){
+
+      public boolean include(ArchivePath pathObject)
+      {
+         String path = pathObject.get();
+         // ear modules are not "/" and don't belong to /lib
+         return path.length() > 1 && !path.startsWith("/lib");
+      }
+   };
+   
+   public static void addCDIManifest(JavaArchive archive)
+   {
+      archive.addManifestResource(new ByteArrayAsset("<web-beans></web-beans>".getBytes()), 
+               ArchivePaths.create("beans.xml"));
+   }
+   
+   public static void addCDIManifest(WebArchive archive)
+   {
+      archive.add(new ByteArrayAsset("<beans/>".getBytes()), 
+               ArchivePaths.create("WEB-INF/beans.xml"));
+   }
+   
+   public static void addManifest(JavaArchive archive)
+   {
+      archive.addManifestResource(new ByteArrayAsset("<ejb-jar/>".getBytes()), 
+               ArchivePaths.create("ejb-jar.xml"));
+   }
+   
+   public static void addManifest(JavaArchive archive, boolean isCDI)
+   {
+      addManifest(archive);
+      if (isCDI)
+      {
+         addCDIManifest(archive);
+      }
+   }
+   
+   public static void addManifest(WebArchive archive)
+   {
+      archive.add(new ByteArrayAsset("<web/>".getBytes()), ArchivePaths.create("WEB-INF/web.xml"));
+   }
+
+   public static void addManifest(WebArchive archive, boolean isCDI)
+   {
+      addManifest(archive);
+      if (isCDI)
+      {
+         addCDIManifest(archive);
+      }
+   }
+   
+   public static void addManifest(EnterpriseArchive archive)
+   {
+      Map<ArchivePath, Node> modules = archive.getContent(EAR_MODULE_FILTER);
+      StringBuffer appProperties = new StringBuffer();
+      for(ArchivePath archivePath: modules.keySet())
+      {
+         // remove leading '/' char
+         String path = archivePath.get().substring(1);
+         appProperties.append(path.replace('.', '_')).append("-module=").append(path);
+         appProperties.append('\n');
+      }
+      archive.addManifestResource(new ByteArrayAsset(appProperties.toString().getBytes()),
+               "application.properties");
+   }
+}

Modified: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractDeploymentTest.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -60,6 +60,10 @@
    {
       for (BeanDeploymentArchive bda : archives)
       {
+         if (result.contains(bda))
+         {
+            continue;
+         }
          result.add(bda);
          getArchives(result, bda.getBeanDeploymentArchives());
       }

Copied: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java (from rev 107515, trunk/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractEnvironmentTest.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,217 @@
+/*
+ * 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.test.deployers.test;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.container.LibraryContainer;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.test.deployers.support.MockArchiveManifest;
+import org.jboss.test.deployers.support.crm.CrmWebBean;
+import org.jboss.test.deployers.support.jar.PlainJavaBean;
+import org.jboss.test.deployers.support.ui.UIWebBean;
+import org.jboss.test.deployers.support.web.ServletWebBean;
+
+/**
+ * Abstract Environment test case.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @param E the type of environment this test applies to
+ */
+public abstract class AbstractEnvironmentTest<E> extends AbstractWeldTest
+{
+   protected static final String EAR_NAME = "simple.ear";
+   protected static final String EJB_JAR_NAME = "ejb.jar";
+   protected static final String WAR_NAME = "simple.war";
+   
+   public AbstractEnvironmentTest(String name)
+   {
+      super(name);
+   }
+
+   private static void addExpectedResource(Set<String> expected, String unit)
+   {
+      addExpectedResource(expected, unit, "/META-INF/beans.xml");
+   }
+
+   private static void addExpectedResource(Set<String> expected, String unit, String suffix)
+   {
+      expected.add(unit + suffix);
+   }
+
+   private static void addExpectedClass(Set<String> expected, Class<?> clazz)
+   {
+      expected.add(clazz.getName());
+   }
+
+   private void assertExpectedClasses(E environment, Set<String> expected)
+   {
+      Collection<Class<?>> weldClasses = getClasses(environment);
+      assertNotNull(weldClasses);
+      assertTrue("Unexpected empty weld classes collection", expected.isEmpty() || !weldClasses.isEmpty());
+      for (Class<?> clazz : weldClasses)
+      {
+         assertTrue("Found unexpected class: " + clazz.getName(), expected.remove(clazz.getName()));
+      }
+      assertEmpty("Should be emtpy, missing " + expected, expected);
+   }
+
+   protected void assertExpectedClasses(E environment, Class<?>... classes)
+   {
+      Set<String> expected = new HashSet<String>();
+      for(Class<?> clazz: classes)
+      {
+         addExpectedClass(expected, clazz);
+      }
+      assertExpectedClasses(environment, expected);
+   }
+
+   private void assertExpectedResources(E environment, Set<String> expected)
+   {
+      Collection<URL> weldXml = getResources(environment);
+      assertNotNull(weldXml);
+      assertTrue("Unexpected empty weld XML collection", expected.isEmpty() || !weldXml.isEmpty());
+      for (URL url : weldXml)
+      {
+         boolean found = false;
+         Iterator<String> iter = expected.iterator();
+         while (iter.hasNext())
+         {
+            String expectedURL = iter.next();
+            if (url.toExternalForm().endsWith(expectedURL))
+            {
+               iter.remove();
+               found = true;
+               break;
+            }
+         }
+         assertTrue("Unexpected wb url: " + url, found);
+      }
+      assertEmpty("Should be emtpy, missing " + expected, expected);
+   }
+
+   protected void assertExpectedResources(E environment, String... units)
+   {
+      Set<String> expected = new HashSet<String>();
+      for (String unit: units)
+      {
+         addExpectedResource(expected, unit);
+      }
+      assertExpectedResources(environment, expected);
+   }
+
+   protected void assertExpectedWarResources(E environment, String warUnit, boolean warResourceExpected, String... units)
+   {
+      Set<String> expected = new HashSet<String>();
+      if (warResourceExpected)
+         addExpectedResource(expected, warUnit, "/WEB-INF/beans.xml");
+      for (String unit: units)
+      {
+         addExpectedResource(expected, warUnit, "/WEB-INF/lib/" + unit + "/META-INF/beans.xml");
+      }
+      assertExpectedResources(environment, expected);
+   }
+
+   protected JavaArchive createEjbJar(boolean jarCDI)
+   {
+      return createEjbJar(EJB_JAR_NAME, jarCDI, PlainJavaBean.class);
+   }
+   
+   protected JavaArchive createEjbJar(String jarName, boolean jarCDI, Class<?>... classes)
+   {
+      JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, jarName);
+      for (Class<?> clazz: classes)
+      {
+         ejbJar.addClass(clazz);
+      }
+      MockArchiveManifest.addManifest(ejbJar, jarCDI);
+      return ejbJar;
+   }
+
+   protected WebArchive createWar(boolean warCDI)
+   {
+      return createWar(WAR_NAME, warCDI, ServletWebBean.class);
+   }
+
+   protected WebArchive createWar(String warName, boolean warCDI, Class<?>... classes)
+   {
+      WebArchive war = ShrinkWrap.create(WebArchive.class, warName);
+      for (Class<?> clazz: classes)
+      {
+         war.addClass(clazz);
+      }
+      MockArchiveManifest.addManifest(war, warCDI);
+      return war;
+   }
+
+   protected WebArchive createWarWithLib(boolean warCDI, boolean libCDI)
+   {
+      WebArchive war = createWar(warCDI);
+      createLib(war, "lib.jar", libCDI, UIWebBean.class);
+      return war;
+   }
+
+   protected WebArchive createWarWithLibs(boolean warCDI, boolean lib1CDI, boolean lib2CDI)
+   {
+      WebArchive war = createWar(warCDI);
+      createLib(war, "lib1.jar", lib1CDI, UIWebBean.class);
+      createLib(war, "lib2.jar", lib2CDI, CrmWebBean.class);
+      return war;
+   }
+
+   protected void createLib(LibraryContainer<?> archive, String libName, boolean cdi, Class<?>... classes)
+   {
+      JavaArchive lib = ShrinkWrap.create(JavaArchive.class, libName);
+      if (cdi)
+      {
+         MockArchiveManifest.addCDIManifest(lib);
+      }
+      for (Class<?> libClass: classes)
+      {
+         lib.addClass(libClass);
+      }
+      archive.addLibrary(lib);
+   }
+
+   /**
+    * Returns the classes recorded in the environment.
+    * 
+    * @param environment the environment
+    * @return the list of classes that have been found in the environment
+    */
+   protected abstract Collection<Class<?>> getClasses(E environment);
+
+   /**
+    * Returns the Weld XML resources recorded in the environment.
+    * 
+    * @param environment the environment
+    * @return the list of URLs pointing to the Weld XML files that have been found in the
+    *         environment
+    */
+   protected abstract Collection<URL> getResources(E environment);
+}

Copied: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractSingleArchiveTest.java (from rev 107515, trunk/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractSingleArchiveTest.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractSingleArchiveTest.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractSingleArchiveTest.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,431 @@
+/*
+ * 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.test.deployers.test;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.test.deployers.support.MockArchiveManifest;
+import org.jboss.test.deployers.support.crm.CrmWebBean;
+import org.jboss.test.deployers.support.ejb.BusinessInterface;
+import org.jboss.test.deployers.support.ejb.MySLSBean;
+import org.jboss.test.deployers.support.ext.ExternalWebBean;
+import org.jboss.test.deployers.support.jar.PlainJavaBean;
+import org.jboss.test.deployers.support.jsf.NotWBJsfBean;
+import org.jboss.test.deployers.support.ui.UIWebBean;
+import org.jboss.test.deployers.support.util.SomeUtil;
+import org.jboss.test.deployers.support.web.ServletWebBean;
+import org.jboss.vfs.VirtualFile;
+
+/**
+ * Abstract test case that contains scenarios involving the deployment of a single archive.
+ * This test does not contain test scenarios that assert the behaviour when more than one
+ * archive is deployed at the same time.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @param E the type of environment this test applies to
+ */
+public abstract class AbstractSingleArchiveTest<E> extends AbstractEnvironmentTest<E>
+{
+   public AbstractSingleArchiveTest(String name)
+   {
+      super(name);
+   }
+
+   protected DeploymentUnit unit;
+
+   public void testEjbJar() throws Exception
+   {
+      JavaArchive ejbJar = createEjbJar(true);
+      unit = assertDeploy(ejbJar);
+
+      E environment = assertSingleEnvironment(EJB_JAR_NAME);
+      assertExpectedClasses(environment, PlainJavaBean.class);
+      assertExpectedResources(environment, "ejb.jar");
+   }
+
+   public void testEjbJarWithoutXml() throws Exception
+   {
+      JavaArchive ejbJar = createEjbJar(false);
+      unit = assertDeploy(ejbJar);
+      
+      assertEmptyEnvironment();
+   }
+
+   public void testEjbJarInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
+      JavaArchive ejbJar = createEjbJar(true);
+      ear.addModule(ejbJar);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      E environment = assertSingleEnvironment(EAR_NAME);
+      assertExpectedClasses(environment, PlainJavaBean.class);
+      assertExpectedResources(environment, unit.getSimpleName() + "/ejb.jar");
+   }
+
+   public void testEjbJarWithoutXmlInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
+      JavaArchive ejbJar = createEjbJar(false);
+      ear.addModule(ejbJar);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      assertEmptyEnvironment();
+   }
+
+   public void testEjbJarsInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
+      JavaArchive ejbJar1 = createEjbJar("ejbJar1.jar", true, PlainJavaBean.class);
+      ear.addModule(ejbJar1);
+      JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", true, MySLSBean.class, BusinessInterface.class);
+      ear.addModule(ejbJar2);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      E environment = assertSingleEnvironment(EAR_NAME);
+      assertExpectedClasses(environment, PlainJavaBean.class, MySLSBean.class,
+               BusinessInterface.class);
+      assertExpectedResources(environment, EAR_NAME + "/ejbJar1.jar",
+               EAR_NAME + "/ejbJar2.jar");
+   }
+
+   public void testMixedEjbJarsInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
+      JavaArchive ejbJar1 = createEjbJar("ejbJar1.jar", false, PlainJavaBean.class);
+      ear.addModule(ejbJar1);
+      JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", true, MySLSBean.class, BusinessInterface.class);
+      ear.addModule(ejbJar2);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      E environment = assertSingleEnvironment(EAR_NAME);
+      assertExpectedClasses(environment, MySLSBean.class, BusinessInterface.class);
+      assertExpectedResources(environment, "simple.ear/ejbJar2.jar");
+   }
+
+   public void testEjbJarsWithoutXmlInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
+      JavaArchive ejbJar1 = createEjbJar("ejbJar1.jar", false, PlainJavaBean.class);
+      ear.addModule(ejbJar1);
+      JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", false, MySLSBean.class, BusinessInterface.class);
+      ear.addModule(ejbJar2);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      assertEmptyEnvironment();
+   }
+
+   public void testWar() throws Exception
+   {
+      WebArchive war = createWar(true);
+      unit = assertDeploy(war);
+      
+      E environment = assertSingleEnvironment(WAR_NAME);
+      assertExpectedClasses(environment, ServletWebBean.class);
+      assertExpectedWarResources(environment, unit.getSimpleName(), true);
+   }
+
+   public void testWarWithLib() throws Exception
+   {
+      WebArchive war = createWarWithLib(true, true);
+      unit = assertDeploy(war);
+      
+      E environment = assertSingleEnvironment(WAR_NAME);
+      assertExpectedClasses(environment, ServletWebBean.class, UIWebBean.class);
+      assertExpectedWarResources(environment, unit.getSimpleName(), true, "lib.jar");
+   }
+
+   public void testWarWithLibs() throws Exception
+   {
+      WebArchive war = createWarWithLibs(true, true, true);
+      unit = assertDeploy(war);
+      
+      E environment = assertSingleEnvironment(WAR_NAME);
+      assertExpectedClasses(environment, ServletWebBean.class, UIWebBean.class, CrmWebBean.class);
+      assertExpectedWarResources(environment, unit.getSimpleName(), true, "lib1.jar", "lib2.jar");
+   }
+
+   public void testWarWithLibWithoutXml() throws Exception
+   {
+      WebArchive war = createWarWithLib(true, false);
+      unit = assertDeploy(war);
+      
+      E environment = assertSingleEnvironment(WAR_NAME);
+      assertExpectedClasses(environment, ServletWebBean.class);
+      assertExpectedWarResources(environment, unit.getSimpleName(), true);
+   }
+
+   public void testWarWithLibsWithoutXml() throws Exception
+   {
+      WebArchive war = createWarWithLibs(true, false, false);
+      unit = assertDeploy(war);
+      
+      E environment = assertSingleEnvironment(WAR_NAME);
+      assertExpectedClasses(environment, ServletWebBean.class);
+      assertExpectedWarResources(environment, unit.getSimpleName(), true);
+   }
+
+   public void testWarWithMixedLibs() throws Exception
+   {
+      WebArchive war = createWarWithLibs(true, true, false);
+      unit = assertDeploy(war);
+      
+      E environment = assertSingleEnvironment(WAR_NAME);
+      assertExpectedClasses(environment, ServletWebBean.class, UIWebBean.class);
+      assertExpectedWarResources(environment, unit.getSimpleName(), true, "lib1.jar");
+   }
+
+   public void testWarWithoutXmlWithLib() throws Exception
+   {
+      WebArchive war = createWarWithLib(false, true);
+      unit = assertDeploy(war);
+      
+      E environment = assertSingleEnvironment(WAR_NAME);
+      assertExpectedClasses(environment, UIWebBean.class);
+      assertExpectedWarResources(environment, unit.getSimpleName(), false, "lib.jar");
+   }
+
+   public void testWarWithoutXmlWithLibs() throws Exception
+   {
+      WebArchive war = createWarWithLibs(false, true, true);
+      unit = assertDeploy(war);
+      
+      E environment = assertSingleEnvironment(WAR_NAME);
+      assertExpectedClasses(environment, UIWebBean.class, CrmWebBean.class);
+      assertExpectedWarResources(environment, unit.getSimpleName(), false, "lib1.jar", "lib2.jar");
+   }
+
+   public void testWarWithoutXmlWithLibWithoutXml() throws Exception
+   {
+      WebArchive war = createWarWithLib(false, false);
+      unit = assertDeploy(war);
+      
+      assertEmptyEnvironment();
+   }
+
+   public void testWarWithoutXmlWithMixedLibs() throws Exception
+   {
+      WebArchive war = createWarWithLibs(false, true, false);
+      unit = assertDeploy(war);
+      
+      E environment = assertSingleEnvironment(WAR_NAME);
+      assertExpectedClasses(environment, UIWebBean.class);
+      assertExpectedWarResources(environment, unit.getSimpleName(), false, "lib1.jar");
+   }
+
+   public void testWarWithoutXmlWithLibsWithoutXml() throws Exception
+   {
+      WebArchive war = createWarWithLibs(false, false, false);
+      unit = assertDeploy(war);
+      
+      assertEmptyEnvironment();
+   }
+
+   public void testWarWithoutXml() throws Exception
+   {
+      WebArchive war = createWar(false);
+      unit = assertDeploy(war);
+      
+      assertEmptyEnvironment();
+   }
+
+   public void testWarInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "warinear.ear");
+      WebArchive war = createWar(true);
+      ear.addModule(war);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      E environment = assertSingleEnvironment("warinear.ear/simple.war");
+      assertExpectedClasses(environment, ServletWebBean.class);
+      assertExpectedWarResources(environment, "warinear.ear/simple.war", true);
+   }
+
+   public void testWarsInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "warinear.ear");
+      WebArchive war = createWar("simple1.war", true, ServletWebBean.class);
+      ear.addModule(war);
+      war = createWar("simple2.war", true, NotWBJsfBean.class);
+      ear.addModule(war);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      assertWarsInEar();
+   }
+
+   protected abstract void assertWarsInEar();
+
+   public void testMixedWarsInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "warinear.ear");
+      WebArchive war = createWar("simple1.war", true, ServletWebBean.class);
+      ear.addModule(war);
+      war = createWar("simple2.war", false, NotWBJsfBean.class);
+      ear.addModule(war);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      E environment = assertSingleEnvironment("warinear.ear/simple1.war");
+      assertExpectedClasses(environment, ServletWebBean.class);
+      assertExpectedWarResources(environment, "warinear.ear/simple1.war", true);
+   }
+
+   public void testWarsWithoutXmlInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "warinear.ear");
+      WebArchive war = createWar("simple1.war", false, ServletWebBean.class);
+      ear.addModule(war);
+      war = createWar("simple2.war", false, NotWBJsfBean.class);
+      ear.addModule(war);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      assertEmptyEnvironment();
+   }
+
+   public void testWarWithLibInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "warinear.ear");
+      WebArchive war = createWarWithLib(true, true);
+      ear.addModule(war);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      E environment = assertSingleEnvironment("warinear.ear/" + WAR_NAME);
+      assertExpectedClasses(environment, ServletWebBean.class, UIWebBean.class);
+      assertExpectedWarResources(environment, "warinear.ear/" + WAR_NAME, true, "lib.jar");
+   }
+
+   public void testWarWithLibWithoutXmlInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "warinear.ear");
+      WebArchive war = createWarWithLib(true, false);
+      ear.addModule(war);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      E environment = assertSingleEnvironment("warinear.ear/" + WAR_NAME);
+      assertExpectedClasses(environment, ServletWebBean.class);
+      assertExpectedWarResources(environment, "warinear.ear/" + WAR_NAME, true);
+   }
+
+   public void testWarWithoutXmlWithLibWithoutXmlInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "warinear.ear");
+      WebArchive war = createWarWithLib(false, false);
+      ear.addModule(war);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      assertEmptyEnvironment();
+   }
+
+   public void testWarWithoutXmlWithLibInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "warinear.ear");
+      WebArchive war = createWarWithLib(false, true);
+      ear.addModule(war);
+      MockArchiveManifest.addManifest(ear);
+      unit = assertDeploy(ear);
+      
+      E environment = assertSingleEnvironment("warinear.ear/" + WAR_NAME);
+      assertExpectedClasses(environment, UIWebBean.class);
+      assertExpectedWarResources(environment, "warinear.ear/" + WAR_NAME, false, "lib.jar");
+   }
+
+   public void testBasicEar() throws Exception
+   {
+      VirtualFile ear = createBasicEar();
+      unit = assertDeploy(ear);
+
+      assertBasicEar();
+   }
+
+   protected abstract void assertBasicEar();
+
+   public void testBasicEarFullCDI() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "top-level.ear");
+      createLib(ear, "util.jar", true, SomeUtil.class);
+      createLib(ear, "ext.jar", true, ExternalWebBean.class);
+      JavaArchive ejbJar = createEjbJar("simple.jar", true, PlainJavaBean.class);
+      ear.addModule(ejbJar);
+      ejbJar = createEjbJar("ejbs.jar", true, MySLSBean.class, BusinessInterface.class);
+      ear.addModule(ejbJar);
+      WebArchive war = createWar("simple.war", true, ServletWebBean.class);
+      createLib(war, "ui.jar", true, UIWebBean.class);
+      ear.addModule(war);
+      war = createWar("crm.war", true, NotWBJsfBean.class);
+      createLib(war, "crm.jar", true, CrmWebBean.class);
+      ear.addModule(war);
+      unit = assertDeploy(ear);
+      
+      assertBasicEarFullCDI();
+   }
+
+   protected abstract void assertBasicEarFullCDI();
+
+   public void testBasicEarWithoutXml() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "simple.ear");
+      createLib(ear, "util.jar", false, SomeUtil.class);
+      createLib(ear, "ext.jar", false, ExternalWebBean.class);
+      JavaArchive ejbJar = createEjbJar("simple.jar", false, PlainJavaBean.class);
+      ear.addModule(ejbJar);
+      ejbJar = createEjbJar("ejbs.jar", false, MySLSBean.class, BusinessInterface.class);
+      ear.addModule(ejbJar);
+      WebArchive war = createWar("simple.war", false, ServletWebBean.class);
+      createLib(war, "ui.jar", false, UIWebBean.class);
+      ear.addModule(war);
+      war = createWar("crm.war", false, NotWBJsfBean.class);
+      createLib(war, "crm.jar", false, CrmWebBean.class);
+      ear.addModule(war);
+      unit = assertDeploy(ear);
+
+      assertBasicEarWithoutXml();
+   }
+
+   protected abstract void assertBasicEarWithoutXml();
+
+   /**
+    * Asserts that there is no environment resultant from the deployment.
+    */
+   protected abstract void assertEmptyEnvironment();
+
+   /**
+    * Asserts that there is only one environment resultant from the deployment.
+    * 
+    * @param name the name of the environment
+    * @return     the environment
+    */
+   protected abstract E assertSingleEnvironment(String name);
+}

Modified: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractWeldTest.java
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractWeldTest.java	2010-08-10 14:42:32 UTC (rev 107523)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/AbstractWeldTest.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -21,11 +21,21 @@
  */
 package org.jboss.test.deployers.test;
 
+import java.io.Closeable;
+import java.io.IOException;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.Executors;
 
 import org.jboss.classloader.plugins.jdk.AbstractJDKChecker;
 import org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataFactoryVisitor;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.vfs3.ArchiveFileSystem;
 import org.jboss.test.deployers.BootstrapDeployersTest;
 import org.jboss.test.deployers.support.crm.CrmWebBean;
 import org.jboss.test.deployers.support.ejb.MySLSBean;
@@ -35,6 +45,8 @@
 import org.jboss.test.deployers.support.ui.UIWebBean;
 import org.jboss.test.deployers.support.util.SomeUtil;
 import org.jboss.test.deployers.support.web.ServletWebBean;
+import org.jboss.vfs.TempDir;
+import org.jboss.vfs.TempFileProvider;
 import org.jboss.vfs.VFS;
 import org.jboss.vfs.VirtualFile;
 
@@ -56,7 +68,7 @@
       // excluding class that knows hot to load from system classloader
       Set<Class<?>> excluded = AbstractJDKChecker.getExcluded();
       excluded.add(BeanMetaDataFactoryVisitor.class);
-      
+            tempFileProvider = TempFileProvider.create("shrinkwrap-", Executors.newSingleThreadScheduledExecutor());
       super.setUp();
    }
 
@@ -177,4 +189,59 @@
          .addPath("/weld/simple/ejb");
       return jarFile;
    }
+   
+      
+   private static TempFileProvider tempFileProvider;
+   private final List<Closeable> vfsHandles = new ArrayList<Closeable>();
+   
+   protected VFSDeploymentUnit assertDeploy(Archive<?> archive) throws Exception
+   {
+      VirtualFile virtualFile = mount(archive);
+      VFSDeploymentUnit unit = assertDeploy(virtualFile);
+      return unit;
+   }
+   
+   @Override
+   protected VFSDeploymentUnit assertDeploy(VirtualFile virtualFile) throws Exception
+   {
+      VFSDeploymentUnit unit = super.assertDeploy(virtualFile);
+      units.add(unit);
+      return unit;
+   }
+   
+   private Collection<VFSDeploymentUnit> units = new ArrayList<VFSDeploymentUnit>();
+   
+   private VirtualFile mount(Archive<?> archive) throws IOException
+   {
+      final TempDir tempDir = tempFileProvider.createTempDir(archive.getName());
+      VirtualFile virtualFile = VFS.getChild(UUID.randomUUID().toString()).getChild(archive.getName());
+      vfsHandles.add(VFS.mount(virtualFile, new ArchiveFileSystem(archive, tempDir)));
+      mountZipFiles(virtualFile);
+      return virtualFile;
+   }
+   
+   private void mountZipFiles(VirtualFile file) throws IOException
+   {
+      if (!file.isDirectory() && file.getName().matches("^.*\\.([EeWwJj][Aa][Rr]|[Zz][Ii][Pp])$"))
+         vfsHandles.add(VFS.mountZip(file, file, tempFileProvider));
+
+      if (file.isDirectory())
+         for (VirtualFile child : file.getChildren())
+            mountZipFiles(child);
+   }
+   
+   protected void tearDown() throws Exception
+   {
+      for (VFSDeploymentUnit unit: units)
+      {
+         undeploy(unit);
+      }
+      units.clear();
+      for (Closeable vfsHandle: vfsHandles)
+      {
+            vfsHandle.close();
+      }
+      vfsHandles.clear();
+      super.tearDown();
+   }
 }
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.java (from rev 107515, trunk/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,274 @@
+/*
+ * 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.test.deployers.test;
+
+import java.net.URL;
+import java.util.Collection;
+
+import junit.framework.Test;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.test.deployers.support.crm.CrmWebBean;
+import org.jboss.test.deployers.support.ejb.BusinessInterface;
+import org.jboss.test.deployers.support.ejb.MySLSBean;
+import org.jboss.test.deployers.support.ext.ExternalWebBean;
+import org.jboss.test.deployers.support.jar.PlainJavaBean;
+import org.jboss.test.deployers.support.jsf.NotWBJsfBean;
+import org.jboss.test.deployers.support.ui.UIWebBean;
+import org.jboss.test.deployers.support.util.SomeUtil;
+import org.jboss.test.deployers.support.web.ServletWebBean;
+import org.jboss.util.UnreachableStatementException;
+import org.jboss.weld.integration.deployer.env.WeldDiscoveryEnvironment;
+import org.jboss.weld.integration.deployer.env.bda.ArchiveInfo;
+
+/**
+ * ArchiveInfo environment discovery test case.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class ArchiveEnvironmentTestCase extends AbstractSingleArchiveTest<WeldDiscoveryEnvironment>
+{
+   public ArchiveEnvironmentTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ArchiveEnvironmentTestCase.class);
+   }
+
+   @Override
+   public void testEjbJarInEar() throws Exception
+   {
+      super.testEjbJarInEar();
+
+      assertSingleChildAsUnit(EJB_JAR_NAME);
+      assertNoArchiveInfo(unit);
+   }
+
+   @Override
+   public void testEjbJarWithoutXmlInEar() throws Exception
+   {
+      super.testEjbJarWithoutXmlInEar();
+
+      assertSingleChildAsUnit(EJB_JAR_NAME);
+      assertNoArchiveInfo(unit);
+   }
+
+   @Override
+   protected void assertWarsInEar()
+   {
+      WeldDiscoveryEnvironment discovery = assertDiscoveryEnvironment();
+      assertExpectedClasses(discovery);
+      assertExpectedResources(discovery);
+      
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         unit = childUnit;
+         if (unit.getSimpleName().equals("simple1.war"))
+         {
+            discovery = assertDiscoveryEnvironment();
+            assertExpectedClasses(discovery, ServletWebBean.class);
+            assertExpectedWarResources(discovery, "warinear.ear/simple1.war", true);
+         }
+         else if (unit.getSimpleName().equals("simple2.war"))
+         {
+            discovery = assertDiscoveryEnvironment();
+            assertExpectedClasses(discovery, NotWBJsfBean.class);
+            assertExpectedWarResources(discovery, "warinear.ear/simple2.war", true);
+         }
+         else
+         {
+            fail("Unexpected childUnit: " + unit.getSimpleName());
+         }
+      }
+   }
+
+   @Override
+   protected void assertBasicEar()
+   {
+      WeldDiscoveryEnvironment discovery = assertDiscoveryEnvironment();
+      assertExpectedClasses(discovery, BusinessInterface.class, MySLSBean.class,
+               ExternalWebBean.class, PlainJavaBean.class);
+      assertExpectedResources(discovery, "top-level.ear/ejbs.jar",
+               "top-level.ear/lib/ext.jar", "top-level.ear/simple.jar");
+
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         unit = childUnit;
+         if (childUnit.getName().endsWith("simple.war/"))
+         {
+            discovery = assertDiscoveryEnvironment();
+            assertExpectedClasses(discovery, UIWebBean.class, ServletWebBean.class);
+            assertExpectedWarResources(discovery, "top-level.ear/simple.war", true, "ui.jar");
+         }
+         else if (childUnit.getName().endsWith("crm.war/"))
+         {
+            discovery = assertDiscoveryEnvironment();
+            assertExpectedClasses(discovery, CrmWebBean.class);
+            assertExpectedWarResources(discovery, "top-level.ear/crm.war", false, "crm.jar");
+         }
+         else
+         {
+            ArchiveInfo archiveInfo = childUnit.getAttachment(ArchiveInfo.class);
+            assertNull("Unit " + unit.getName() +  " contains a not null ArchiveInfo", archiveInfo);
+         }
+      }
+   }
+
+   @Override
+   protected void assertBasicEarFullCDI()
+   {
+      WeldDiscoveryEnvironment discovery = assertDiscoveryEnvironment();
+      assertExpectedClasses(discovery, BusinessInterface.class, MySLSBean.class,
+               ExternalWebBean.class, PlainJavaBean.class, SomeUtil.class);
+      assertExpectedResources(discovery, "top-level.ear/lib/util.jar",
+               "top-level.ear/lib/ext.jar", "top-level.ear/simple.jar",
+               "top-level.ear/ejbs.jar");
+
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         unit = childUnit;
+         if (childUnit.getName().endsWith("simple.war/"))
+         {
+            discovery = assertDiscoveryEnvironment();
+            assertExpectedClasses(discovery, UIWebBean.class, ServletWebBean.class);
+            assertExpectedWarResources(discovery, "top-level.ear/simple.war", true, "ui.jar");
+         }
+         else if (childUnit.getName().endsWith("crm.war/"))
+         {
+            discovery = assertDiscoveryEnvironment();
+            assertExpectedClasses(discovery, CrmWebBean.class, NotWBJsfBean.class);
+            assertExpectedWarResources(discovery, "top-level.ear/crm.war", true, "crm.jar");
+         }
+         else
+         {
+            ArchiveInfo archiveInfo = childUnit.getAttachment(ArchiveInfo.class);
+            assertNull("Unit " + unit.getName() +  " contains a not null ArchiveInfo", archiveInfo);
+         }
+      }
+   }
+
+   @Override
+   protected void assertBasicEarWithoutXml()
+   {
+      WeldDiscoveryEnvironment discovery = assertDiscoveryEnvironment();
+      
+      assertExpectedClasses(discovery);
+      assertExpectedResources(discovery);
+
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         if (childUnit.getName().endsWith("simple.war/") ||
+                  childUnit.getName().endsWith("crm.war/"))
+         {
+            unit = childUnit;
+            discovery = assertDiscoveryEnvironment();
+            assertExpectedClasses(discovery);
+            assertExpectedResources(discovery);
+         }
+         else
+         {
+            ArchiveInfo archiveInfo = childUnit.getAttachment(ArchiveInfo.class);
+            assertNull("Unit " + unit.getName() +  " contains a not null ArchiveInfo", archiveInfo);
+         }
+      }
+   }
+
+   @Override
+   protected void assertEmptyEnvironment()
+   {
+      WeldDiscoveryEnvironment discovery = assertDiscoveryEnvironment();
+      assertExpectedClasses(discovery);
+      assertExpectedResources(discovery);
+   }
+
+   @Override
+   protected WeldDiscoveryEnvironment assertSingleEnvironment(String name)
+   {
+      if (unit.getName().contains(name))
+      {
+         return assertDiscoveryEnvironment(name);
+      }
+      for (DeploymentUnit childUnit : unit.getChildren())
+      {
+         if (childUnit.getName().contains(name))
+         {
+            return assertDiscoveryEnvironment(childUnit, name);
+         }
+      }
+      fail("Was not able to find a unit with suffix " + name);
+      throw new UnreachableStatementException();
+   }
+
+   @Override
+   protected Collection<Class<?>> getClasses(
+            WeldDiscoveryEnvironment environment)
+   {
+      return environment.getWeldClasses();
+   }
+
+   @Override
+   protected Collection<URL> getResources(WeldDiscoveryEnvironment environment)
+   {
+      return environment.getWeldXml();
+   }
+
+   private void assertSingleChildAsUnit(String name)
+   {
+      assertEquals(1, unit.getChildren().size());
+      unit = unit.getChildren().iterator().next();
+      assertEquals(unit.getSimpleName(), name);
+   }
+
+   private void assertNoArchiveInfo(DeploymentUnit unit)
+   {
+      assertNull(unit.getAttachment(ArchiveInfo.class));
+   }
+
+   private WeldDiscoveryEnvironment assertDiscoveryEnvironment(String name)
+   {
+      return assertDiscoveryEnvironment(unit, name);
+   }
+
+   private WeldDiscoveryEnvironment assertDiscoveryEnvironment(DeploymentUnit unit, String name)
+   {
+      ArchiveInfo archiveInfo = unit.getAttachment(ArchiveInfo.class);
+      assertNotNull(archiveInfo);
+      assertTrue("Unit name \"" + unit.getName() + "\" expected to end with \"" + name +
+               "\" suffix", unit.getName().endsWith(name + '/'));
+      WeldDiscoveryEnvironment discovery = archiveInfo.getEnvironment();
+      assertNotNull(discovery);
+      return discovery;
+   }
+
+   private WeldDiscoveryEnvironment assertDiscoveryEnvironment()
+   {
+      ArchiveInfo archiveInfo = unit.getAttachment(ArchiveInfo.class);
+      assertNotNull(archiveInfo);
+      WeldDiscoveryEnvironment discovery = archiveInfo.getEnvironment();
+      assertNotNull(discovery);
+      return discovery;
+   }
+}

Copied: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.java (from rev 107515, trunk/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,195 @@
+/*
+ * 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.test.deployers.test;
+
+import junit.framework.Test;
+
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.test.deployers.support.jar.PlainJavaBean;
+import org.jboss.test.deployers.support.web.ServletWebBean;
+import org.jboss.vfs.VFS;
+import org.jboss.vfs.VirtualFile;
+import org.jboss.weld.integration.deployer.env.bda.ArchiveInfo;
+import org.jboss.weld.integration.deployer.env.bda.Classpath;
+
+/**
+ * ArchiveInfo deployment test case.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ArchiveInfoDeploymentTestCase extends AbstractWeldTest
+{
+   // the name of a classpath should always coincide with the name of the corresponding domain
+   private static String DEFAULT_CLASSPATH_NAME = ClassLoaderSystem.getInstance().getDefaultDomain().getName();
+   
+   public ArchiveInfoDeploymentTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ArchiveInfoDeploymentTestCase.class);
+   }
+   
+   private Classpath defaultClasspath;
+   private VFSDeploymentUnit unit;
+   
+   public void tearDown() throws Exception
+   {
+      undeploy(unit);
+      super.tearDown();
+   }
+
+   public void testEjbJar() throws Exception
+   {
+      VirtualFile ejbJar = createEjbJar("simple.jar", PlainJavaBean.class);
+      unit = assertDeploy(ejbJar);
+      assertArchiveInfoWithDefaultClasspath(unit);
+      assertEmpty(unit.getChildren());
+   }
+
+   public void testWar() throws Exception
+   {
+      VirtualFile war = createWar("simple.war", ServletWebBean.class);
+      unit = assertDeploy(war);
+      assertArchiveInfoWithWarClasspath(unit);
+   }
+
+   public void testEjbJarinEar() throws Exception
+   {
+      VirtualFile ejbJar = createJarInEar();
+      unit = assertDeploy(ejbJar);
+      assertArchiveInfoWithDefaultClasspath(unit);
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         assertNull(childUnit.getAttachment(ArchiveInfo.class));
+      }
+   }
+
+   public void testWarinEar() throws Exception
+   {
+      VirtualFile warInEar = createWarInEar();
+      unit = assertDeploy(warInEar);
+      assertArchiveInfoWithDefaultClasspath(unit);
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         assertArchiveInfoWithWarClasspath(childUnit);
+      }
+   }
+
+   public void testEarWithUtil() throws Exception
+   {
+      VirtualFile ear = createTopLevelWithUtil("/weld/earwithutil");
+      unit = assertDeploy(ear);
+      assertArchiveInfoWithDefaultClasspath(unit);
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         assertNull(childUnit.getAttachment(ArchiveInfo.class));
+      }
+   }
+
+   public void testJarWarInEar() throws Exception
+   {
+      VirtualFile ear = VFS.getChild("jar-in-ear.ear"); 
+      createAssembledDirectory(ear)
+      .addPath("/weld/jarwarinear")
+      .addPackage("simple.jar", PlainJavaBean.class)
+      .addPackage("simple.war/WEB-INF/classes", PlainJavaBean.class)
+      .addPath("simple.war", "/weld/warwowb/web");
+      unit = assertDeploy(ear);
+      
+      assertArchiveInfoWithDefaultClasspath(unit);
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         if (childUnit.getName().endsWith("simple.jar/"))
+         {
+            assertNull(childUnit.getAttachment(ArchiveInfo.class));
+         }
+         else if (childUnit.getName().endsWith("simple.war/"))
+         {
+            assertArchiveInfoWithWarClasspath(childUnit);
+         }
+         else
+         {
+            fail("Unexpected unit name: " + childUnit.getName());
+         }
+      }
+   }
+
+   public void testEar() throws Exception
+   {
+      VirtualFile ear = createBasicEar();
+      unit = assertDeploy(ear);
+      assertArchiveInfoWithDefaultClasspath(unit);
+      for (DeploymentUnit childUnit: unit.getChildren())
+      {
+         ArchiveInfo archiveInfo = childUnit.getAttachment(ArchiveInfo.class);
+         if (childUnit.getName().endsWith(".war/"))
+         {
+            assertNotNull("Null ArchiveInfo", archiveInfo);
+            assertNonDefaultClasspath(childUnit.getName(), archiveInfo.getClasspath());
+         }
+         else
+         {
+            assertNull("ArchiveInfo for unit " + childUnit.getName() + " is not null", archiveInfo);
+         }
+      }
+   }
+
+   private void assertArchiveInfoWithDefaultClasspath(VFSDeploymentUnit unit)
+   {
+      ArchiveInfo archiveInfo = unit.getAttachment(ArchiveInfo.class);
+      assertNotNull("Null ArchiveInfo", archiveInfo);
+      assertDefaultClasspath(archiveInfo.getClasspath());
+   }
+
+   private void assertArchiveInfoWithWarClasspath(DeploymentUnit unit)
+   {
+      ArchiveInfo archiveInfo = unit.getAttachment(ArchiveInfo.class);
+      assertNotNull("Null ArchiveInfo for unit " + unit, archiveInfo);
+      assertClasspath(unit.getName(), archiveInfo.getClasspath());
+      assertEmpty(unit.getChildren());
+   }
+
+   private void assertDefaultClasspath(Classpath classpath)
+   {
+      assertClasspath(DEFAULT_CLASSPATH_NAME, classpath);
+      this.defaultClasspath = classpath;
+   }
+
+   private void assertNonDefaultClasspath(String name, Classpath classpath)
+   {
+      assertClasspath(name, classpath);
+      assertNotSame(defaultClasspath, classpath);
+   }
+
+   private void assertClasspath(String name, Classpath classpath)
+   {
+      assertNotNull(classpath);
+      assertFalse(classpath.iterator().hasNext());
+      assertEquals(name, classpath.getName());
+   }
+}

Copied: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.java (from rev 107515, trunk/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,56 @@
+/*
+ * 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.test.deployers.test;
+
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+
+/**
+ * JBoss Deployment test case.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class BasicEarJBossDeploymentTestCase extends AbstractDeploymentTest
+{
+   public BasicEarJBossDeploymentTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(BasicEarJBossDeploymentTestCase.class);
+   }
+
+   protected int getExpectedArchives()
+   {
+      return 3;
+   }
+
+   protected void assertNewBeanDeploymentArchive(List<BeanDeploymentArchive> archives, BeanDeploymentArchive newBDA)
+   {
+      assertSame(newBDA, archives.iterator().next());
+   }
+}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/DeploymentEnvironmentTestCase.java (from rev 107515, trunk/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/DeploymentEnvironmentTestCase.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/DeploymentEnvironmentTestCase.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/DeploymentEnvironmentTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,272 @@
+/*
+ * 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.test.deployers.test;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import junit.framework.Test;
+
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.test.deployers.support.CheckableBootstrap;
+import org.jboss.test.deployers.support.MockEjbServices;
+import org.jboss.test.deployers.support.MockEmptyEjbServices;
+import org.jboss.test.deployers.support.MockTransactionServices;
+import org.jboss.test.deployers.support.MockWeldBootstrap;
+import org.jboss.test.deployers.support.WeldDEWrapper;
+import org.jboss.test.deployers.support.crm.CrmWebBean;
+import org.jboss.test.deployers.support.ejb.BusinessInterface;
+import org.jboss.test.deployers.support.ejb.MySLSBean;
+import org.jboss.test.deployers.support.ext.ExternalWebBean;
+import org.jboss.test.deployers.support.jar.PlainJavaBean;
+import org.jboss.test.deployers.support.jsf.NotWBJsfBean;
+import org.jboss.test.deployers.support.ui.UIWebBean;
+import org.jboss.test.deployers.support.util.SomeUtil;
+import org.jboss.test.deployers.support.web.ServletWebBean;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+/**
+ * JBossDeployment environment test case.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class DeploymentEnvironmentTestCase extends AbstractSingleArchiveTest<BeanDeploymentArchive>
+{
+   public DeploymentEnvironmentTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(DeploymentEnvironmentTestCase.class);
+   }
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      JavaArchive mockJar = ShrinkWrap.create(JavaArchive.class, "mock.jar");
+      mockJar.addClass(CheckableBootstrap.class);
+      mockJar.addClass(MockEjbServices.class);
+      mockJar.addClass(MockEmptyEjbServices.class);
+      mockJar.addClass(MockTransactionServices.class);
+      mockJar.addClass(MockWeldBootstrap.class);
+      mockJar.addClass(WeldDEWrapper.class);
+      assertDeploy(mockJar);
+   }
+
+   @Override
+   protected void assertWarsInEar()
+   {
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      Collection<BeanDeploymentArchive> bdas = getBDAs(deployment);
+      assertEquals(2, bdas.size());
+      Iterator<BeanDeploymentArchive> iterator = bdas.iterator();
+      BeanDeploymentArchive bda = iterator.next();
+      BeanDeploymentArchive bda1, bda2;
+      if (bda.getId().contains("simple1.war"))
+      {
+         bda1 = bda;
+         bda2 = iterator.next();
+      }
+      else
+      {
+         bda2 = bda;
+         bda1 = iterator.next();
+      }
+      assertBDAId(bda1, "warinear.ear/simple1.war");
+      assertExpectedClasses(bda1, ServletWebBean.class);
+      assertExpectedWarResources(bda1, "simple1.war", true);
+
+      assertBDAId(bda2, "warinear.ear/simple2.war");
+      assertExpectedClasses(bda2, NotWBJsfBean.class);
+      assertExpectedWarResources(bda2, "simple2.war", true);
+      
+      Collection<BeanDeploymentArchive> reachableBDAs = getReachableBDAs(bda1);
+      assertTrue(reachableBDAs.isEmpty());
+      reachableBDAs = getReachableBDAs(bda2);
+      assertTrue(reachableBDAs.isEmpty());
+   }
+
+   @Override
+   protected void assertBasicEar()
+   {
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      Collection<BeanDeploymentArchive> bdas = getBDAs(deployment);
+      assertEquals(3, bdas.size());
+      BeanDeploymentArchive earBDA = null, simpleWarBDA = null, crmWarBDA = null;
+      for (BeanDeploymentArchive bda: bdas)
+      {
+         if (bda.getId().contains("simple.war"))
+         {
+            simpleWarBDA = bda;
+            assertBDAId(simpleWarBDA, "top-level.ear/simple.war");
+            assertExpectedClasses(simpleWarBDA, UIWebBean.class, ServletWebBean.class);
+            assertExpectedWarResources(simpleWarBDA, "top-level.ear/simple.war", true, "ui.jar");
+         }
+         else if (bda.getId().contains("crm.war"))
+         {
+            crmWarBDA = bda;
+            assertBDAId(crmWarBDA, "top-level.ear/crm.war");
+            assertExpectedClasses(crmWarBDA, CrmWebBean.class);
+            assertExpectedResources(crmWarBDA, "crm.jar");
+         }
+         else
+         {
+            earBDA = bda;
+            assertBDAId(earBDA, "top-level.ear");
+            assertExpectedClasses(earBDA, BusinessInterface.class, MySLSBean.class,
+                     ExternalWebBean.class, PlainJavaBean.class);
+            assertExpectedResources(earBDA, "top-level.ear/ejbs.jar",
+                     "top-level.ear/lib/ext.jar", "top-level.ear/simple.jar");
+         }
+      }
+      Collection<BeanDeploymentArchive> reachableBDAs = getReachableBDAs(earBDA);
+      assertTrue(reachableBDAs.isEmpty());
+      reachableBDAs = getReachableBDAs(simpleWarBDA);
+      assertEquals(1, reachableBDAs.size());
+      assertSame(earBDA, reachableBDAs.iterator().next());
+   }
+
+   @Override
+   protected void assertBasicEarFullCDI()
+   {
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      Collection<BeanDeploymentArchive> bdas = getBDAs(deployment);
+      assertEquals(3, bdas.size());
+      BeanDeploymentArchive earBDA = null, simpleWarBDA = null, crmWarBDA = null;
+      for (BeanDeploymentArchive bda: bdas)
+      {
+         if (bda.getId().contains("simple.war"))
+         {
+            simpleWarBDA = bda;
+            assertBDAId(simpleWarBDA, "top-level.ear/simple.war");
+            assertExpectedClasses(simpleWarBDA, UIWebBean.class, ServletWebBean.class);
+            assertExpectedWarResources(simpleWarBDA, "top-level.ear/simple.war", true, "ui.jar");
+         }
+         else if (bda.getId().contains("crm.war"))
+         {
+            crmWarBDA = bda;
+            assertBDAId(crmWarBDA, "top-level.ear/crm.war");
+            assertExpectedClasses(crmWarBDA, CrmWebBean.class, NotWBJsfBean.class);
+            assertExpectedWarResources(crmWarBDA, "top-level.ear/crm.war", true, "crm.jar");
+         }
+         else
+         {
+            earBDA = bda;
+            assertBDAId(earBDA, "top-level.ear");
+            assertExpectedClasses(earBDA, BusinessInterface.class, MySLSBean.class,
+                     ExternalWebBean.class, PlainJavaBean.class, SomeUtil.class);
+            assertExpectedResources(earBDA, "top-level.ear/lib/util.jar",
+                     "top-level.ear/lib/ext.jar", "top-level.ear/simple.jar",
+                     "top-level.ear/ejbs.jar");
+         }
+      }
+
+      Collection<BeanDeploymentArchive> reachableBDAs = getReachableBDAs(earBDA);
+      assertTrue(reachableBDAs.isEmpty());
+      reachableBDAs = getReachableBDAs(simpleWarBDA);
+      assertEquals(1, reachableBDAs.size());
+      assertSame(earBDA, reachableBDAs.iterator().next());
+   }
+
+   @Override
+   protected void assertBasicEarWithoutXml()
+   {
+      assertEmptyEnvironment();
+   }
+
+   @Override
+   protected void assertEmptyEnvironment()
+   {
+      assertNoBean(Deployment.class);
+   }
+
+   @Override
+   protected BeanDeploymentArchive assertSingleEnvironment(String name)
+   {
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      return assertOneBDA(deployment, name);
+   }
+
+   @Override
+   protected Collection<Class<?>> getClasses(BeanDeploymentArchive bda)
+   {
+      return bda.getBeanClasses();
+   }
+
+   @Override
+   protected Collection<URL> getResources(BeanDeploymentArchive bda)
+   {
+      return bda.getBeansXml();
+   }
+
+   private BeanDeploymentArchive assertOneBDA(Deployment deployment, String name)
+   {
+      Collection<BeanDeploymentArchive> bdas = getBDAs(deployment);
+      assertEquals(1, bdas.size());
+      BeanDeploymentArchive bda = bdas.iterator().next();
+      assertBDAId(bda, name);
+      assertTrue(getReachableBDAs(bda).isEmpty());
+      return bda;
+   }
+
+   private Collection<BeanDeploymentArchive> getBDAs(Deployment deployment)
+   {
+      assertNotNull(deployment);
+      Collection<BeanDeploymentArchive> bdas = deployment.getBeanDeploymentArchives();
+      assertNotNull(bdas);
+      return bdas;
+   }
+
+   private void assertBDAId(BeanDeploymentArchive bda, String name)
+   {
+      assertTrue("BDA id \""  + bda.getId() + "\" expected to end with suffix \"" + name + "/}\"",
+               bda.getId().endsWith(name + "/}"));
+   }
+
+   private Collection<BeanDeploymentArchive> getReachableBDAs(BeanDeploymentArchive bda)
+   {
+      Collection<BeanDeploymentArchive> result = new HashSet<BeanDeploymentArchive>();
+      getReachableBDAs(bda, result);
+      result.remove(bda);
+      return result;
+   }
+
+   private void getReachableBDAs(BeanDeploymentArchive bda, Collection<BeanDeploymentArchive> result)
+   {
+      if (result.contains(bda))
+      {
+         return;
+      }
+      result.add(bda);
+      for (BeanDeploymentArchive reachableBDA: bda.getBeanDeploymentArchives())
+      {
+         getReachableBDAs(reachableBDA, result);
+      }
+   }
+}

Copied: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentSmokeTestCase.java (from rev 107515, trunk/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentSmokeTestCase.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentSmokeTestCase.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/FlatDeploymentSmokeTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,43 @@
+/*
+ * 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.test.deployers.test;
+
+import junit.framework.Test;
+
+/**
+ * Smoke tests for FlatDeployment creation.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class FlatDeploymentSmokeTestCase extends SmokeTestCase
+{
+   public FlatDeploymentSmokeTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(FlatDeploymentSmokeTestCase.class);
+   }
+}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/JBossDeploymentSmokeTestCase.java (from rev 107515, trunk/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/JBossDeploymentSmokeTestCase.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/JBossDeploymentSmokeTestCase.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/JBossDeploymentSmokeTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,43 @@
+/*
+ * 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.test.deployers.test;
+
+import junit.framework.Test;
+
+/**
+ * Smoke tests for JBossDeployment creation.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class JBossDeploymentSmokeTestCase extends SmokeTestCase
+{
+   public JBossDeploymentSmokeTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(JBossDeploymentSmokeTestCase.class);
+   }
+}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java (from rev 107515, trunk/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/java/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.java	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,907 @@
+/*
+ * 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.test.deployers.test;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.Iterator;
+
+import junit.framework.Test;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.test.deployers.support.CheckableBootstrap;
+import org.jboss.test.deployers.support.MockArchiveManifest;
+import org.jboss.test.deployers.support.MockEjbServices;
+import org.jboss.test.deployers.support.MockEmptyEjbServices;
+import org.jboss.test.deployers.support.MockTransactionServices;
+import org.jboss.test.deployers.support.MockWeldBootstrap;
+import org.jboss.test.deployers.support.WeldDEWrapper;
+import org.jboss.test.deployers.support.crm.CrmWebBean;
+import org.jboss.test.deployers.support.ejb.BusinessInterface;
+import org.jboss.test.deployers.support.ejb.MySLSBean;
+import org.jboss.test.deployers.support.ext.ExternalWebBean;
+import org.jboss.test.deployers.support.jar.PlainJavaBean;
+import org.jboss.test.deployers.support.jsf.NotWBJsfBean;
+import org.jboss.test.deployers.support.ui.UIWebBean;
+import org.jboss.test.deployers.support.util.SomeUtil;
+import org.jboss.test.deployers.support.web.ServletWebBean;
+import org.jboss.test.deployers.vfs.classloader.support.a.A;
+import org.jboss.test.deployers.vfs.classloader.support.b.B;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.integration.deployer.DeployersUtils;
+
+/**
+ * Deployment.loadBeanDeploymentArchive test case.
+ *
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class LoadBeanDeploymentArchiveTestCase extends AbstractEnvironmentTest<BeanDeploymentArchive>
+{
+   public LoadBeanDeploymentArchiveTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(LoadBeanDeploymentArchiveTestCase.class);
+   }
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      JavaArchive mockJar = ShrinkWrap.create(JavaArchive.class, "mock.jar");
+      mockJar.addClass(CheckableBootstrap.class);
+      mockJar.addClass(MockEjbServices.class);
+      mockJar.addClass(MockEmptyEjbServices.class);
+      mockJar.addClass(MockTransactionServices.class);
+      mockJar.addClass(MockWeldBootstrap.class);
+      mockJar.addClass(WeldDEWrapper.class);
+      assertDeploy(mockJar);
+   }
+
+   public void testEjbJars() throws Exception
+   {
+      // ejb1.jar
+      JavaArchive ejbJar1 = createEjbJar("ejb1.jar", true, PlainJavaBean.class);
+      DeploymentUnit unit = assertDeploy(ejbJar1);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+      Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      // ejb2.jar
+      JavaArchive ejbJar2 = createEjbJar("ejb2.jar", true,  MySLSBean.class, BusinessInterface.class);
+      unit = assertDeploy(ejbJar2);
+      Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
+      Class<?> businessInterface = getClass(BusinessInterface.class, unit);
+      Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      
+      assertNotSame(deployment1, deployment2);
+      
+      BeanDeploymentArchive bda1 = deployment1.getBeanDeploymentArchives().iterator().next();
+      BeanDeploymentArchive bda2 = deployment2.getBeanDeploymentArchives().iterator().next();
+      // double invocation should yield the same result
+      assertSame(bda1, deployment1.loadBeanDeploymentArchive(plainJavaBeanClass));
+      assertSame(bda1, deployment1.loadBeanDeploymentArchive(plainJavaBeanClass));
+      
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
+      
+      assertSame(bda1, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
+      assertSame(bda1, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(businessInterface));
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(businessInterface));
+   }
+
+   public void testMixedEjbJars() throws Exception
+   {
+      // ejb1.jar
+      JavaArchive ejbJar1 = createEjbJar("ejb1.jar", true, PlainJavaBean.class);
+      DeploymentUnit unit = assertDeploy(ejbJar1);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+      Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      // ejb2.jar
+      JavaArchive ejbJar2 = createEjbJar("ejb2.jar", false,  MySLSBean.class, BusinessInterface.class);
+      unit = assertDeploy(ejbJar2);
+      ClassLoader classLoader2 = unit.getClassLoader();
+      Class<?> mySLSBeanClass = classLoader2.loadClass(MySLSBean.class.getName());
+      Class<?> businessInterface = classLoader2.loadClass(BusinessInterface.class.getName());
+      
+      BeanDeploymentArchive bda1 = deployment1.getBeanDeploymentArchives().iterator().next();
+      assertSame(bda1, deployment1.loadBeanDeploymentArchive(plainJavaBeanClass));
+      // creation of bda2 on demand
+      BeanDeploymentArchive bda2 = deployment1.loadBeanDeploymentArchive(mySLSBeanClass);
+      assertBDAId(bda2, "ejb2.jar");
+      assertExpectedClasses(bda2, MySLSBean.class);
+      assertExpectedResources(bda2);
+      // double invocation
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertBDAId(bda2, "ejb2.jar");
+      assertExpectedClasses(bda2, MySLSBean.class);
+      assertExpectedResources(bda2);
+      // inclusion of BusinessInterface
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
+      assertBDAId(bda2, "ejb2.jar");
+      assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
+      assertExpectedResources(bda2);
+      // double invocation
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
+      assertBDAId(bda2, "ejb2.jar");
+      assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
+      assertExpectedResources(bda2);
+   }
+
+   public void testEjbJarsInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
+      JavaArchive ejbJar1 = createEjbJar("ejbJar1.jar", true, PlainJavaBean.class);
+      ear.addModule(ejbJar1);
+      JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", true, MySLSBean.class, BusinessInterface.class);
+      ear.addModule(ejbJar2);
+      MockArchiveManifest.addManifest(ear);
+      DeploymentUnit unit = assertDeploy(ear);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+      Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
+      Class<?> businessInterface = getClass(BusinessInterface.class, unit);
+      
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      BeanDeploymentArchive bda = deployment.loadBeanDeploymentArchive(plainJavaBeanClass);
+      assertBDAId(bda, EAR_NAME);
+      assertExpectedClasses(bda, PlainJavaBean.class, MySLSBean.class, BusinessInterface.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertSame(bda, deployment.loadBeanDeploymentArchive(businessInterface));
+   }
+   
+   
+   public void testMixedEjbJarsInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
+      JavaArchive ejbJar1 = createEjbJar("ejbJar1.jar", true, PlainJavaBean.class);
+      ear.addModule(ejbJar1);
+      JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", false, MySLSBean.class, BusinessInterface.class);
+      ear.addModule(ejbJar2);
+      MockArchiveManifest.addManifest(ear);
+      DeploymentUnit unit = assertDeploy(ear);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+      Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
+      Class<?> businessInterface = getClass(BusinessInterface.class, unit);
+      
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      BeanDeploymentArchive bda = deployment.loadBeanDeploymentArchive(plainJavaBeanClass);
+      assertBDAId(bda, EAR_NAME);
+      assertExpectedClasses(bda, PlainJavaBean.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertBDAId(bda, EAR_NAME);
+      assertExpectedClasses(bda, PlainJavaBean.class, MySLSBean.class);
+      // make sure double invocation does not affect the bda contents
+      assertSame(bda, deployment.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertBDAId(bda, EAR_NAME);
+      assertExpectedClasses(bda, PlainJavaBean.class, MySLSBean.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(businessInterface));
+      assertSame(bda, deployment.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertBDAId(bda, EAR_NAME);
+      assertExpectedClasses(bda, PlainJavaBean.class, MySLSBean.class, BusinessInterface.class);
+   }
+   
+   public void testEjbJarsInEars() throws Exception
+   {
+      // simple1.ear
+      EnterpriseArchive ear1 = ShrinkWrap.create(EnterpriseArchive.class, "simple1.ear");
+      JavaArchive ejbJar1 = createEjbJar("ejbJar1.jar", true, PlainJavaBean.class);
+      ear1.addModule(ejbJar1);
+      MockArchiveManifest.addManifest(ear1);
+      DeploymentUnit unit = assertDeploy(ear1);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+      Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      // simple2.ear
+      EnterpriseArchive ear2 = ShrinkWrap.create(EnterpriseArchive.class, "simple2.ear");
+      JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", true, MySLSBean.class, BusinessInterface.class);
+      ear2.addModule(ejbJar2);
+      MockArchiveManifest.addManifest(ear2);
+      unit = assertDeploy(ear2);
+      Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
+      Class<?> businessInterface = getClass(BusinessInterface.class, unit);
+      Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      
+      BeanDeploymentArchive bda1 = deployment1.getBeanDeploymentArchives().iterator().next();
+      BeanDeploymentArchive bda2 = deployment2.getBeanDeploymentArchives().iterator().next();
+      // double invocation should yield the same result
+      assertSame(bda1, deployment1.loadBeanDeploymentArchive(plainJavaBeanClass));
+      assertSame(bda1, deployment1.loadBeanDeploymentArchive(plainJavaBeanClass));
+      
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertSame(bda2, deployment1.loadBeanDeploymentArchive(businessInterface));
+      
+      assertSame(bda1, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
+      assertSame(bda1, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(businessInterface));
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(businessInterface));
+   }
+   
+   
+   public void testMixedEjbJarsInEars() throws Exception
+   {
+      // simple1.ear
+      EnterpriseArchive ear1 = ShrinkWrap.create(EnterpriseArchive.class, "simple1.ear");
+      JavaArchive ejbJar1 = createEjbJar("ejbJar1.jar", false, PlainJavaBean.class);
+      ear1.addModule(ejbJar1);
+      MockArchiveManifest.addManifest(ear1);
+      DeploymentUnit unit = assertDeploy(ear1);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+
+      // simple2.ear
+      EnterpriseArchive ear2 = ShrinkWrap.create(EnterpriseArchive.class, "simple2.ear");
+      JavaArchive ejbJar2 = createEjbJar("ejbJar2.jar", true, MySLSBean.class, BusinessInterface.class);
+      ear2.addModule(ejbJar2);
+      MockArchiveManifest.addManifest(ear2);
+      unit = assertDeploy(ear2);
+      Class<?> mySLSBeanClass = getClass(MySLSBean.class, unit);
+      Class<?> businessInterface = getClass(BusinessInterface.class, unit);
+      Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      
+      BeanDeploymentArchive bda2 = deployment2.getBeanDeploymentArchives().iterator().next();
+      // contents of BDA2
+      assertBDAId(bda2, "simple2.ear");
+      assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
+      // call loadBDA
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(mySLSBeanClass));
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(businessInterface));
+      // make sure that loadBDA did not change the contents of BDA2
+      assertBDAId(bda2, "simple2.ear");
+      assertExpectedClasses(bda2, MySLSBean.class, BusinessInterface.class);
+      
+      // creation of bda1 on demand
+      BeanDeploymentArchive bda1 = deployment2.loadBeanDeploymentArchive(plainJavaBeanClass);
+      assertBDAId(bda1, "simple1.ear");
+      assertExpectedClasses(bda1, PlainJavaBean.class);
+      assertExpectedResources(bda1);
+      // double invocation
+      assertSame(bda1, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
+      assertBDAId(bda1, "simple1.ear");
+      assertExpectedClasses(bda1, PlainJavaBean.class);
+      assertExpectedResources(bda1);
+   }
+   
+   public void testWars() throws Exception
+   {
+      WebArchive war1 = createWar("simple1.war", true, ServletWebBean.class);
+      DeploymentUnit unit = assertDeploy(war1);
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
+      Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+
+      WebArchive war2 = createWar("simple2.war", true, NotWBJsfBean.class);
+      unit = assertDeploy(war2);
+      Class<?> notWBJsfBeanClass = getClass(NotWBJsfBean.class, unit);
+      Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+
+      assertCannotLoadBDA(deployment1, notWBJsfBeanClass);
+      assertCannotLoadBDA(deployment2, servletWebBeanClass);
+      
+      BeanDeploymentArchive bda1 = deployment1.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(bda1, "simple1.war");
+      assertExpectedClasses(bda1, ServletWebBean.class);
+      assertSame(bda1, deployment1.loadBeanDeploymentArchive(servletWebBeanClass));
+      // make sure loadBDA didn't change the bda structure
+      assertBDAId(bda1, "simple1.war");
+      assertExpectedClasses(bda1, ServletWebBean.class);
+      
+      BeanDeploymentArchive bda2 = deployment2.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(bda2, "simple2.war");
+      assertExpectedClasses(bda2, NotWBJsfBean.class);
+      assertSame(bda2, deployment2.loadBeanDeploymentArchive(notWBJsfBeanClass));
+      // make sure loadBDA didn't change the bda structure
+      assertBDAId(bda2, "simple2.war");
+      assertExpectedClasses(bda2, NotWBJsfBean.class);
+   }
+   
+   public void testMixedWars() throws Exception
+   {
+      WebArchive war1 = createWar("simple1.war", true, ServletWebBean.class);
+      DeploymentUnit unit = assertDeploy(war1);
+      Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+
+      WebArchive war2 = createWar("simple2.war", false, NotWBJsfBean.class);
+      unit = assertDeploy(war2);
+      Class<?> notWBJsfBeanClass = getClass(NotWBJsfBean.class, unit);
+
+      assertCannotLoadBDA(deployment1, notWBJsfBeanClass);
+   }
+   
+   public void testWarWithLib() throws Exception
+   {
+      WebArchive war = createWarWithLib(true, true);
+      DeploymentUnit unit = assertDeploy(war);
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
+      Class<?> uiWebBeanClass = getClass(UIWebBean.class, unit);
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      
+      BeanDeploymentArchive bda = deployment.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(servletWebBeanClass));
+      assertSame(bda, deployment.loadBeanDeploymentArchive(uiWebBeanClass));
+      // make sure bda is unchanged
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+   }
+   
+   public void testWarWithLibWithoutXml() throws Exception
+   {
+      WebArchive war = createWarWithLib(true, false);
+      DeploymentUnit unit = assertDeploy(war);
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
+      Class<?> uiWebBeanClass = getClass(UIWebBean.class, unit);
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      
+      BeanDeploymentArchive bda = deployment.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(servletWebBeanClass));
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(uiWebBeanClass));
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+      // duplicate call makes no difference in the bda contents
+      assertSame(bda, deployment.loadBeanDeploymentArchive(uiWebBeanClass));
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+   }
+   
+   public void testWarWithoutXmlWithLib() throws Exception
+   {
+      WebArchive war = createWarWithLib(false, true);
+      DeploymentUnit unit = assertDeploy(war);
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
+      Class<?> uiWebBeanClass = getClass(UIWebBean.class, unit);
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      
+      BeanDeploymentArchive bda = deployment.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, UIWebBean.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(servletWebBeanClass));
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+      // duplicate call makes no difference in the bda contents
+      assertSame(bda, deployment.loadBeanDeploymentArchive(servletWebBeanClass));
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(uiWebBeanClass));
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+   }
+   
+   public void testWarWithMixedLibs() throws Exception
+   {
+      WebArchive war = createWarWithLibs(true, true, false);
+      DeploymentUnit unit = assertDeploy(war);
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
+      Class<?> uiWebBeanClass = getClass(UIWebBean.class, unit);
+      Class<?> crmWebBeanClass = getClass(CrmWebBean.class, unit);
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      
+      BeanDeploymentArchive bda = deployment.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(servletWebBeanClass));
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(uiWebBeanClass));
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+      assertSame(bda, deployment.loadBeanDeploymentArchive(crmWebBeanClass));
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class, CrmWebBean.class);
+      // duplicate call makes no difference in the bda contents
+      assertSame(bda, deployment.loadBeanDeploymentArchive(crmWebBeanClass));
+      assertBDAId(bda, WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class, CrmWebBean.class);
+   }
+   
+
+   public void testWarInEars() throws Exception
+   {
+      EnterpriseArchive ear1 = ShrinkWrap.create(EnterpriseArchive.class, "warinear1.ear");
+      WebArchive war1 = createWar(true);
+      ear1.addModule(war1);
+      MockArchiveManifest.addManifest(ear1);
+      DeploymentUnit unit = assertDeploy(ear1);
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit.getChildren().iterator().next());
+      Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      
+      EnterpriseArchive ear2 = ShrinkWrap.create(EnterpriseArchive.class, "warinear2.ear");
+      WebArchive war2 = createWar(WAR_NAME, true, NotWBJsfBean.class);
+      ear2.addModule(war2);
+      MockArchiveManifest.addManifest(ear2);
+      unit = assertDeploy(ear2);
+      Class<?> notWBJsfBeanClass = getClass(NotWBJsfBean.class, unit.getChildren().iterator().next());
+      Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      
+      assertCannotLoadBDA(deployment1, notWBJsfBeanClass);
+      assertCannotLoadBDA(deployment2, servletWebBeanClass);
+   }
+
+   public void testWarsInEar() throws Exception
+   {
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "warinear.ear");
+      WebArchive war1 = createWar("simple1.war", true, ServletWebBean.class);
+      ear.addModule(war1);
+      WebArchive war2 = createWar("simple2.war", true, NotWBJsfBean.class);
+      ear.addModule(war2);
+      MockArchiveManifest.addManifest(ear);
+      DeploymentUnit unit = assertDeploy(ear);
+      Iterator<DeploymentUnit> iterator = unit.getChildren().iterator();
+      DeploymentUnit unit1 = iterator.next();
+      DeploymentUnit unit2 = iterator.next();
+      if (unit2.getName().contains("simple1.war"))
+      {
+         DeploymentUnit temp = unit2;
+         unit2 = unit1;
+         unit1 = temp;
+      }
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit1);
+      Class<?> notWBJsfBeanClass = getClass(NotWBJsfBean.class, unit2);
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      
+      BeanDeploymentArchive bda1 = deployment.loadBeanDeploymentArchive(servletWebBeanClass);
+      assertBDAId(bda1, "warinear.ear/simple1.war");
+      assertExpectedClasses(bda1, ServletWebBean.class);
+      
+      BeanDeploymentArchive bda2 = deployment.loadBeanDeploymentArchive(notWBJsfBeanClass);
+      assertBDAId(bda2, "warinear.ear/simple2.war");
+      assertExpectedClasses(bda2, NotWBJsfBean.class);
+   }
+   
+   public void testEjbJar_War() throws Exception
+   {
+      // ejb.jar
+      JavaArchive ejbJar = createEjbJar(true);
+      DeploymentUnit unit = assertDeploy(ejbJar);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+      Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      // simple.war
+      WebArchive war = createWar(true);
+      unit = assertDeploy(war);
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
+      Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      
+      assertCannotLoadBDA(deployment1, servletWebBeanClass);
+      
+      BeanDeploymentArchive bda = deployment1.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(bda, EJB_JAR_NAME);
+      assertExpectedClasses(bda, PlainJavaBean.class);
+      assertSame(bda, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
+      // make sure bda contents are unchanged
+      assertBDAId(bda, EJB_JAR_NAME);
+      assertExpectedClasses(bda, PlainJavaBean.class);
+   }
+   
+   public void testEjbJarAndWarInEar() throws Exception
+   {
+      // ejb.jar
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
+      JavaArchive ejbJar = createEjbJar(true);
+      ear.addModule(ejbJar);
+      // simple.war
+      WebArchive war = createWar(true);
+      ear.addModule(war);
+      MockArchiveManifest.addManifest(ear);
+      DeploymentUnit unit = assertDeploy(ear);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+      Iterator<DeploymentUnit> iterator = unit.getChildren().iterator();
+      DeploymentUnit warUnit = null;
+      do
+      {
+         warUnit = iterator.next();
+      } while (!warUnit.getName().contains(WAR_NAME));
+      
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, warUnit);
+      Deployment deployment = (Deployment) getBean(Deployment.class);
+      
+      
+      BeanDeploymentArchive bda = deployment.loadBeanDeploymentArchive(plainJavaBeanClass);
+      assertBDAId(bda, EAR_NAME);
+      assertExpectedClasses(bda, PlainJavaBean.class);
+      
+      bda = deployment.loadBeanDeploymentArchive(servletWebBeanClass);
+      assertBDAId(bda, EAR_NAME + "/" + WAR_NAME);
+      assertExpectedClasses(bda, ServletWebBean.class);
+   }
+   
+   public void testEjbJarInEar_War() throws Exception
+   {
+      // ejb.jar
+      EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
+      JavaArchive ejbJar = createEjbJar(true);
+      ear.addModule(ejbJar);
+      MockArchiveManifest.addManifest(ear);
+      DeploymentUnit unit = assertDeploy(ear);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+      Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      // simple.war
+      WebArchive war = createWar(true);
+      unit = assertDeploy(war);
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, unit);
+      Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      
+      assertCannotLoadBDA(deployment1, servletWebBeanClass);
+      
+      BeanDeploymentArchive bda = deployment1.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(bda, EAR_NAME);
+      assertExpectedClasses(bda, PlainJavaBean.class);
+      assertSame(bda, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
+      // make sure bda contents are unchanged
+      assertBDAId(bda, EAR_NAME);
+      assertExpectedClasses(bda, PlainJavaBean.class);
+   }
+   
+   
+   public void testEjbJarInEar_WarWithLibInEar() throws Exception
+   {
+      // ejb.ear
+      EnterpriseArchive ejbEar = ShrinkWrap.create(EnterpriseArchive.class, "ejb.ear");
+      JavaArchive ejbJar = createEjbJar(true);
+      ejbEar.addModule(ejbJar);
+      MockArchiveManifest.addManifest(ejbEar);
+      DeploymentUnit unit = assertDeploy(ejbEar);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, unit);
+      Deployment deployment1 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      // war.ear
+      EnterpriseArchive warEar = ShrinkWrap.create(EnterpriseArchive.class, "war.ear");
+      WebArchive war = createWarWithLib(true, false);
+      warEar.addModule(war);
+      MockArchiveManifest.addManifest(warEar);
+      unit = assertDeploy(warEar);
+      DeploymentUnit warUnit = unit.getChildren().iterator().next();
+      Class<?> servletWebBeanClass = getClass(ServletWebBean.class, warUnit);
+      Class<?> uiWebBeanClass = getClass(UIWebBean.class, warUnit);
+      Deployment deployment2 = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(unit));
+      
+      assertCannotLoadBDA(deployment1, servletWebBeanClass);
+      
+      BeanDeploymentArchive bda = deployment1.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(bda, "ejb.ear");
+      assertExpectedClasses(bda, PlainJavaBean.class);
+      assertSame(bda, deployment2.loadBeanDeploymentArchive(plainJavaBeanClass));
+      // make sure bda contents are unchanged
+      assertBDAId(bda, "ejb.ear");
+      assertExpectedClasses(bda, PlainJavaBean.class);
+      
+      bda = deployment2.loadBeanDeploymentArchive(servletWebBeanClass);
+      String bdaName = "war.ear/" + WAR_NAME;
+      assertBDAId(bda, bdaName);
+      assertExpectedClasses(bda, ServletWebBean.class);
+      
+      BeanDeploymentArchive bda2 = deployment2.loadBeanDeploymentArchive(uiWebBeanClass);
+      assertSame(bda, bda2);
+      assertBDAId(bda, bdaName);
+      assertExpectedClasses(bda, ServletWebBean.class, UIWebBean.class);
+   }
+   
+   public void testMultipleArchives() throws Exception
+   {
+      WebArchive war1 = createWar("web1.war", true, ServletWebBean.class);
+      DeploymentUnit war1Unit = assertDeploy(war1);
+      Deployment war1Deployment = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(war1Unit));
+      BeanDeploymentArchive war1BDA = war1Deployment.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(war1BDA, "web1.war");
+      assertExpectedClasses(war1BDA, ServletWebBean.class);
+      Class<?> servletWebBeanWar1Class = getClass(ServletWebBean.class, war1Unit);
+      
+      WebArchive war2 = createWar("web2.war", true, NotWBJsfBean.class);
+      createLib(war2, "crm.jar", false, CrmWebBean.class);
+      DeploymentUnit war2Unit = assertDeploy(war2);
+      Deployment war2Deployment = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(war2Unit));
+      BeanDeploymentArchive war2BDA = war2Deployment.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(war2BDA, "web2.war");
+      assertExpectedClasses(war2BDA, NotWBJsfBean.class);
+      Class<?> notWBJsfBeanWar2Class = getClass(NotWBJsfBean.class, war2Unit);
+      Class<?> crmWebBeanWar2Class = getClass(CrmWebBean.class, war2Unit);
+      
+      JavaArchive ejbJar = createEjbJar("ejb.jar", true, BusinessInterface.class);
+      DeploymentUnit ejbJarUnit = assertDeploy(ejbJar);
+      Deployment ejbJarDeployment = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(ejbJarUnit));
+      BeanDeploymentArchive ejbJarBDA = ejbJarDeployment.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(ejbJarBDA, "ejb.jar");
+      assertExpectedClasses(ejbJarBDA, BusinessInterface.class);
+      Class<?> businessInterfaceClass = getClass(BusinessInterface.class, ejbJarUnit);
+      
+      EnterpriseArchive ear1 = ShrinkWrap.create(EnterpriseArchive.class, "full.ear");
+      WebArchive warInEar1 = createWarWithLibs(false, true, true);
+      ear1.addModule(warInEar1);
+      ear1.addModule(war2);
+      JavaArchive ejbJarInEar1 = createEjbJar("ejbInFullEar.jar", false, MySLSBean.class);
+      ear1.addModule(ejbJarInEar1);
+      createLib(ear1, "lib1.jar", false, ExternalWebBean.class);
+      createLib(ear1, "lib2.jar", true, A.class);
+      createLib(ear1, "lib3.jar", false, B.class);
+      MockArchiveManifest.addManifest(ear1);
+      DeploymentUnit ear1Unit = assertDeploy(ear1);
+      Deployment ear1Deployment = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(ear1Unit));
+      BeanDeploymentArchive ear1BDA = null, ear1War1BDA = null, ear1War2BDA = null;
+      for (BeanDeploymentArchive bda: ear1Deployment.getBeanDeploymentArchives())
+      {
+         if (bda.getId().contains(WAR_NAME))
+         {
+            ear1War1BDA = bda;
+         }
+         else if (bda.getId().contains("web2.war"))
+         {
+            ear1War2BDA = bda;
+         }
+         else
+         {
+            ear1BDA = bda;
+         }
+      }
+      assertBDAId(ear1BDA, "full.ear");
+      assertExpectedClasses(ear1BDA, A.class);
+      assertBDAId(ear1War1BDA, "full.ear/" + WAR_NAME);
+      assertExpectedClasses(ear1War1BDA, UIWebBean.class, CrmWebBean.class);
+      assertBDAId(ear1War2BDA, "full.ear/web2.war");
+      assertExpectedClasses(ear1War2BDA, NotWBJsfBean.class);
+      Class<?> servletWebBeanEar1Class = null, uiWebBeanEar1Class = null,
+               crmWebBeanEar1War1Class = null, notWBJsfBeanEar1Class = null,
+               crmWebBeanEar1War2Class = null;
+      for (DeploymentUnit ear1Child: ear1Unit.getChildren())
+      {
+         if (ear1Child.getName().contains(WAR_NAME))
+         {
+           servletWebBeanEar1Class = getClass(ServletWebBean.class, ear1Child);
+           uiWebBeanEar1Class = getClass(UIWebBean.class, ear1Child);
+           crmWebBeanEar1War1Class = getClass(CrmWebBean.class, ear1Child);
+         }
+         else if (ear1Child.getName().contains("web2.war"))
+         {
+            notWBJsfBeanEar1Class = getClass(NotWBJsfBean.class, ear1Child);
+            crmWebBeanEar1War2Class = getClass(CrmWebBean.class, ear1Child);
+         }
+      }
+      Class<?> externalWebBeanClass = getClass(ExternalWebBean.class, ear1Unit);
+      Class<?> aClass = getClass(A.class, ear1Unit);
+      Class<?> bClass = getClass(B.class, ear1Unit);
+      
+      EnterpriseArchive ear2 = ShrinkWrap.create(EnterpriseArchive.class, "ejbWLibs.ear");
+      JavaArchive ejbJarInEar2 = createEjbJar("ejbInEar2.jar", true, PlainJavaBean.class);
+      ear2.addModule(ejbJarInEar2);
+      createLib(ear2, "lib1.jar", false, SomeUtil.class);
+      createLib(ear2, "lib2.jar", true, CrmWebBean.class);
+      MockArchiveManifest.addManifest(ear2);
+      DeploymentUnit ear2Unit = assertDeploy(ear2);
+      Deployment ear2Deployment = (Deployment) getBean(DeployersUtils.getDeploymentBeanName(ear2Unit));
+      BeanDeploymentArchive ear2BDA = ear2Deployment.getBeanDeploymentArchives().iterator().next();
+      assertBDAId(ear2BDA, "ejbWLibs.ear");
+      assertExpectedClasses(ear2BDA, PlainJavaBean.class, CrmWebBean.class);
+      Class<?> plainJavaBeanClass = getClass(PlainJavaBean.class, ear2Unit);
+      Class<?> someUtilClass = getClass(SomeUtil.class, ear2Unit);
+      Class<?> crmWebBeanClass = getClass(CrmWebBean.class, ear2Unit);
+      
+      // Assert on web classes
+      
+      assertCannotLoadBDA(war1Deployment, servletWebBeanEar1Class);
+      assertCannotLoadBDA(war1Deployment, notWBJsfBeanWar2Class);
+      assertCannotLoadBDA(war1Deployment, notWBJsfBeanEar1Class);
+      assertCannotLoadBDA(war1Deployment, crmWebBeanWar2Class);
+      assertCannotLoadBDA(war1Deployment, crmWebBeanEar1War1Class);
+      assertCannotLoadBDA(war1Deployment, crmWebBeanEar1War2Class);
+      assertCannotLoadBDA(war1Deployment, uiWebBeanEar1Class);
+      BeanDeploymentArchive bda = war1Deployment.loadBeanDeploymentArchive(servletWebBeanWar1Class);
+      assertSame(war1BDA, bda);
+      // verify the absence of collateral effects on the BDA
+      assertBDAId(war1BDA, "web1.war");
+      assertExpectedClasses(war1BDA, ServletWebBean.class);
+      
+      assertCannotLoadBDA(war2Deployment, servletWebBeanWar1Class);
+      assertCannotLoadBDA(war2Deployment, servletWebBeanEar1Class);
+      assertCannotLoadBDA(war2Deployment, notWBJsfBeanEar1Class);
+      assertCannotLoadBDA(war2Deployment, crmWebBeanEar1War1Class);
+      assertCannotLoadBDA(war2Deployment, crmWebBeanEar1War2Class);
+      assertCannotLoadBDA(war2Deployment, uiWebBeanEar1Class);
+      bda = war2Deployment.loadBeanDeploymentArchive(notWBJsfBeanWar2Class);
+      bda = war2Deployment.loadBeanDeploymentArchive(crmWebBeanWar2Class);
+      assertSame(war2BDA, bda);
+      assertBDAId(war2BDA, "web2.war");
+      assertExpectedClasses(war2BDA, NotWBJsfBean.class, CrmWebBean.class);
+      
+      assertCannotLoadBDA(ejbJarDeployment, servletWebBeanWar1Class);
+      assertCannotLoadBDA(ejbJarDeployment, servletWebBeanEar1Class);
+      assertCannotLoadBDA(ejbJarDeployment, notWBJsfBeanWar2Class);
+      assertCannotLoadBDA(ejbJarDeployment, notWBJsfBeanEar1Class);
+      assertCannotLoadBDA(ejbJarDeployment, crmWebBeanWar2Class);
+      assertCannotLoadBDA(ejbJarDeployment, crmWebBeanEar1War1Class);
+      assertCannotLoadBDA(ejbJarDeployment, crmWebBeanEar1War2Class);
+      assertCannotLoadBDA(ejbJarDeployment, uiWebBeanEar1Class);
+      
+      assertCannotLoadBDA(ear1Deployment, servletWebBeanWar1Class);
+      assertCannotLoadBDA(ear1Deployment, notWBJsfBeanWar2Class);
+      assertCannotLoadBDA(ear1Deployment, crmWebBeanWar2Class);
+      bda = ear1Deployment.loadBeanDeploymentArchive(servletWebBeanEar1Class);
+      assertSame(ear1War1BDA, bda);
+      bda = ear1Deployment.loadBeanDeploymentArchive(uiWebBeanEar1Class);
+      assertSame(ear1War1BDA, bda);
+      bda = ear1Deployment.loadBeanDeploymentArchive(crmWebBeanEar1War1Class);
+      assertSame(ear1War1BDA, bda);
+      assertBDAId(ear1War1BDA, "full.ear/" + WAR_NAME);
+      assertExpectedClasses(ear1War1BDA, ServletWebBean.class, UIWebBean.class, CrmWebBean.class);
+      
+      bda = ear1Deployment.loadBeanDeploymentArchive(notWBJsfBeanEar1Class);
+      assertSame(ear1War2BDA, bda);
+      bda = ear1Deployment.loadBeanDeploymentArchive(crmWebBeanEar1War2Class);
+      assertSame(ear1War2BDA, bda);
+      assertBDAId(ear1War2BDA, "full.ear/web2.war");
+      assertExpectedClasses(ear1War2BDA, NotWBJsfBean.class, CrmWebBean.class);
+      
+      assertCannotLoadBDA(ear2Deployment, servletWebBeanWar1Class);
+      assertCannotLoadBDA(ear2Deployment, servletWebBeanEar1Class);
+      assertCannotLoadBDA(ear2Deployment, notWBJsfBeanWar2Class);
+      assertCannotLoadBDA(ear2Deployment, notWBJsfBeanEar1Class);
+      assertCannotLoadBDA(ear2Deployment, crmWebBeanWar2Class);
+      assertCannotLoadBDA(ear2Deployment, crmWebBeanEar1War1Class);
+      assertCannotLoadBDA(ear2Deployment, crmWebBeanEar1War2Class);
+      assertCannotLoadBDA(ear2Deployment, uiWebBeanEar1Class);
+      
+      // Assert on business classes that are part of existing BDAs
+      bda = ejbJarDeployment.loadBeanDeploymentArchive(businessInterfaceClass);
+      assertSame(ejbJarBDA, bda);
+      war1Deployment.loadBeanDeploymentArchive(businessInterfaceClass);
+      assertSame(ejbJarBDA, bda);
+      war2Deployment.loadBeanDeploymentArchive(businessInterfaceClass);
+      assertSame(ejbJarBDA, bda);
+      ear1Deployment.loadBeanDeploymentArchive(businessInterfaceClass);
+      assertSame(ejbJarBDA, bda);
+      war2Deployment.loadBeanDeploymentArchive(businessInterfaceClass);
+      assertSame(ejbJarBDA, bda);
+      assertBDAId(ejbJarBDA, "ejb.jar"); // no collateral effects on the BDA
+      assertExpectedClasses(ejbJarBDA, BusinessInterface.class);
+      
+      bda = ear1Deployment.loadBeanDeploymentArchive(aClass);
+      assertSame(ear1BDA, bda);
+      bda = war1Deployment.loadBeanDeploymentArchive(aClass);
+      assertSame(ear1BDA, bda);
+      bda = war2Deployment.loadBeanDeploymentArchive(aClass);
+      assertSame(ear1BDA, bda);
+      bda = ejbJarDeployment.loadBeanDeploymentArchive(aClass);
+      assertSame(ear1BDA, bda);
+      bda = ear2Deployment.loadBeanDeploymentArchive(aClass);
+      assertSame(ear1BDA, bda);
+      assertBDAId(ear1BDA, "full.ear"); // no collateral effects on the BDA
+      assertExpectedClasses(ear1BDA, A.class);
+      
+      bda = ear2Deployment.loadBeanDeploymentArchive(plainJavaBeanClass);
+      assertSame(ear2BDA, bda);
+      bda = ear2Deployment.loadBeanDeploymentArchive(crmWebBeanClass);
+      assertSame(ear2BDA, bda);
+      bda = war1Deployment.loadBeanDeploymentArchive(plainJavaBeanClass);
+      assertSame(ear2BDA, bda);
+      bda = war1Deployment.loadBeanDeploymentArchive(crmWebBeanClass);
+      assertSame(ear2BDA, bda);
+      bda = war2Deployment.loadBeanDeploymentArchive(plainJavaBeanClass);
+      assertSame(ear2BDA, bda);
+      bda = war2Deployment.loadBeanDeploymentArchive(crmWebBeanClass);
+      assertSame(ear2BDA, bda);
+      bda = ejbJarDeployment.loadBeanDeploymentArchive(plainJavaBeanClass);
+      assertSame(ear2BDA, bda);
+      bda = ejbJarDeployment.loadBeanDeploymentArchive(crmWebBeanClass);
+      assertSame(ear2BDA, bda);
+      bda = ear1Deployment.loadBeanDeploymentArchive(plainJavaBeanClass);
+      assertSame(ear2BDA, bda);
+      bda = ear1Deployment.loadBeanDeploymentArchive(crmWebBeanClass);
+      assertSame(ear2BDA, bda);
+      assertBDAId(ear2BDA, "ejbWLibs.ear"); // no collateral effects on the BDA
+      assertExpectedClasses(ear2BDA, PlainJavaBean.class, CrmWebBean.class);
+      
+      // Assert on business classes that are not yet part of existing BDAs
+      bda = war1Deployment.loadBeanDeploymentArchive(externalWebBeanClass);
+      assertSame(ear1BDA, bda);
+      assertBDAId(ear1BDA, "full.ear");
+      assertExpectedClasses(ear1BDA, ExternalWebBean.class, A.class);
+      bda = war2Deployment.loadBeanDeploymentArchive(externalWebBeanClass);
+      assertSame(ear1BDA, bda);
+      bda = ejbJarDeployment.loadBeanDeploymentArchive(externalWebBeanClass);
+      assertSame(ear1BDA, bda);
+      bda = ear1Deployment.loadBeanDeploymentArchive(externalWebBeanClass);
+      assertSame(ear1BDA, bda);
+      bda = ear2Deployment.loadBeanDeploymentArchive(externalWebBeanClass);
+      assertSame(ear1BDA, bda);
+      assertBDAId(ear1BDA, "full.ear"); // no collateral effects on the BDA
+      assertExpectedClasses(ear1BDA, ExternalWebBean.class, A.class);
+      
+      bda = ear1Deployment.loadBeanDeploymentArchive(bClass);
+      assertSame(ear1BDA, bda);
+      assertBDAId(ear1BDA, "full.ear");
+      assertExpectedClasses(ear1BDA, ExternalWebBean.class, A.class, B.class);
+      bda = war1Deployment.loadBeanDeploymentArchive(bClass);
+      assertSame(ear1BDA, bda);
+      bda = war2Deployment.loadBeanDeploymentArchive(bClass);
+      assertSame(ear1BDA, bda);
+      bda = ejbJarDeployment.loadBeanDeploymentArchive(bClass);
+      assertSame(ear1BDA, bda);
+      bda = ear2Deployment.loadBeanDeploymentArchive(bClass);
+      assertSame(ear1BDA, bda);
+      assertBDAId(ear1BDA, "full.ear"); // no collateral effects on the BDA
+      assertExpectedClasses(ear1BDA, ExternalWebBean.class, A.class, B.class);
+
+      bda = ejbJarDeployment.loadBeanDeploymentArchive(someUtilClass);
+      assertSame(ear2BDA, bda);
+      assertBDAId(ear2BDA, "ejbWLibs.ear");
+      assertExpectedClasses(ear2BDA, PlainJavaBean.class, SomeUtil.class, CrmWebBean.class);
+      bda = war1Deployment.loadBeanDeploymentArchive(someUtilClass);
+      assertSame(ear2BDA, bda);
+      bda = war2Deployment.loadBeanDeploymentArchive(someUtilClass);
+      assertSame(ear2BDA, bda);
+      bda = ear1Deployment.loadBeanDeploymentArchive(someUtilClass);
+      assertSame(ear2BDA, bda);
+      bda = ear2Deployment.loadBeanDeploymentArchive(someUtilClass);
+      assertSame(ear2BDA, bda);
+      assertBDAId(ear2BDA, "ejbWLibs.ear"); // no collateraleffects on the BDA
+      assertExpectedClasses(ear2BDA, PlainJavaBean.class, SomeUtil.class, CrmWebBean.class);
+   }
+
+   @Override
+   protected Collection<Class<?>> getClasses(BeanDeploymentArchive bda)
+   {
+      return bda.getBeanClasses();
+   }
+
+   @Override
+   protected Collection<URL> getResources(BeanDeploymentArchive bda)
+   {
+      return bda.getBeansXml();
+   }
+   
+   private void assertBDAId(BeanDeploymentArchive bda, String name)
+   {
+      assertTrue("BDA id \""  + bda.getId() + "\" expected to end with suffix \"" + name + "/}\"",
+               bda.getId().endsWith(name + "/}"));
+   }
+
+   private Class<?> getClass(Class<?> clazz, DeploymentUnit unit) throws ClassNotFoundException
+   {
+      ClassLoader classLoader = unit.getClassLoader();
+      return classLoader.loadClass(clazz.getName());
+   }
+   
+   private void assertCannotLoadBDA(Deployment deployment, Class<?> beanClass)
+   {
+      boolean failed = false;
+      try
+      {
+         deployment.loadBeanDeploymentArchive(beanClass);
+      }
+      catch (IllegalArgumentException e)
+      {
+         failed = true;
+      }
+      assertTrue(failed);
+   }
+}
\ No newline at end of file

Copied: branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.xml (from rev 107515, trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.xml)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.xml	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/ArchiveEnvironmentTestCase.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,14 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
+  <bean name="WarStructure" class="org.jboss.test.deployers.vfs.structure.war.support.MockWarStructureDeployer"/>
+  <bean name="WarClassLoader" class="org.jboss.test.deployers.vfs.reflect.support.MockWarClassLoaderDeployer"/>
+
+  <bean name="JWBMDDeployer" class="org.jboss.weld.integration.deployer.ext.JBossWeldMetaDataDeployer"/>
+  <bean name="WBFilesDeployer" class="org.jboss.weld.integration.deployer.metadata.WeldFilesDeployer"/>
+  <bean name="ArchiveInfoDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveInfoDeployer"/>
+
+  <!--  Target of the Test -->
+  <bean name="ArchiveDiscoveryDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveDiscoveryDeployer"/>
+
+</deployment>

Copied: branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.xml (from rev 107515, trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.xml)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.xml	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/ArchiveInfoDeploymentTestCase.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,10 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
+  <bean name="WarStructure" class="org.jboss.test.deployers.vfs.structure.war.support.MockWarStructureDeployer"/>
+  <bean name="WarClassLoader" class="org.jboss.test.deployers.vfs.reflect.support.MockWarClassLoaderDeployer"/>
+
+  <!--  Target of the Test -->
+  <bean name="ArchiveInfoDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveInfoDeployer"/>
+
+</deployment>

Copied: branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.xml (from rev 107515, trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.xml)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.xml	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,33 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
+  <bean name="WarStructure" class="org.jboss.test.deployers.vfs.structure.war.support.MockWarStructureDeployer"/>
+  <bean name="WarClassLoader" class="org.jboss.test.deployers.vfs.reflect.support.MockWarClassLoaderDeployer"/>
+
+  <bean name="JWBMDDeployer" class="org.jboss.weld.integration.deployer.ext.JBossWeldMetaDataDeployer"/>
+  <bean name="WBFilesDeployer" class="org.jboss.weld.integration.deployer.metadata.WeldFilesDeployer"/>
+  <bean name="ArchiveInfoDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveInfoDeployer"/>
+  <bean name="ArchiveDiscoveryDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveDiscoveryDeployer"/>
+
+  <beanfactory name="JBossEjbServices" class="org.jboss.test.deployers.support.MockEmptyEjbServices"/>
+
+  <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer">
+    <property name="ejbServicesClassName">org.jboss.test.deployers.support.MockEmptyEjbServices</property>
+  </bean>
+
+  <!-- Target of the Test -->
+  <bean name="DeploymentDeployer" class="org.jboss.weld.integration.deployer.env.JBossDeploymentDeployer"/>
+
+  <bean name="BootDeployer" class="org.jboss.test.deployers.support.deployer.MockBootDeployer"/>
+
+  <bean name="DynamicDependencyCreator" class="org.jboss.weld.integration.deployer.env.DynamicDependencyCreator">
+    <constructor>
+      <parameter><inject bean="jboss.kernel:service=KernelController"/></parameter>
+    </constructor>
+  </bean>
+
+  <bean name="JBossTransactionServices" class="org.jboss.test.deployers.support.MockTransactionServices"/>
+
+  <bean name="RealTransactionManager" class="java.lang.Object"/>
+
+</deployment>

Copied: branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/DeploymentEnvironmentTestCase.xml (from rev 107515, trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/DeploymentEnvironmentTestCase.xml)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/DeploymentEnvironmentTestCase.xml	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/DeploymentEnvironmentTestCase.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,33 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
+  <bean name="WarStructure" class="org.jboss.test.deployers.vfs.structure.war.support.MockWarStructureDeployer"/>
+  <bean name="WarClassLoader" class="org.jboss.test.deployers.vfs.reflect.support.MockWarClassLoaderDeployer"/>
+
+  <bean name="JWBMDDeployer" class="org.jboss.weld.integration.deployer.ext.JBossWeldMetaDataDeployer"/>
+  <bean name="WBFilesDeployer" class="org.jboss.weld.integration.deployer.metadata.WeldFilesDeployer"/>
+  <bean name="ArchiveInfoDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveInfoDeployer"/>
+  <bean name="ArchiveDiscoveryDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveDiscoveryDeployer"/>
+
+  <beanfactory name="JBossEjbServices" class="org.jboss.test.deployers.support.MockEmptyEjbServices"/>
+
+  <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer">
+    <property name="ejbServicesClassName">org.jboss.test.deployers.support.MockEmptyEjbServices</property>
+  </bean>
+
+  <!-- Target of the Test -->
+  <bean name="DeploymentDeployer" class="org.jboss.weld.integration.deployer.env.JBossDeploymentDeployer"/>
+
+  <bean name="BootDeployer" class="org.jboss.test.deployers.support.deployer.MockBootDeployer"/>
+
+  <bean name="DynamicDependencyCreator" class="org.jboss.weld.integration.deployer.env.DynamicDependencyCreator">
+    <constructor>
+      <parameter><inject bean="jboss.kernel:service=KernelController"/></parameter>
+    </constructor>
+  </bean>
+
+  <bean name="JBossTransactionServices" class="org.jboss.test.deployers.support.MockTransactionServices"/>
+
+  <bean name="RealTransactionManager" class="java.lang.Object"/>
+
+</deployment>

Copied: branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/JBossDeploymentSmokeTestCase.xml (from rev 107515, trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/JBossDeploymentSmokeTestCase.xml)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/JBossDeploymentSmokeTestCase.xml	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/JBossDeploymentSmokeTestCase.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,64 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <!-- Structure mocks -->
+
+  <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
+  <bean name="WarStructure" class="org.jboss.test.deployers.vfs.structure.war.support.MockWarStructureDeployer"/>
+
+  <!-- Mock metadata deployer -->
+
+  <bean name="JBAppMDDeployer" class="org.jboss.test.deployers.support.deployer.MockJBossAppDeployer"/>
+  <bean name="JBWMDDeployer" class="org.jboss.test.deployers.support.deployer.MockWebDeployer"/>
+  <bean name="EjbJarDeployer" class="org.jboss.test.deployers.support.deployer.MockEjbJarDeployer"/>
+  <bean name="EjbMergeDeployer" class="org.jboss.test.deployers.support.deployer.MockCopyJBossDeployer"/>
+  <bean name="WarCLDeployer" class="org.jboss.test.deployers.support.deployer.MockWarClassLoaderDeployer"/>
+
+  <!-- Weld deployers -->
+
+  <!-- Responsible for discovering Weld files -->
+  <bean name="WeldFilesDeployer" class="org.jboss.weld.integration.deployer.metadata.WeldFilesDeployer"/>
+
+  <!-- Responsible for creating an ArchiveInfo for every module -->
+  <bean name="ArchiveInfoDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveInfoDeployer"/>
+
+  <!-- Responsible for discovering Weld classes -->
+  <bean name="DiscoveryDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveDiscoveryDeployer"/>
+
+  <!-- Responsible for discovering Weld classes -->
+  <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer"/>
+
+  <!-- Responsible for generating metadata for the creation of a Deployment -->
+  <bean name="DeploymentDeployer" class="org.jboss.weld.integration.deployer.env.JBossDeploymentDeployer"/>
+
+  <!-- Responsible for dynamic ejb dependency creation -->
+  <bean name="DynamicDependencyCreator" class="org.jboss.weld.integration.deployer.env.DynamicDependencyCreator">
+    <constructor>
+      <parameter><inject bean="jboss.kernel:service=KernelController"/></parameter>
+    </constructor>
+  </bean>
+
+  <!-- Responsible for booting Weld -->
+  <bean name="WeldBootstrapDeployer" class="org.jboss.weld.integration.deployer.env.WeldBootstrapDeployer"/>
+
+  <!-- Binds bootstrap to jndi -->
+  <bean name="JndiBinderDeployer" class="org.jboss.test.deployers.support.deployer.MockJndiBinderDeployer"/>
+
+  <!-- Missing real URL integration tests-->
+
+  <bean name="MockUrlIntegrationDeployer" class="org.jboss.test.deployers.support.deployer.MockUrlIntegrationDeployer"/>
+
+  <!-- Responsible for inserting the Weld EJB interceptor -->
+  <bean name="PostEjbJarMetadataDeployer" class="org.jboss.weld.integration.deployer.metadata.WeldEjbInterceptorMetadataDeployer"/>
+
+  <!-- Responsible for enabling classloader isolation for Weld jars -->
+  <bean name="PostJBossMetadataDeployer" class="org.jboss.weld.integration.deployer.metadata.PostJBossMetadataDeployer"/>
+
+  <!-- Responsible for enabling classloader isolation for Weld wars -->
+  <bean name="PostJBossWebMetadataDeployer" class="org.jboss.weld.integration.deployer.metadata.PostJBossWebMetadataDeployer"/>
+
+  <!-- Responsible for adding the Weld listener to the Servlet -->
+  <bean name="PostWebMetadataDeployer" class="org.jboss.weld.integration.deployer.metadata.PostWebMetadataDeployer"/>
+
+  <!-- Removed WeldJndiBinder -->
+
+</deployment>

Copied: branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.xml (from rev 107515, trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.xml)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.xml	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/LoadBeanDeploymentArchiveTestCase.xml	2010-08-10 15:04:17 UTC (rev 107524)
@@ -0,0 +1,33 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="EarStructure" class="org.jboss.test.deployers.vfs.structure.ear.support.MockEarStructureDeployer"/>
+  <bean name="WarStructure" class="org.jboss.test.deployers.vfs.structure.war.support.MockWarStructureDeployer"/>
+  <bean name="WarClassLoader" class="org.jboss.test.deployers.vfs.reflect.support.MockWarClassLoaderDeployer"/>
+
+  <bean name="JWBMDDeployer" class="org.jboss.weld.integration.deployer.ext.JBossWeldMetaDataDeployer"/>
+  <bean name="WBFilesDeployer" class="org.jboss.weld.integration.deployer.metadata.WeldFilesDeployer"/>
+  <bean name="ArchiveInfoDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveInfoDeployer"/>
+  <bean name="ArchiveDiscoveryDeployer" class="org.jboss.weld.integration.deployer.env.ArchiveDiscoveryDeployer"/>
+
+  <beanfactory name="JBossEjbServices" class="org.jboss.test.deployers.support.MockEmptyEjbServices"/>
+
+  <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer">
+    <property name="ejbServicesClassName">org.jboss.test.deployers.support.MockEmptyEjbServices</property>
+  </bean>
+
+  <!-- Target of the Test -->
+  <bean name="DeploymentDeployer" class="org.jboss.weld.integration.deployer.env.JBossDeploymentDeployer"/>
+
+  <bean name="BootDeployer" class="org.jboss.test.deployers.support.deployer.MockBootDeployer"/>
+
+  <bean name="DynamicDependencyCreator" class="org.jboss.weld.integration.deployer.env.DynamicDependencyCreator">
+    <constructor>
+      <parameter><inject bean="jboss.kernel:service=KernelController"/></parameter>
+    </constructor>
+  </bean>
+
+  <bean name="JBossTransactionServices" class="org.jboss.test.deployers.support.MockTransactionServices"/>
+
+  <bean name="RealTransactionManager" class="java.lang.Object"/>
+
+</deployment>



More information about the jboss-cvs-commits mailing list