Index: weld-int/deployer/src/main/java/org/jboss/weld/integration/util/IdFactory.java =================================================================== --- weld-int/deployer/src/main/java/org/jboss/weld/integration/util/IdFactory.java (revision 108657) +++ weld-int/deployer/src/main/java/org/jboss/weld/integration/util/IdFactory.java (revision ) @@ -24,6 +24,10 @@ import javax.management.ObjectName; +import java.security.AccessController; +import java.security.PrivilegedAction; + +import org.jboss.bootstrap.api.as.config.JBossASBasedServerConfig; import org.jboss.classloading.spi.RealClassLoader; /** @@ -33,6 +37,30 @@ */ public final class IdFactory { + private static String serverHome; + + static + { + String home; + SecurityManager sm = System.getSecurityManager(); + if (sm == null) + home = System.getProperty(JBossASBasedServerConfig.PROP_KEY_JBOSSAS_SERVER_HOME_URL); + else + { + home = AccessController.doPrivileged(new PrivilegedAction() + { + public String run() + { + return System.getProperty(JBossASBasedServerConfig.PROP_KEY_JBOSSAS_SERVER_HOME_URL); + } + }); + } + if (home != null && home.startsWith("file:")) + home = home.substring("file:".length()); + + serverHome = home; + } + private IdFactory() { } @@ -57,8 +85,14 @@ { ObjectName on = ((RealClassLoader) current).getObjectName(); if (on != null) - return on.getCanonicalName(); + { + String canonical = on.getCanonicalName(); + if (serverHome != null) + return canonical.replace(serverHome, "-JBossAS-"); + else + return canonical; - } + } + } return cl.toString(); // the best we can do :-( } }