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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 22 17:21:53 EDT 2010


Author: pferraro
Date: 2010-10-22 17:21:52 -0400 (Fri, 22 Oct 2010)
New Revision: 108837

Added:
   branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/
   branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/
   branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/application.xml
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/util/IdFactory.java
Removed:
   branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/
   branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/application.xml
Modified:
   branches/infinispan-int/build/build.xml
   branches/infinispan-int/component-matrix/pom.xml
   branches/infinispan-int/server/src/main/java/org/jboss/deployment/EARContentsDeployer.java
   branches/infinispan-int/system-jmx/src/main/java/org/jboss/deployment/MainDeployer.java
   branches/infinispan-int/testsuite/imports/sections/weld.xml
   branches/infinispan-int/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WebContainterIntegrationDeployer.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/BeanDeploymentArchiveImpl.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DUTopLevelClassLoaderGetter.java
   branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/JBossBeanDeploymentArchiveLocator.java
Log:
merge --depth=infinity -r108654:108785 from trunk

Modified: branches/infinispan-int/build/build.xml
===================================================================
--- branches/infinispan-int/build/build.xml	2010-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/build/build.xml	2010-10-22 21:21:52 UTC (rev 108837)
@@ -1971,6 +1971,7 @@
       <fileset refid="org.jboss.ws.projects:jaxws-httpserver-httpspi:jar"/>
       <fileset refid="org.jboss.netty:netty:jar"/>
       <fileset refid="commons-beanutils:commons-beanutils:jar"/>
+      <fileset refid="asm:asm:jar"/>
       <fileset refid="antlr:antlr:jar"/>
       <fileset refid="commons-collections:commons-collections:jar"/>
       <fileset refid="org.jboss.security:jboss-negotiation:jar"/>
@@ -2238,6 +2239,7 @@
     <!-- Copy the generated client libraries -->
     <mkdir dir="${install.client}"/>
     <copy todir="${install.client}" filtering="no">
+      <fileset refid="asm:asm:jar"/>
       <fileset refid="antlr:antlr:jar"/>
       <fileset refid="apache-xalan:xalan:jar"/>
       <fileset refid="apache-xalan:serializer:jar"/>

Modified: branches/infinispan-int/component-matrix/pom.xml
===================================================================
--- branches/infinispan-int/component-matrix/pom.xml	2010-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/component-matrix/pom.xml	2010-10-22 21:21:52 UTC (rev 108837)
@@ -51,11 +51,11 @@
     <version.jaxws-httpserver-httpspi>1.0.0.GA</version.jaxws-httpserver-httpspi>
     <version.jboss.jaxr>2.0.1</version.jboss.jaxr>
     <version.jboss.jbossts>4.11.0.Final</version.jboss.jbossts>
-    <version.jboss.jbossws-native>3.4.0.CR1</version.jboss.jbossws-native>
-    <version.jboss.jbossws-cxf>3.4.0.CR1</version.jboss.jbossws-cxf>
-    <version.jboss.jbossws-common>1.4.0.CR1</version.jboss.jbossws-common>
-    <version.jboss.jbossws-framework>3.4.0.CR1</version.jboss.jbossws-framework>
-    <version.jboss.jbossws-spi>1.4.0.CR1</version.jboss.jbossws-spi>
+    <version.jboss.jbossws-native>3.4.0.CR2</version.jboss.jbossws-native>
+    <version.jboss.jbossws-cxf>3.4.0.CR2</version.jboss.jbossws-cxf>
+    <version.jboss.jbossws-common>1.4.0.CR2</version.jboss.jbossws-common>
+    <version.jboss.jbossws-framework>3.4.0.CR2</version.jboss.jbossws-framework>
+    <version.jboss.jbossws-spi>1.4.0.CR2</version.jboss.jbossws-spi>
     <version.jboss.jms-integration-tests>1.0.1.GA</version.jboss.jms-integration-tests>
     <version.jboss.jsf-deployer>1.0.2</version.jboss.jsf-deployer>
     <version.jboss.web>3.0.0-beta-7</version.jboss.web>
@@ -109,9 +109,9 @@
     <version.org.jboss.mc-int>2.2.0.Alpha2</version.org.jboss.mc-int>
     <version.org.jboss.mdr>2.2.0.Alpha3</version.org.jboss.mdr>
     <version.org.jboss.metadata.client>2.0.0.Alpha2</version.org.jboss.metadata.client>
-    <version.org.jboss.metadata.common>2.0.0.Alpha17</version.org.jboss.metadata.common>
+    <version.org.jboss.metadata.common>2.0.0.Alpha18</version.org.jboss.metadata.common>
     <version.org.jboss.metadata.ear>2.0.0.Alpha4</version.org.jboss.metadata.ear>
-    <version.org.jboss.metadata.ejb>2.0.0-alpha-20</version.org.jboss.metadata.ejb>
+    <version.org.jboss.metadata.ejb>2.0.0-alpha-21</version.org.jboss.metadata.ejb>
     <!--version.org.jboss.metadata.ejb>2.0.0-alpha-22-SNAPSHOT</version.org.jboss.metadata.ejb-->
     <version.org.jboss.metadata.rar>2.0.0.Alpha</version.org.jboss.metadata.rar>
     <version.org.jboss.metadata.war>2.0.0.Alpha15</version.org.jboss.metadata.war>

Modified: branches/infinispan-int/server/src/main/java/org/jboss/deployment/EARContentsDeployer.java
===================================================================
--- branches/infinispan-int/server/src/main/java/org/jboss/deployment/EARContentsDeployer.java	2010-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/server/src/main/java/org/jboss/deployment/EARContentsDeployer.java	2010-10-22 21:21:52 UTC (rev 108837)
@@ -112,7 +112,11 @@
    public void deploy(VFSDeploymentUnit unit) throws DeploymentException
    {
       VirtualFile root = unit.getRoot();
-      VirtualFile ear = unit.getFile(unit.getRelativePath());
+      String relativePath = unit.getRelativePath();
+      VirtualFile ear = unit.getFile(relativePath);
+      if (ear == null)
+         throw new DeploymentException("No such ear file, relative path: '" + relativePath + "', root: " + root);
+
       deploy(unit, root, ear);
    }
 

Modified: branches/infinispan-int/system-jmx/src/main/java/org/jboss/deployment/MainDeployer.java
===================================================================
--- branches/infinispan-int/system-jmx/src/main/java/org/jboss/deployment/MainDeployer.java	2010-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/system-jmx/src/main/java/org/jboss/deployment/MainDeployer.java	2010-10-22 21:21:52 UTC (rev 108837)
@@ -21,23 +21,17 @@
  */
 package org.jboss.deployment;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import java.io.*;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
 import org.jboss.bootstrap.api.as.config.JBossASServerConfig;
 import org.jboss.deployers.client.spi.DeployerClient;
 import org.jboss.deployers.client.spi.Deployment;
@@ -364,6 +358,9 @@
          {
             // avoid caching
             VirtualFile file = VFS.getChild(url);
+            if (file == null || file.exists() == false)
+               throw new DeploymentException("File doesn't exist: " + url);
+
             VFSDeployment deployment = deploymentFactory.createVFSDeployment(file);
             delegate.addDeployment(deployment);
             deploymentName = deployment.getName();
@@ -372,11 +369,15 @@
             contextMap.put(url, deploymentName);
             delegate.checkComplete(deployment);
          }
+         catch (DeploymentException e)
+         {
+            log.warn("Failed to deploy: "+url, e);
+            throw e;
+         }
          catch(Exception e)
          {
             log.warn("Failed to deploy: "+url, e);
-            DeploymentException ex = new DeploymentException("Failed to deploy: "+url, e);
-            throw ex;
+            throw new DeploymentException("Failed to deploy: "+url, e);
          }
       }
    }

Modified: branches/infinispan-int/testsuite/imports/sections/weld.xml
===================================================================
--- branches/infinispan-int/testsuite/imports/sections/weld.xml	2010-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/testsuite/imports/sections/weld.xml	2010-10-22 21:21:52 UTC (rev 108837)
@@ -103,8 +103,7 @@
          </fileset>
       </jar>
 
-      <!-- This is still OK application.xml as we don't include lib jar -->
-      <ear destfile="${build.lib}/weld-translator3rdpartylib.ear" appxml="${source.resources}/deployers/weld/translatorWithManifestClasspath/META-INF/application.xml">
+      <ear destfile="${build.lib}/weld-translator3rdpartylib.ear" appxml="${source.resources}/deployers/weld/translator3rdparty/META-INF/application.xml">
          <fileset dir="${build.lib}">
             <include name="weld-translator-3rdpartylib.jar"/>
             <include name="weld-translator.war"/>
@@ -133,7 +132,7 @@
 
    </target>
 
-   <target name="_jars-weld" depends="numberguess, translator, plainEjbTranslator,translatorWithManifestClasspath">
+   <target name="_jars-weld" depends="numberguess, translator, plainEjbTranslator,translatorWithManifestClasspath, translatorWith3rdPartyLib">
       <mkdir dir="${build.lib}" />
    </target>
   

Copied: branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty (from rev 108785, trunk/testsuite/src/resources/deployers/weld/translator3rdparty)

Copied: branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF (from rev 108785, trunk/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF)

Deleted: branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/application.xml
===================================================================
--- trunk/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/application.xml	2010-10-22 07:42:48 UTC (rev 108785)
+++ branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/application.xml	2010-10-22 21:21:52 UTC (rev 108837)
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-
-<application xmlns="http://java.sun.com/xml/ns/javaee" 
-             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
-             version="5">
-
-  <display-name>weld-translator3rdparty-ear</display-name>
-  <module>
-    <web>
-      <web-uri>weld-translator.war</web-uri>
-      <context-root>/weld-translator3rdpartylib</context-root>
-    </web>
-  </module>
-  <module>
-    <ejb>weld-translator-3rdpartylib.jar</ejb>
-  </module>
-</application>

Copied: branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/application.xml (from rev 108785, trunk/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/application.xml)
===================================================================
--- branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/application.xml	                        (rev 0)
+++ branches/infinispan-int/testsuite/src/resources/deployers/weld/translator3rdparty/META-INF/application.xml	2010-10-22 21:21:52 UTC (rev 108837)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+
+<application xmlns="http://java.sun.com/xml/ns/javaee" 
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd"
+             version="5">
+
+  <display-name>weld-translator3rdparty-ear</display-name>
+  <module>
+    <web>
+      <web-uri>weld-translator.war</web-uri>
+      <context-root>/weld-translator3rdpartylib</context-root>
+    </web>
+  </module>
+  <module>
+    <ejb>weld-translator-3rdpartylib.jar</ejb>
+  </module>
+</application>

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-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml	2010-10-22 21:21:52 UTC (rev 108837)
@@ -28,8 +28,7 @@
    <bean name="WeldClasspathFactory" class="org.jboss.weld.integration.deployer.env.bda.ClasspathFactory">
       <constructor factoryMethod="getInstance" />
       <property name="system"><inject bean="ClassLoaderSystem"/></property>
-      <!-- Disable until we fix the loop -->
-      <!-- property name="libArchivesProvider"><inject bean="LibsDiscoveryService"/></property -->
+      <property name="libArchivesProvider"><inject bean="LibsDiscoveryService"/></property>
    </bean>
 
   <!-- Weld deployers -->

Modified: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WebContainterIntegrationDeployer.java
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WebContainterIntegrationDeployer.java	2010-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WebContainterIntegrationDeployer.java	2010-10-22 21:21:52 UTC (rev 108837)
@@ -12,6 +12,7 @@
 import org.jboss.weld.integration.deployer.DeployersUtils;
 import org.jboss.weld.integration.deployer.env.helpers.BootstrapBean;
 import org.jboss.weld.integration.injection.WeldInjector;
+import org.jboss.weld.integration.util.IdFactory;
 
 /**
  * Ensures that Weld is bootstrapped before the Web Application is started
@@ -39,7 +40,7 @@
          BeanMetaDataBuilder weldInjector = BeanMetaDataBuilder.createBuilder(injectorName, WeldInjector.class.getName());
 
          weldInjector.addConstructorParameter(BootstrapBean.class.getName(), weldInjector.createInject(bootstrapBeanName));
-         weldInjector.addConstructorParameter(String.class.getName(), unit.getClassLoader().toString());
+         weldInjector.addConstructorParameter(String.class.getName(), IdFactory.getIdFromClassLoader(unit.getClassLoader()));
          weldInjector.setDestroy("cleanup");
          unit.addAttachment(injectorName + "_" + BeanMetaData.class.getSimpleName(), weldInjector.getBeanMetaData());
 

Modified: 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/Archive.java	2010-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/Archive.java	2010-10-22 21:21:52 UTC (rev 108837)
@@ -32,6 +32,7 @@
 import org.jboss.weld.bootstrap.api.ServiceRegistry;
 import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
 import org.jboss.weld.ejb.spi.EjbDescriptor;
+import org.jboss.weld.integration.util.IdFactory;
 
 /**
  * An archive is an abstract representation of one or more deployed archives.
@@ -113,7 +114,7 @@
       // update instances map
       synchronized (instances)
       {
-         instances.put(this.classLoader, new WeakReference(this));
+         instances.put(this.classLoader, new WeakReference<Archive>(this));
       }
    }
 
@@ -153,13 +154,14 @@
    }
    
    /**
-    * Indicates whether {@code beanClass} is visible to this BDA
+    * 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;
+      Class<?> loadedClass;
       try
       {
          loadedClass = this.getClassLoader().loadClass(beanClass.getName());
@@ -170,8 +172,7 @@
       }
       return loadedClass == beanClass;
    }
-   
-   
+
    /**
     * Adds a class to this archive.
     * 
@@ -241,6 +242,7 @@
     * never returns duplicates.
     * 
     * @param bootstrap the Weld boostrap 
+    * @param services the services
     * @return the BeanDeploymentArchive representing this archive. If this bda has not
     *         been created, it is created and returned
     */
@@ -248,7 +250,7 @@
    {
       if (bda == null)
       {
-         bda = new BeanDeploymentArchiveImpl(classLoader.toString(), bootstrap, services, this);
+         bda = new BeanDeploymentArchiveImpl(IdFactory.getIdFromClassLoader(classLoader), bootstrap, services, this);
          for (ArchiveLifecycleListener listener: lifecycleListeners)
          {
             // notifies the listener that this archive became visible as a BDA
@@ -262,7 +264,8 @@
     * Creates the BeanDeploymentArchive that corresponds to this archive. This method
     * never returns duplicates.
     * Use this method if you are sure that this Archive has no beans.xml file.
-    *  
+    *
+    * @param services the services
     * @return the BeanDeploymentArchive representing this archive. If this bda has not
     *         been created, it is created and returned
     */

Modified: 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/BeanDeploymentArchiveImpl.java	2010-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/BeanDeploymentArchiveImpl.java	2010-10-22 21:21:52 UTC (rev 108837)
@@ -29,6 +29,7 @@
 import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
 import org.jboss.weld.bootstrap.spi.BeansXml;
 import org.jboss.weld.ejb.spi.EjbDescriptor;
+import org.jboss.weld.xml.BeansXmlParser;
 
 /**
  * {@link BeanDeploymentArchive} implementation for JBoss AS.
@@ -38,6 +39,9 @@
  */
 class BeanDeploymentArchiveImpl implements BeanDeploymentArchive
 {
+   // the beans parser
+   private static final BeansXmlParser parser = new BeansXmlParser();
+
    // identifies this BDA
    private final String id;
 
@@ -60,6 +64,13 @@
     */
    public BeanDeploymentArchiveImpl(String id, Bootstrap bootstrap, ServiceRegistry services, Archive archive)
    {
+      if (id == null)
+         throw new IllegalArgumentException("Null id");
+      if (archive == null)
+         throw new IllegalArgumentException("Null archive");
+      if (services == null)
+         throw new IllegalArgumentException("Null services");
+
       this.id = id;
       this.bootstrap = bootstrap;
       this.services = services;
@@ -79,11 +90,15 @@
    public BeansXml getBeansXml()
    {
       Collection<URL> urls = archive.getXmlURLs();
-      if (urls.isEmpty())
+      if (urls == null || urls.isEmpty())
       {
          return BeansXml.EMPTY_BEANS_XML;
       }
-      return bootstrap.parse(urls);
+
+      if (bootstrap != null)
+         return bootstrap.parse(urls);
+      else
+         return parser.parse(urls);
    }
 
    public Collection<EjbDescriptor<?>> getEjbs()

Modified: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DUTopLevelClassLoaderGetter.java
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DUTopLevelClassLoaderGetter.java	2010-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DUTopLevelClassLoaderGetter.java	2010-10-22 21:21:52 UTC (rev 108837)
@@ -22,7 +22,6 @@
 
 package org.jboss.weld.integration.deployer.env.bda;
 
-import org.jboss.classloader.spi.base.BaseClassLoader;
 import org.jboss.classloading.spi.RealClassLoader;
 import org.jboss.classloading.spi.dependency.Module;
 import org.jboss.deployers.plugins.classloading.AbstractDeploymentClassLoaderPolicyModule;

Modified: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/JBossBeanDeploymentArchiveLocator.java
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/JBossBeanDeploymentArchiveLocator.java	2010-10-22 21:05:22 UTC (rev 108836)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/jndi/JBossBeanDeploymentArchiveLocator.java	2010-10-22 21:21:52 UTC (rev 108837)
@@ -3,11 +3,13 @@
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
 import org.jboss.weld.integration.deployer.env.helpers.BootstrapBean;
+import org.jboss.weld.integration.util.IdFactory;
 
 /**
  * {@link BeanDeploymentArchiveLocator} implementation for non-flat (hierarchical) archives
  *
  * @author Marius Bogoevici
+ * @author Ales Justin
  */
 public class JBossBeanDeploymentArchiveLocator implements BeanDeploymentArchiveLocator
 {
@@ -15,7 +17,8 @@
    {
       for (BeanDeploymentArchive beanDeploymentArchive: bootstrap.getDeployment().getBeanDeploymentArchives())
       {
-         if (beanDeploymentArchive.getId().equals(deploymentUnit.getClassLoader().toString()))
+         String id = IdFactory.getIdFromClassLoader(deploymentUnit.getClassLoader());
+         if (beanDeploymentArchive.getId().equals(id))
          {
             return beanDeploymentArchive;
          }

Copied: branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/util/IdFactory.java (from rev 108785, trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/util/IdFactory.java)
===================================================================
--- branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/util/IdFactory.java	                        (rev 0)
+++ branches/infinispan-int/weld-int/deployer/src/main/java/org/jboss/weld/integration/util/IdFactory.java	2010-10-22 21:21:52 UTC (rev 108837)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.util;
+
+import javax.management.ObjectName;
+
+import org.jboss.classloading.spi.RealClassLoader;
+
+/**
+ * Try creating id the best way we can.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public final class IdFactory
+{
+   private IdFactory()
+   {
+   }
+
+   /**
+    * Get the id from classloader -- let's try RealClassLoader's objectName.
+    * 
+    * @param cl the classloader
+    * @return classloader's unique id
+    */
+   public static String getIdFromClassLoader(ClassLoader cl)
+   {
+      if (cl == null)
+         throw new IllegalArgumentException("Null classloader.");
+
+      ClassLoader current = cl;
+      while (current != null && (current instanceof RealClassLoader == false))
+      {
+         current = current.getParent();
+      }
+      if (current != null)
+      {
+         ObjectName on = ((RealClassLoader) current).getObjectName();
+         if (on != null)
+            return on.getCanonicalName();
+      }
+      return cl.toString(); // the best we can do :-(
+   }
+}



More information about the jboss-cvs-commits mailing list