[jboss-cvs] JBossAS SVN: r69622 - trunk/aspects/src/main/org/jboss/aop/asintegration/jboss5.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 5 09:34:38 EST 2008


Author: kabir.khan at jboss.com
Date: 2008-02-05 09:34:38 -0500 (Tue, 05 Feb 2008)
New Revision: 69622

Modified:
   trunk/aspects/src/main/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java
Log:
Fix weaving classes in WEB-INF/classes when deployed in a war deployed as part of a scoped ear file

Modified: trunk/aspects/src/main/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java	2008-02-05 14:20:44 UTC (rev 69621)
+++ trunk/aspects/src/main/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java	2008-02-05 14:34:38 UTC (rev 69622)
@@ -52,50 +52,69 @@
       ClassLoader loader = unit.getClassLoader();
       ClassLoader topLoader = unit.getTopLevel().getClassLoader();
       
-      ClassLoaderMetaData topMetaData = unit.getTopLevel().getAttachment(ClassLoaderMetaData.class);
-      ClassLoaderMetaData myMetaData = unit.getAttachment(ClassLoaderMetaData.class);
-      
-      
       boolean isWar = unit.isAttachmentPresent("org.jboss.metadata.web.jboss.JBossWebMetaData");
 
-      ScopedVFSClassLoaderDomain scopedDomain = (ScopedVFSClassLoaderDomain)registry.getRegisteredDomain(loader);
-      if (scopedDomain == null)
+      if (isWar && loader != topLoader)
       {
-         if (module.getParentDomain() != null/* && module.getParentDomain().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME)*/)
+         ScopedVFSClassLoaderDomain scopedDomain = (ScopedVFSClassLoaderDomain)registry.getRegisteredDomain(loader);
+         if (scopedDomain == null) 
          {
-            ClassLoaderSystem system = ClassLoaderSystem.getInstance();
-            String domainName = module.getDomainName();
-            ClassLoaderDomain domain = system.getDomain(domainName);
-   
-            ClassLoaderMetaData cmd = module.getMetadata();
-            boolean parentDelegation = cmd.isJ2seClassLoadingCompliance();
-            String name = String.valueOf(System.identityHashCode(loader));
-            
-            scopedDomain = new ScopedVFSClassLoaderDomain(loader, name, parentDelegation, AspectManager.getTopLevelAspectManager(), false, domain, registry);
+            scopedDomain = (ScopedVFSClassLoaderDomain)registry.getRegisteredDomain(topLoader);
          }
-   
-         registry.initMapsForLoader(loader, module, scopedDomain);
          
-         //Need to pass some data through to the classpoolfactory here
-         Map properties = new HashMap();
-         //The module is needed by the JBoss5ClassPoolFactory, the legacy JBossClassPoolFactory will ignore this
-         properties.put(Module.class, module);
-         properties.put("IsWebCl", isWar ? Boolean.TRUE : Boolean.FALSE);
-         ExtraClassPoolFactoryParameters.pushThreadProperties(properties);
-         try
+         if (scopedDomain != null)
          {
-            AspectManager.instance().registerClassLoader(loader); //Ends up in classpool factory create method
+            registry.initMapsForLoader(loader, module, scopedDomain);
          }
-         finally
+
+         registerClassLoader(module, isWar, loader);
+         
+         return scopedDomain;
+      }
+      else
+      {
+         ScopedVFSClassLoaderDomain scopedDomain = (ScopedVFSClassLoaderDomain)registry.getRegisteredDomain(loader);
+         if (scopedDomain == null)
          {
-            ExtraClassPoolFactoryParameters.popThreadProperties();
+            if (module.getParentDomain() != null/* && module.getParentDomain().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME)*/)
+            {
+               ClassLoaderSystem system = ClassLoaderSystem.getInstance();
+               String domainName = module.getDomainName();
+               ClassLoaderDomain domain = system.getDomain(domainName);
+      
+               ClassLoaderMetaData cmd = module.getMetadata();
+               boolean parentDelegation = cmd.isJ2seClassLoadingCompliance();
+               String name = String.valueOf(System.identityHashCode(loader));
+               
+               scopedDomain = new ScopedVFSClassLoaderDomain(loader, name, parentDelegation, AspectManager.getTopLevelAspectManager(), false, domain, registry);
+            }
+      
+            registry.initMapsForLoader(loader, module, scopedDomain);
+            
+            registerClassLoader(module, isWar, loader);
          }
+         return scopedDomain;
       }      
-      return scopedDomain;
    }
 
+   private void registerClassLoader(Module module, boolean isWar, ClassLoader loader)
+   {
+      //Need to pass some data through to the classpoolfactory here
+      Map properties = new HashMap();
+      //The module is needed by the JBoss5ClassPoolFactory, the legacy JBossClassPoolFactory will ignore this
+      properties.put(Module.class, module);
+      properties.put("IsWebCl", isWar ? Boolean.TRUE : Boolean.FALSE);
+      ExtraClassPoolFactoryParameters.pushThreadProperties(properties);
+      try
+      {
+         AspectManager.instance().registerClassLoader(loader); //Ends up in classpool factory create method
+      }
+      finally
+      {
+         ExtraClassPoolFactoryParameters.popThreadProperties();
+      }
+   }
    
-   
    public Domain getDomain(ClassLoader classLoader, AspectManager parent)
    {
       //Check the stored domains




More information about the jboss-cvs-commits mailing list