[jboss-cvs] JBossAS SVN: r104481 - projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 5 11:36:23 EDT 2010


Author: kabir.khan at jboss.com
Date: 2010-05-05 11:36:23 -0400 (Wed, 05 May 2010)
New Revision: 104481

Modified:
   projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolConfig.java
   projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java
Log:
[CLASSPOOL-7] Rework the VFSClassLoaderDomainRegistry into something that can be delegated to rather than extended

Modified: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolConfig.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolConfig.java	2010-05-05 14:35:40 UTC (rev 104480)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/JBossClClassPoolConfig.java	2010-05-05 15:36:23 UTC (rev 104481)
@@ -70,7 +70,7 @@
       if (config != null)
          return;
       
-      DomainRegistry domainRegistry = new VFSClassLoaderDomainRegistry();
+      DomainRegistry domainRegistry = VFSClassLoaderDomainRegistry.getInstance();
       RegisterModuleCallback registerModuleCallback = new RegisterModuleCallback(domainRegistry);
       JBossClDelegatingClassPoolFactory classPoolFactory = new JBossClDelegatingClassPoolFactory(domainRegistry, registerModuleCallback);
       

Modified: projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java
===================================================================
--- projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java	2010-05-05 14:35:40 UTC (rev 104480)
+++ projects/jboss-classpool/trunk/jbosscl/src/main/java/org/jboss/classpool/plugins/jbosscl/VFSClassLoaderDomainRegistry.java	2010-05-05 15:36:23 UTC (rev 104481)
@@ -23,8 +23,10 @@
 
 
 import java.lang.ref.WeakReference;
+import java.util.List;
 import java.util.Map;
 import java.util.WeakHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.jboss.classloader.spi.ClassLoaderDomain;
 import org.jboss.classloader.spi.ClassLoaderSystem;
@@ -38,15 +40,10 @@
  */
 public class VFSClassLoaderDomainRegistry implements DomainRegistry
 {
-   protected final static ClassLoaderDomain domain = new ClassLoaderDomain("NOT_USED_PLACEHOLDER");
+   //protected final static ClassLoaderDomain domain = new ClassLoaderDomain("NOT_USED_PLACEHOLDER");
    
-   private static final VFSClassLoaderDomainRegistry instance = new VFSClassLoaderDomainRegistry();
+   private static final VFSClassLoaderDomainRegistry INSTANCE = new VFSClassLoaderDomainRegistry();
    
-   public static final VFSClassLoaderDomainRegistry getInstance()
-   {
-      return instance;
-   }
-   
    private ClassLoaderSystem system;
    
    private ClassLoaderDomain defaultDomain;
@@ -65,10 +62,18 @@
 
    protected Map<ClassLoaderDomain, Integer> classLoaderDomainReferenceCounts = new WeakHashMap<ClassLoaderDomain, Integer>();
    
-   private volatile ClassLoader abstractDeploymentClassLoaderPolicyModuleLoader;
+   private final List<Callback> callbacks = new CopyOnWriteArrayList<Callback>(); 
    
-   protected VFSClassLoaderDomainRegistry() {}
+   private VFSClassLoaderDomainRegistry() 
+   {
+      
+   }
    
+   public static final VFSClassLoaderDomainRegistry getInstance()
+   {
+      return INSTANCE;
+   }
+   
    /**
     * Needed for the tests, not expected to be needed in production
     */
@@ -138,12 +143,18 @@
    
    protected void validateInitMaps(ClassLoader loader, ClassLoaderDomain loaderDomain, Module module, ClassLoader parentUnitLoader)
    {
-      
+      if (callbacks.size() == 0)
+         return;
+      for (Callback callback : callbacks)
+         callback.validateInitMaps(loader, loaderDomain, module, parentUnitLoader);
    }
    
    protected void initMapsDone(ClassLoader loader, ClassLoaderDomain loaderDomain, Module module, ClassLoader parentUnitLoader)
    {
-      
+      if (callbacks.size() == 0)
+         return;
+      for (Callback callback : callbacks)
+         callback.initMapsDone(loader, loaderDomain, module, parentUnitLoader);
    }
    
    public synchronized void cleanupModule(Module module)
@@ -176,9 +187,18 @@
       cleanupLoaderDone(loader, clDomain, cnt);
    }
 
-   protected void validateCleanupLoader(ClassLoader loader) {}
+   protected void validateCleanupLoader(ClassLoader loader)
+   {
+      
+   }
    
-   protected void cleanupLoaderDone(ClassLoader loader, ClassLoaderDomain loaderDomain, int domainReferences) {}
+   protected void cleanupLoaderDone(ClassLoader loader, ClassLoaderDomain loaderDomain, int domainReferences)
+   {
+      if (callbacks.size() == 0)
+         return;
+      for (Callback callback : callbacks)
+         callback.cleanupLoaderDone(loader, loaderDomain, domainReferences);
+   }
    
    public synchronized ClassLoaderDomain getClassLoaderDomainForLoader(ClassLoader cl)
    {
@@ -235,12 +255,14 @@
    {
       return ParentUnitLoaderFinders.getInstance().findParentUnitLoader(module);
    }
-
+   
    public void addCallback(Callback callback)
    {
+      callbacks.add(callback);
    }
-
+   
    public void removeCallback(Callback callback)
    {
+      callbacks.remove(callback);
    }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list