[jboss-cvs] JBossAS SVN: r92354 - in projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src: test/java/org/jboss/test and 13 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 14 08:12:50 EDT 2009


Author: flavia.rainone at jboss.com
Date: 2009-08-14 08:12:49 -0400 (Fri, 14 Aug 2009)
New Revision: 92354

Added:
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPDomainRegistry.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPVFSClassLoaderDomainRegistry.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/jbosscl/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/jbosscl/test/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/BundleInfoBuilder.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/Result.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/SupportClasses.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderFactory.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderFactoryFactory.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderPolicyModule.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/resources/org/jboss/test/classpool/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/resources/org/jboss/test/classpool/jbosscl/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/resources/org/jboss/test/classpool/jbosscl/Common.xml
Removed:
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/DomainRegistry.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5ClassPool.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5ClassPoolFactory.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/RegisterModuleCallback.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ScopedJBoss5ClassPool.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ToClassInvoker.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ToClassInvokerPoolReference.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderDomainRegistry.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/AlwaysWritablePermissionCollectionTestPolicyPlugin.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/BundleInfoBuilder.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/CapabilityInfo.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/ModuleOrPackageInfo.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/NoMatchClassFilter.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/RequirementInfo.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/Result.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactory.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactoryFactory.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderPolicyModule.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/excluded/a/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/excluded/b/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/excluded/c/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/excluded/replacereferences/Invoked.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/excluded/replacereferences/child/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/excluded/replacereferences/parent/
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/test/
Modified:
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPClassLoaderInitializer.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPClassLoaderScopingPolicyWithRegistry.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5Integration.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ScopedVFSClassLoaderDomain.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/weaving/test/WeavingTest.java
   projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/scopeddomain/test/ScopedVFSClassLoaderDomainTestCase.java
Log:
[JBAOP-742] The asintegration-mc project is by far the project that was more affected by this task:
- removed duplicates
- JBoss5Integration now uses the new AOP classpool structure
- created an AOPDomainRegistry interface and an AOPVFSClassLoaderDomainRegistry class
- replaced all DomainRegistry references to AOPDomainRegistry references throught the project
- adapted test classes and created a few helper class tests
- duplicated JBossClClassPoolTest and adapted it so it would work with the new registries and with the AOP domain structure. The next step related to this change is to study whether extending the original JBossClClassPoolTest class would be a better idea.

Modified: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPClassLoaderInitializer.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPClassLoaderInitializer.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPClassLoaderInitializer.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -47,7 +47,7 @@
    public static void unregisterLoaders(AspectManager manager, DeploymentUnit unit)
    {
       AOPClassLoaderScopingPolicyWithRegistry policy = (AOPClassLoaderScopingPolicyWithRegistry)AspectManager.getClassLoaderScopingPolicy();
-      DomainRegistry registry = policy.getRegistry();
+      AOPDomainRegistry registry = policy.getRegistry();
       if (unit.isTopLevel() || unit.getParent().getClassLoader() != unit.getClassLoader())
       {
          registry.cleanupLoader(unit.getClassLoader());
@@ -57,7 +57,7 @@
    
    private static void registerLoaders(AOPClassLoaderScopingPolicyWithRegistry policy, DeploymentUnit unit)
    {
-      DomainRegistry registry = policy.getRegistry();
+      AOPDomainRegistry registry = policy.getRegistry();
       if (!unit.isTopLevel())
       {
          registerLoaders(policy, unit.getParent());
@@ -105,12 +105,12 @@
    }
    
    
-   private static ScopedVFSClassLoaderDomain getDomain(DomainRegistry registry, DeploymentUnit unit)
+   private static ScopedVFSClassLoaderDomain getDomain(AOPDomainRegistry registry, DeploymentUnit unit)
    {
       return (ScopedVFSClassLoaderDomain)registry.getRegisteredDomain(unit.getClassLoader());
    }
    
-   private static ScopedVFSClassLoaderDomain createDomain(DomainRegistry registry, ClassLoader loader, Module module, DeploymentUnit unit)
+   private static ScopedVFSClassLoaderDomain createDomain(AOPDomainRegistry registry, ClassLoader loader, Module module, DeploymentUnit unit)
    {
       if (!module.getDeterminedDomainName().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME))
       {

Modified: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPClassLoaderScopingPolicyWithRegistry.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPClassLoaderScopingPolicyWithRegistry.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPClassLoaderScopingPolicyWithRegistry.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -21,8 +21,9 @@
 */ 
 package org.jboss.aop.asintegration.jboss5;
 
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+import org.jboss.aop.newclasspool.AOPClassLoaderScopingPolicy;
 import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classpool.jboss5.DomainRegistry;
 
 /**
  * 
@@ -31,7 +32,7 @@
  */
 public interface AOPClassLoaderScopingPolicyWithRegistry extends AOPClassLoaderScopingPolicy
 {
-   DomainRegistry getRegistry();
+   AOPDomainRegistry getRegistry();
 
    void registerClassLoader(Module module, ClassLoader loader);
 

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPDomainRegistry.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPDomainRegistry.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPDomainRegistry.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,47 @@
+/*
+* 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.aop.asintegration.jboss5;
+
+import java.util.List;
+import java.util.concurrent.locks.ReadWriteLock;
+
+import org.jboss.aop.Domain;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classpool.jboss5.DomainRegistry;
+
+/**
+ * 
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface AOPDomainRegistry extends DomainRegistry
+{
+   boolean initMapsForLoader(ClassLoader loader, Module module, ScopedVFSClassLoaderDomain domain, ClassLoader parentUnitLoader);
+   
+   Domain getRegisteredDomain(ClassLoader cl);
+   
+   List<ScopedVFSClassLoaderDomain> getAOPDomainsForClassLoaderDomain(ClassLoaderDomain domain);
+   
+   ReadWriteLock getAOPDomainsLockForClassLoaderDomain(ClassLoaderDomain domain);
+}
\ No newline at end of file

Copied: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPVFSClassLoaderDomainRegistry.java (from rev 91623, projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderDomainRegistry.java)
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPVFSClassLoaderDomainRegistry.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/AOPVFSClassLoaderDomainRegistry.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,150 @@
+/*
+ * 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.aop.asintegration.jboss5;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.jboss.aop.Domain;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classpool.jboss5.VFSClassLoaderDomainRegistry;
+
+/**
+ * 
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ *
+ * @version $Revision: 1.1 $
+ */
+public class AOPVFSClassLoaderDomainRegistry extends VFSClassLoaderDomainRegistry implements AOPDomainRegistry
+{
+   /** aopDomains by classloader */
+   private Map<ClassLoader, ScopedVFSClassLoaderDomain> aopDomainsByClassLoader = new WeakHashMap<ClassLoader, ScopedVFSClassLoaderDomain>();
+   
+   /** aopDomains by classloader domain */
+   private Map<ClassLoaderDomain, List<ScopedVFSClassLoaderDomain>> aopDomainsByClassLoaderDomain = new WeakHashMap<ClassLoaderDomain, List<ScopedVFSClassLoaderDomain>>();
+
+   private Map<ClassLoaderDomain, ReadWriteLock> aopDomainsLocksByClassLoaderDomain = new WeakHashMap<ClassLoaderDomain, ReadWriteLock>();
+
+   private ScopedVFSClassLoaderDomain initDomain = null;
+
+   public List<ScopedVFSClassLoaderDomain> getAOPDomainsForClassLoaderDomain(ClassLoaderDomain domain)
+   {
+      List<ScopedVFSClassLoaderDomain> domains = aopDomainsByClassLoaderDomain.get(domain);
+      if (domains != null)
+      {
+         return domains;
+      }
+      return Collections.emptyList();
+   }
+
+   public ReadWriteLock getAOPDomainsLockForClassLoaderDomain(ClassLoaderDomain domain)
+   {
+      return aopDomainsLocksByClassLoaderDomain.get(domain);
+   }
+
+   public synchronized Domain getRegisteredDomain(ClassLoader cl)
+   {
+      return aopDomainsByClassLoader.get(cl);
+   }
+
+   public synchronized boolean initMapsForLoader(ClassLoader loader, Module module, ScopedVFSClassLoaderDomain domain, ClassLoader parentUnitLoader)
+   {
+      this.initDomain = domain;
+      return super.initMapsForLoader(loader, module, parentUnitLoader);
+   }
+   
+   @Override
+   protected void validateInitMaps(ClassLoader loader, ClassLoaderDomain loaderDomain, Module module, ClassLoader parentUnitLoader)
+   {
+      if (loaderDomain == null && initDomain != null)
+      {
+         throw new IllegalStateException("Have " + domain + " but no classloader domain");
+      }
+   }
+   
+   @Override
+   protected void initMapsDone(ClassLoader loader, ClassLoaderDomain loaderDomain, Module module, ClassLoader parentUnitLoader)
+   {
+      if (initDomain != null)
+      {
+         aopDomainsByClassLoader.put(loader, initDomain);
+
+         ReadWriteLock lock = aopDomainsLocksByClassLoaderDomain.get(loaderDomain);
+         if (lock == null)
+         {
+            lock = new ReentrantReadWriteLock();
+            aopDomainsLocksByClassLoaderDomain.put(loaderDomain, lock);
+         }
+         
+         lock.writeLock().lock();
+         try
+         {
+            List<ScopedVFSClassLoaderDomain> aopDomains = aopDomainsByClassLoaderDomain.get(loaderDomain);
+            if (aopDomains == null)
+            {
+               synchronized (aopDomainsByClassLoaderDomain)
+               {
+                  aopDomains = new CopyOnWriteArrayList<ScopedVFSClassLoaderDomain>();
+                  if (!aopDomains.contains(loaderDomain))
+                  {
+                     aopDomainsByClassLoaderDomain.put(loaderDomain, aopDomains);
+                  }
+               }
+            }
+            aopDomains.add(initDomain);
+         }
+         finally
+         {
+            lock.writeLock().unlock();
+         }
+      }
+   }
+   
+   @Override
+   public synchronized void cleanupLoaderDone(ClassLoader loader, ClassLoaderDomain loaderDomain, int domainReferences)
+   {
+      if (loaderDomain != null)
+      {
+         if (domainReferences == 0)
+         {
+            //aopDomainsByClassLoaderDomain.remove(loaderDomain);
+         }
+         ScopedVFSClassLoaderDomain aopDomain = aopDomainsByClassLoader.remove(loader);
+         List<ScopedVFSClassLoaderDomain> aopDomains = aopDomainsByClassLoaderDomain.get(loaderDomain);
+         if (aopDomains != null)
+         {
+            aopDomains.remove(aopDomain);
+         }
+         if (aopDomain != null)
+         {
+            aopDomain.getParent().unsubscribeSubDomain(aopDomain);
+         }
+      }
+      aopDomainsByClassLoader.remove(loader);
+   }
+}
\ No newline at end of file

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/DomainRegistry.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/DomainRegistry.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/DomainRegistry.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,60 +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.aop.asintegration.jboss5;
-
-import java.util.List;
-import java.util.concurrent.locks.ReadWriteLock;
-
-import org.jboss.aop.Domain;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloading.spi.dependency.Module;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public interface DomainRegistry
-{
-   ClassLoaderSystem getSystem();
-   
-   ClassLoaderDomain getDefaultDomain();
-   
-   boolean initMapsForLoader(ClassLoader loader, Module module, ScopedVFSClassLoaderDomain domain, ClassLoader parentUnitLoader);
-
-   void cleanupLoader(ClassLoader loader);
-   
-   Domain getRegisteredDomain(ClassLoader cl);
-
-   ClassLoaderDomain getClassLoaderDomainForLoader(ClassLoader cl);
-
-   ClassLoader getParentUnitLoader(ClassLoader loader);
-
-   Module getModule(ClassLoader loader);
-
-   ClassLoader getClassLoader(Module module);
-   
-   List<ScopedVFSClassLoaderDomain> getAOPDomainsForClassLoaderDomain(ClassLoaderDomain domain);
-   
-   ReadWriteLock getAOPDomainsLockForClassLoaderDomain(ClassLoaderDomain domain);
-}
\ No newline at end of file

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5ClassPool.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5ClassPool.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5ClassPool.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,76 +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.aop.asintegration.jboss5;
-
-import java.net.URL;
-import java.security.ProtectionDomain;
-
-import javassist.CannotCompileException;
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-import org.jboss.aop.classpool.AOPClassPool;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class JBoss5ClassPool extends AOPClassPool implements ToClassInvokerPoolReference
-{
-   protected ToClassInvoker toClassInvoker = null;
-
-   boolean closed;
-   
-   protected JBoss5ClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, URL tmpURL)
-   {
-      super(cl, src, repository);
-      toClassInvoker = new ToClassInvoker(tmpURL);
-   }
-
-   protected JBoss5ClassPool(ClassPool src, ScopedClassPoolRepository repository)
-   {
-      super(src, repository);
-   }
-
-   public boolean isUnloadedClassLoader()
-   {
-      return closed;
-   }
-
-   public void close()
-   {
-      closed = true;
-      super.close();
-   }
-
-   public Class<?> toClass(CtClass cc, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
-   {
-      return toClassInvoker.toClass(this, cc, getResourceName(cc.getName()), loader, domain);
-   }
-
-   public Class<?> superPoolToClass(CtClass cc, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
-   {
-      return super.toClass(cc, loader, domain);
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5ClassPoolFactory.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5ClassPoolFactory.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5ClassPoolFactory.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,102 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.aop.asintegration.jboss5;
-
-import java.net.URL;
-
-import javassist.ClassPool;
-import javassist.scopedpool.ScopedClassPool;
-import javassist.scopedpool.ScopedClassPoolFactory;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.aop.classpool.AbstractJBossClassPoolFactory;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloading.spi.RealClassLoader;
-import org.jboss.classloading.spi.dependency.Module;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision: 64815 $
- **/
-public class JBoss5ClassPoolFactory extends AbstractJBossClassPoolFactory implements ScopedClassPoolFactory
-{
-   private DomainRegistry registry;
-   
-   public JBoss5ClassPoolFactory(DomainRegistry registry)
-   {
-      this.registry = registry;
-   }
-   
-   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
-   {      
-      ClassPool parent = getCreateParentClassPools(cl, src, repository);
-
-      ScopedClassPool pool = null;
-      
-      if (cl instanceof RealClassLoader)
-      {
-         Module module = registry.getModule(cl);
-         if (module != null && module.getDeterminedParentDomainName() != null)
-         {
-            //It is scoped
-            ClassLoaderSystem sys = registry.getSystem();
-            ClassLoaderDomain domain = sys.getDomain(module.getDeterminedDomainName());
-            boolean parentFirst = module.isJ2seClassLoadingCompliance();
-            ClassPool parentDomainPool = getParentUnitClassPool(cl); 
-            pool = new ScopedJBoss5ClassPool(cl, parent, parentDomainPool, repository, getTempURL(module), parentFirst, domain);
-         }
-         else
-         {
-            pool =  new JBoss5ClassPool(cl, parent, repository, getTempURL(module));
-         }
-      }
-      
-      if (pool == null)
-      {
-         pool = new AOPClassPool(cl, parent, repository);
-      }
-      log.debug("Created pool " + pool + " for loader " + cl);
-      
-      return pool;
-   }
-
-   private ClassPool getParentUnitClassPool(ClassLoader cl)
-   {
-      ClassLoader parent = registry.getParentUnitLoader(cl);
-      return AspectManager.instance().registerClassLoader(parent);
-   }
-   
-
-   private URL getTempURL(Module module)
-   {
-      if (module == null)
-         return null;
-      
-      return module.getDynamicClassRoot();
-   }
-}

Modified: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5Integration.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5Integration.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/JBoss5Integration.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -35,8 +35,11 @@
 
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.asintegration.JBossIntegration;
+import org.jboss.aop.newclasspool.AOPClassPoolFactory;
 import org.jboss.classloader.spi.ClassLoaderSystem;
 import org.jboss.classloading.spi.RealClassLoader;
+import org.jboss.classpool.AbstractClassPoolFactory;
+import org.jboss.classpool.jboss5.JBoss5ClassPoolFactory;
 
 /**
  * 
@@ -120,21 +123,30 @@
       return policy;
    }
    
-   public DomainRegistry getDomainRegistry()
+   public AOPDomainRegistry getDomainRegistry()
    {
       return policy.getRegistry();
    }
    
    public void setClassPoolFactory(ScopedClassPoolFactory factory)
    {
-      this.delegateClassPoolFactory = factory;
+      if (factory instanceof AbstractClassPoolFactory)
+      {
+         AOPClassPoolFactory.setDelegateClassPoolFactory((AbstractClassPoolFactory) factory);
+         this.delegateClassPoolFactory = new AOPClassPoolFactory();
+      }
+      else
+      {
+         this.delegateClassPoolFactory = factory;
+      }
    }
 
    public synchronized ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception
    {
       if (delegateClassPoolFactory == null)
       {
-         delegateClassPoolFactory = new JBoss5ClassPoolFactory(getDomainRegistry());
+         AOPClassPoolFactory.setDelegateClassPoolFactory(new JBoss5ClassPoolFactory(getDomainRegistry()));
+         delegateClassPoolFactory = new AOPClassPoolFactory();
       }
       return this;
    }

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/RegisterModuleCallback.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/RegisterModuleCallback.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/RegisterModuleCallback.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,68 +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.aop.asintegration.jboss5;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.logging.Logger;
-
-/**
- * Use with org.jboss.aop.classpool.jbosscl.JBossClDelegatingClassPoolFactory
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class RegisterModuleCallback
-{
-   Logger logger = Logger.getLogger(this.getClass());
-   
-   private Set<Module> registeredModules = new HashSet<Module>();
-   private Set<Module> unregisteredModules = new HashSet<Module>();
-
-   public synchronized void addModule(Module module)
-   {
-      logger.debug("Adding module " + module);
-      unregisteredModules.add(module);
-   }
-
-   public synchronized void removeModule(Module module)
-   {
-      logger.debug("Removing module " + module);
-      registeredModules.remove(module);
-      unregisteredModules.remove(module);
-   }
-   
-   public synchronized Set<Module> getUnregisteredModules()
-   {
-      return Collections.unmodifiableSet(new HashSet<Module>(unregisteredModules));
-   }
-   
-   public synchronized void registerModule(Module module)
-   {
-      logger.debug("Registering module " + module);
-      registeredModules.add(module);
-      unregisteredModules.remove(module);
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ScopedJBoss5ClassPool.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ScopedJBoss5ClassPool.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ScopedJBoss5ClassPool.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,401 +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.aop.asintegration.jboss5;
-
-import java.lang.ref.WeakReference;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.NotFoundException;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.aop.classpool.AOPClassPoolRepository;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.Loader;
-import org.jboss.classloading.spi.RealClassLoader;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ScopedJBoss5ClassPool extends JBoss5ClassPool
-{
-   ThreadLocal<ClassPool> lastPool = new ThreadLocal<ClassPool>();
-   WeakReference<ClassLoaderDomain> domainRef;
-   /** The classpool representing the parent domain of this one */
-   ClassPool parentDomainPool;
-
-   public ScopedJBoss5ClassPool(ClassLoader cl, ClassPool src, ClassPool parentDomainPool, ScopedClassPoolRepository repository, 
-         URL tmpURL, boolean parentFirst, ClassLoaderDomain domain)
-   {
-      super(cl, src, repository, tmpURL);
-      super.childFirstLookup = !parentFirst;
-      this.parentDomainPool = parentDomainPool;
-      this.domainRef = new WeakReference<ClassLoaderDomain>(domain);
-      
-      logger.debug("Created new ScopedJBoss5ClasPool for " + cl + ", with parent: " + src + ", parentDomain: " + parentDomainPool + ", parentFirst: " + parentFirst);
-   }
-
-   private URL getResourceUrlForClass(String resourcename)
-   {
-      ClassLoaderDomain domain = domainRef.get();
-      return domain.getResource(resourcename);
-   }
-
-   private boolean isMine(URL myURL, String resourceName)
-   {
-      if (myURL == null)
-      {
-         return false;
-      }
-      
-      ClassLoaderDomain domain = domainRef.get();
-      Loader parent = domain.getParent();
-      URL parentURL = parent.getResource(resourceName);
-      
-      if (parentURL == null)
-      {
-         return true;
-      }
-      
-      if (!myURL.equals(parentURL))
-      {
-         return true;
-      }
-      
-      return false;
-   }
-   
-
-   @Override
-   protected synchronized CtClass get0(String classname, boolean useCache) throws NotFoundException
-   {
-      CtClass clazz = null;
-      if (useCache)
-      {
-         clazz = getCached(classname);
-         if (clazz != null)
-            return clazz;
-      }
-
-      if (!childFirstLookup)
-      {
-         if (parentDomainPool != null)
-         {
-            clazz = performGet(parentDomainPool, classname);
-            if (clazz != null)
-            {
-               return clazz;
-            }
-         }
-         if (parent != null)
-         {
-            clazz = performGet(parent, classname);
-            if (clazz != null)
-            {
-               return clazz;
-            }
-         }
-      }
-
-      clazz = createCtClass(classname, useCache);
-      if (clazz != null)
-      {
-         // clazz.getName() != classname if classname is "[L<name>;".
-         if (useCache)
-            cacheCtClass(clazz.getName(), clazz, false);
-
-         return clazz;
-      }
-
-      if (childFirstLookup)
-      {
-         if (parent != null)
-         {
-            clazz = performGet(parent, classname);
-            if (clazz != null)
-            {
-               return clazz;
-            }
-         }
-         if (parentDomainPool != null)
-         {
-            clazz = performGet(parentDomainPool, classname);
-            if (clazz != null)
-            {
-               return clazz;
-            }
-         }
-      }
-
-      return clazz;
-   }
-
-   private CtClass performGet(ClassPool pool, String classname)
-   {
-      try
-      {
-         //Want to avoid calling get() if possible since that creates NotFoundExceptions
-         //on misses which is expensive
-         if (pool instanceof AOPClassPool)
-         {
-            return ((AOPClassPool)pool).internalGet0(classname, true);
-         }
-         else
-         {
-            return pool.get(classname);
-         }
-      }
-      catch (NotFoundException e)
-      {
-         return null;
-      }
-   }
-   
-   
-   public CtClass getCached(String classname)
-   {
-      boolean trace = logger.isTraceEnabled();
-      
-      if (trace)
-      {
-         logger.trace("getCached() " + classname);
-      }
-      
-      if (classname == null)
-      {
-         if (trace)
-         {
-            logger.trace("getCached() returning null (classname == null)");
-         }
-         return null;
-      }
-      if (isUnloadedClassLoader())
-      {
-         if (trace)
-         {
-            logger.trace("getCached() returning null (unloaded)");
-         }
-         return null;
-      }
-
-      if (generatedClasses.get(classname) != null)
-      {
-         //It is a new class, and this callback is probably coming from the frozen check when creating a new nested class
-         if (trace)
-         {
-            logger.trace("getCached() In generated classes - check super");
-         }
-         return super.getCached(classname);
-      }
-      
-      //Is this from the scoped classloader itself of from the parent?
-      String resourcename = getResourceName(classname);
-      URL url = getResourceUrlForClass(resourcename);
-      
-      if (isMine(url, resourcename))
-      {
-         if (super.childFirstLookup)
-         {
-            //Parent delegation is false, attempt to get this class out of ourselves
-            CtClass clazz = super.getCachedLocally(classname);
-            if (clazz == null)
-            {
-               if (trace)
-               {
-                  logger.trace("getCached() Creating my class " + classname);
-               }
-               clazz = createCtClass(classname, false);
-               if (clazz != null)
-               {
-                  lockInCache(clazz);
-               }
-            }
-            if (clazz != null)
-            {
-               if (trace)
-               {
-                  logger.trace("getCached() Returning my class " + classname);
-               }
-               return clazz;
-            }
-         }
-         if (trace)
-         {
-            logger.trace("getCached() Checking super for my class " + classname);
-         }
-         return super.getCached(classname);
-      }
-      else if (url == null)
-      {
-         if (trace)
-         {
-            logger.trace("getCached() Checking super for my class " + classname + " (no url)");
-         }
-         return super.getCached(classname);
-      }
-      
-
-      try
-      {
-         ClassPool pool = getCorrectPoolForResource(classname, resourcename, url, trace);
-         if (trace)
-         {
-            logger.trace("getCached() Found pool for class " + classname + " " + pool);
-         }
-         if (pool != lastPool.get())
-         {
-            lastPool.set(pool);
-            CtClass found = pool.get(classname);
-            if (trace)
-            {
-               logger.trace("getCached() Found clazz " + classname + " in " + pool + " : " + found);
-            }
-            return found;
-         }
-      }
-      catch (NotFoundException e)
-      {
-      }
-      catch(StackOverflowError e)
-      {
-         throw e;
-      }
-      finally
-      {
-         lastPool.set(null);
-      }
-
-      return null;
-   }
-   
-   @Override
-   protected boolean includeInGlobalSearch()
-   {
-      return false;
-   } 
-   
-   private ClassPool getCorrectPoolForResource(String classname, String resourceName, URL url, boolean trace)
-   {
-      synchronized(AspectManager.getRegisteredCLs())
-      {
-         //JBoss 5 has an extra NoAnnotationURLCLassLoader that is not on the default path, make sure that that is checked at the end
-         //FIXME This needs revisiting/removing once the 
-         ArrayList<ClassPool> noAnnotationURLClassLoaderPools = null;
-                 
-         for(Iterator<ClassPool> it = AspectManager.getRegisteredCLs().values().iterator() ; it.hasNext() ; )
-         {
-            AOPClassPool candidate = (AOPClassPool)it.next();
-            if (candidate.isUnloadedClassLoader())
-            {
-               AspectManager.instance().unregisterClassLoader(candidate.getClassLoader());
-               continue;
-            }
-            
-            if (candidate.getClassLoader() instanceof RealClassLoader)
-            {
-               //Sometimes the ClassLoader is a proxy for MBeanProxyExt?!
-               RealClassLoader bcl = (RealClassLoader)candidate.getClassLoader();
-               URL foundUrl = bcl.getResourceLocally(resourceName);
-               if (foundUrl != null)
-               {
-                  if (url.equals(foundUrl))
-                  {
-                     if (trace)
-                     {
-                        logger.trace("getCorrectPoolForResource() Candidate classloader " + bcl + " has local resource " + foundUrl);
-                     }
-                     return candidate;
-                  }
-               }
-            }
-            //FIXME Remove once we have the JBoss 5 version of pool
-            else if (isInstanceOfNoAnnotationURLClassLoader(candidate.getClassLoader()))
-            {
-               if (noAnnotationURLClassLoaderPools == null)
-               {
-                  noAnnotationURLClassLoaderPools = new ArrayList<ClassPool>(); 
-               }
-               noAnnotationURLClassLoaderPools.add(candidate);
-            }
-         }
-         
-         //FIXME Remove once we have the JBoss 5 version of pool
-         if (noAnnotationURLClassLoaderPools != null)
-         {
-            for (ClassPool pool : noAnnotationURLClassLoaderPools)
-            {
-               try
-               {
-                  pool.get(classname);
-                  if (trace)
-                  {
-                     logger.trace("getCorrectPoolForResource(() Found  " + classname + " (no url)");
-                  }
-                  return pool;
-               }
-               catch(NotFoundException ignoreTryNext)
-               {
-               }
-            }
-         }
-      }
-      return createTempPool();
-   }
-   
-   private ClassPool createTempPool()
-   {
-      //Rememeber that the stuff in jboss5/lib goes in a child classloader of the default classloader. We need
-      //to make this the parent of the temp classloader
-      ClassLoader aopLoader = AspectManager.class.getClassLoader();
-      ClassPool pool = AspectManager.instance().registerClassLoader(aopLoader);
-      return AOPClassPool.createAOPClassPool(pool, AOPClassPoolRepository.getInstance());
-   }
-   
-   /**
-    * NoAnnotationURLCLassLoader lives in different packages in JBoss 4 and 5
-    */
-   private boolean isInstanceOfNoAnnotationURLClassLoader(ClassLoader loader)
-   {
-      if (loader == null)
-      {
-         return false;
-      }
-      Class<?> parent = loader.getClass();
-      while (parent != null)
-      {
-         if ("NoAnnotationURLClassLoader".equals(parent.getSimpleName()))
-         {
-            return true;
-         }
-         parent = parent.getSuperclass();
-      }
-      return false;
-   }
-   
-}

Modified: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ScopedVFSClassLoaderDomain.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ScopedVFSClassLoaderDomain.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ScopedVFSClassLoaderDomain.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -70,10 +70,10 @@
 public class ScopedVFSClassLoaderDomain extends ScopedClassLoaderDomain
 {
    WeakReference<ClassLoaderDomain> classLoaderDomainRef;
-   DomainRegistry registry;
+   AOPDomainRegistry registry;
    
    public ScopedVFSClassLoaderDomain(ClassLoader loader, String name, boolean parentDelegation, AspectManager manager, boolean parentFirst, 
-         ClassLoaderDomain classLoaderDomain, DomainRegistry registry)
+         ClassLoaderDomain classLoaderDomain, AOPDomainRegistry registry)
    {
       super(loader, name, parentDelegation, manager, parentFirst);
       classLoaderDomainRef = new WeakReference<ClassLoaderDomain>(classLoaderDomain);

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ToClassInvoker.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ToClassInvoker.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ToClassInvoker.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,100 +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.aop.asintegration.jboss5;
-
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.net.URL;
-import java.security.ProtectionDomain;
-
-import javassist.CannotCompileException;
-import javassist.CtClass;
-
-import org.jboss.classloading.spi.RealClassLoader;
-import org.jboss.logging.Logger;
-import org.jboss.virtual.plugins.context.memory.MemoryContextFactory;
-
-/**
- * @author  <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version  $Revision: 1.1 $
- */
-public class ToClassInvoker
-{
-   Logger logger = Logger.getLogger(this.getClass());
-   
-   public URL tempURL;
-
-   public Object tmplock = new Object();
-
-   public ToClassInvoker(URL tempURL)
-   {
-      this.tempURL = tempURL;
-   }
-
-   public Class<?> toClass(ToClassInvokerPoolReference pool, CtClass cc, String classFileName, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
-   {
-      boolean trace = logger.isTraceEnabled();
-      pool.lockInCache(cc);
-      final ClassLoader myloader = pool.getClassLoader();
-      if (myloader == null || tempURL == null)
-      {
-         if (trace) logger.trace(this + " " + pool + ".toClass() myloader:" + myloader + " tempURL:" + tempURL + " default to superPool.toClass for " + cc.getName());
-         Class<?> clazz = pool.superPoolToClass(cc, loader, domain);
-         if (trace) logger.trace(this + " " + pool + " myloader:" + myloader + " created class:" + clazz);
-         return clazz;
-      }
-      
-      try
-      {
-         URL outputURL = new URL(tempURL.toString() + "/" + classFileName);
-         //Write the classfile to the temporary url
-         synchronized (tmplock)
-         {
-            if (trace) logger.trace(this + " " + pool + ".toClass() myloader:" + myloader + " writing bytes to " + tempURL);
-            ByteArrayOutputStream byteout = new ByteArrayOutputStream();
-            BufferedOutputStream out = new BufferedOutputStream(byteout);
-            out.write(cc.toBytecode());
-            out.flush();
-            out.close();
-            
-            byte[] classBytes = byteout.toByteArray();
-            MemoryContextFactory factory = MemoryContextFactory.getInstance();
-            factory.putFile(outputURL, classBytes);
-
-            if (myloader instanceof RealClassLoader)
-            {
-               ((RealClassLoader)myloader).clearBlackList(classFileName);
-            }
-            
-            Class<?> clazz = myloader.loadClass(cc.getName());
-            if (trace) logger.trace(this + " " + pool + " myloader:" + myloader + " created class:" + clazz);
-            return clazz;
-         }
-      }
-      catch(Exception e)
-      {
-         ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName() + " on " + this + " loader:" + myloader);
-         cfe.initCause(e);
-         throw cfe;
-      }
-   }
-}
\ No newline at end of file

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ToClassInvokerPoolReference.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ToClassInvokerPoolReference.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/ToClassInvokerPoolReference.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,40 +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.aop.asintegration.jboss5;
-
-import java.security.ProtectionDomain;
-
-import javassist.CannotCompileException;
-import javassist.CtClass;
-
-/**
- * Exposes methods on ClassPool needed by JBoss5ClassPool
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public interface ToClassInvokerPoolReference
-{
-   Class<?> superPoolToClass(CtClass cc, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException;
-   ClassLoader getClassLoader();
-   void lockInCache(CtClass clazz);
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderDomainRegistry.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderDomainRegistry.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderDomainRegistry.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,290 +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.aop.asintegration.jboss5;
-
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.WeakHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.jboss.aop.Domain;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloading.spi.dependency.Module;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class VFSClassLoaderDomainRegistry implements DomainRegistry
-{
-   final static ClassLoaderDomain domain = new ClassLoaderDomain("NOT_USED_PLACEHOLDER");
-   
-   private ClassLoaderSystem system;
-   
-   private ClassLoaderDomain defaultDomain;
-   
-   /** classloader domains by their classloaders */
-   private Map<ClassLoader, WeakReference<ClassLoaderDomain>> classLoaderDomainsByLoader = new WeakHashMap<ClassLoader, WeakReference<ClassLoaderDomain>>();
-
-   /** aopDomains by classloader */
-   private Map<ClassLoader, ScopedVFSClassLoaderDomain> aopDomainsByClassLoader = new WeakHashMap<ClassLoader, ScopedVFSClassLoaderDomain>();
-   
-   /** aopDomains by classloader domain */
-   private Map<ClassLoaderDomain, List<ScopedVFSClassLoaderDomain>> aopDomainsByClassLoaderDomain = new WeakHashMap<ClassLoaderDomain, List<ScopedVFSClassLoaderDomain>>();
-
-   private Map<ClassLoaderDomain, ReadWriteLock> aopDomainsLocksByClassLoaderDomain = new WeakHashMap<ClassLoaderDomain, ReadWriteLock>();
-
-
-   /** parent deployment unit classloaders indexed by children */
-   private Map<ClassLoader, WeakReference<ClassLoader>> classLoaderUnitParents = new WeakHashMap<ClassLoader, WeakReference<ClassLoader>>(); 
-   
-   /** Modules by classloader */
-   private Map<ClassLoader, WeakReference<Module>> classLoaderModules = new WeakHashMap<ClassLoader, WeakReference<Module>>();
-   
-   /** classloaders by module */
-   private Map<Module, WeakReference<ClassLoader>> moduleClassLoaders = new WeakHashMap<Module, WeakReference<ClassLoader>>();
-
-   private Map<ClassLoaderDomain, Integer> classLoaderDomainReferenceCounts = new WeakHashMap<ClassLoaderDomain, Integer>();
-   
-   /**
-    * Needed for the tests, not expected to be needed in production
-    */
-   public void setSystem(ClassLoaderSystem system)
-   {
-      this.system = system;
-   }
-   
-   /**
-    * Needed for the tests, not expected to be needed in production
-    */
-   public void setDefaultDomain(ClassLoaderDomain domain)
-   {
-      this.defaultDomain = domain;
-   }
-   
-   public synchronized ClassLoaderSystem getSystem()
-   {
-      if (system == null)
-      {
-         system = ClassLoaderSystem.getInstance();
-      }
-      return system;
-   }
-   
-   public synchronized ClassLoaderDomain getDefaultDomain()
-   {
-      if (defaultDomain == null)
-      {
-         defaultDomain = getSystem().getDefaultDomain();
-      }
-      return defaultDomain;
-   }
-
-   public synchronized boolean initMapsForLoader(ClassLoader loader, Module module, ScopedVFSClassLoaderDomain domain, ClassLoader parentUnitLoader)
-   {
-      if (loader == parentUnitLoader)
-      {
-         throw new IllegalArgumentException("initMapsForLoader() should only be called if parentUnitLoader is different from loader");
-      }
-      ClassLoaderSystem system = getSystem();
-      
-      String domainName = module.getDeterminedDomainName();
-      ClassLoaderDomain clDomain = system.getDomain(domainName);
-      if (clDomain == null && domain != null)
-      {
-         throw new IllegalStateException("Have " + domain + " but no classloader domain");
-      }
-
-      boolean ret = false;
-      if (!classLoaderDomainsByLoader.containsKey(loader))
-      {
-         Integer count = classLoaderDomainReferenceCounts.get(clDomain);
-         int cnt = count == null ? 0 : count.intValue();
-         classLoaderDomainReferenceCounts.put(clDomain, cnt);
-         
-         classLoaderDomainsByLoader.put(loader, new WeakReference<ClassLoaderDomain>(clDomain));
-         classLoaderUnitParents.put(loader, new WeakReference<ClassLoader>(parentUnitLoader));
-         classLoaderModules.put(loader, new WeakReference<Module>(module));
-         moduleClassLoaders.put(module, new WeakReference<ClassLoader>(loader));
-         ret = true;
-         if (domain != null)
-         {
-            aopDomainsByClassLoader.put(loader, domain);
-
-            ReadWriteLock lock = aopDomainsLocksByClassLoaderDomain.get(clDomain);
-            if (lock == null)
-            {
-               lock = new ReentrantReadWriteLock();
-               aopDomainsLocksByClassLoaderDomain.put(clDomain, lock);
-            }
-            
-            lock.writeLock().lock();
-            try
-            {
-               List<ScopedVFSClassLoaderDomain> aopDomains = aopDomainsByClassLoaderDomain.get(clDomain);
-               if (aopDomains == null)
-               {
-                  synchronized (aopDomainsByClassLoaderDomain)
-                  {
-                     aopDomains = new CopyOnWriteArrayList<ScopedVFSClassLoaderDomain>();
-                     if (!aopDomains.contains(clDomain))
-                     {
-                        aopDomainsByClassLoaderDomain.put(clDomain, aopDomains);
-                     }
-                  }
-               }
-               aopDomains.add(domain);
-            }
-            finally
-            {
-               lock.writeLock().unlock();
-            }
-         }
-      }
-      
-      
-      return ret;
-   }
-   
-   public synchronized void cleanupLoader(ClassLoader loader)
-   {
-      WeakReference<ClassLoaderDomain> clDomainRef = classLoaderDomainsByLoader.remove(loader);
-      ClassLoaderDomain clDomain = clDomainRef == null ? null : clDomainRef.get();
-      if (clDomain != null)
-      {
-         Integer count =  classLoaderDomainReferenceCounts.get(clDomain);
-         int cnt = count == null ? 0 : count.intValue();
-         if (cnt > 0)
-         {
-            cnt--;
-         }
-         if (cnt == 0)
-         {
-            //aopDomainsByClassLoaderDomain.remove(clDomain);
-            classLoaderDomainReferenceCounts.remove(clDomain);
-         }
-         else
-         {
-            classLoaderDomainReferenceCounts.put(clDomain, ++cnt);
-         }
-         ScopedVFSClassLoaderDomain aopDomain = aopDomainsByClassLoader.remove(loader);
-         classLoaderUnitParents.remove(loader);
-         WeakReference<Module> moduleRef = classLoaderModules.remove(loader);
-         if (moduleRef != null)
-         {
-            Module module = moduleRef.get();
-            if (module != null)
-            {
-               moduleClassLoaders.remove(module);
-            }
-         }
-
-         List<ScopedVFSClassLoaderDomain> aopDomains = aopDomainsByClassLoaderDomain.get(clDomain);
-         if (aopDomains != null)
-         {
-            aopDomains.remove(aopDomain);
-         }
-         if (aopDomain != null)
-         {
-            aopDomain.getParent().unsubscribeSubDomain(aopDomain);
-         }
-      }
-      aopDomainsByClassLoader.remove(loader);
-   }
-
-   public synchronized Domain getRegisteredDomain(ClassLoader cl)
-   {
-      return aopDomainsByClassLoader.get(cl);
-   }
-   
-   public synchronized ClassLoaderDomain getClassLoaderDomainForLoader(ClassLoader cl)
-   {
-      WeakReference<ClassLoaderDomain> clDomainRef = classLoaderDomainsByLoader.get(cl);
-      if (clDomainRef != null)
-      {
-         return clDomainRef.get();
-      }
-      
-      ClassLoader parent = SecurityActions.getParent(cl);
-      if (parent != null)
-      {
-         ClassLoaderDomain domain = getClassLoaderDomainForLoader(parent);
-         if (domain != null)
-         {
-            classLoaderDomainsByLoader.put(parent, new WeakReference<ClassLoaderDomain>(domain));
-            return domain;
-         }
-      }
-      return null;
-   }
-   
-   public synchronized ClassLoader getParentUnitLoader(ClassLoader loader)
-   {
-      WeakReference<ClassLoader> parentRef = classLoaderUnitParents.get(loader);
-      if (parentRef != null)
-      {
-         return parentRef.get();
-      }
-      return null;
-   }
-   
-   public synchronized Module getModule(ClassLoader loader)
-   {
-      WeakReference<Module> moduleRef = classLoaderModules.get(loader);
-      if (moduleRef != null)
-      {
-         return moduleRef.get();
-      }
-      return null;
-   }
-   
-   public synchronized ClassLoader getClassLoader(Module module)
-   {
-      WeakReference<ClassLoader> loaderRef = moduleClassLoaders.get(module);
-      if (loaderRef != null)
-      {
-         return loaderRef.get();
-      }
-      return null;
-   }
-
-   public List<ScopedVFSClassLoaderDomain> getAOPDomainsForClassLoaderDomain(ClassLoaderDomain domain)
-   {
-      List<ScopedVFSClassLoaderDomain> domains = aopDomainsByClassLoaderDomain.get(domain);
-      if (domains != null)
-      {
-         return domains;
-      }
-      return Collections.emptyList();
-   }
-
-   public ReadWriteLock getAOPDomainsLockForClassLoaderDomain(ClassLoaderDomain domain)
-   {
-      return aopDomainsLocksByClassLoaderDomain.get(domain);
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,83 +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.aop.asintegration.jboss5;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.Domain;
-import org.jboss.aop.classpool.ExtraClassPoolFactoryParameters;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.logging.Logger;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class VFSClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicyWithRegistry
-{
-   static Logger log = Logger.getLogger(VFSClassLoaderScopingPolicy.class);
-   DomainRegistry registry = new VFSClassLoaderDomainRegistry();
-   
-   public DomainRegistry getRegistry()
-   {
-      return registry;
-   }
-
-   public void registerClassLoader(Module module, ClassLoader loader)
-   {
-      //Need to pass some data through to the classpoolfactory here
-      Map<Object, Object> properties = new HashMap<Object, Object>();
-      //The module is needed by the JBoss5ClassPoolFactory, the legacy JBossClassPoolFactory will ignore this
-      properties.put(Module.class, module);
-      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
-      Domain domain = registry.getRegisteredDomain(classLoader);
-      if (domain != null)
-      {
-         return domain;
-      }
-      
-      return null;
-   }
-
-   public Domain getTopLevelDomain(AspectManager parent)
-   {
-      Thread.currentThread().getContextClassLoader();
-      return null;
-   }
-}
-   

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/main/java/org/jboss/aop/asintegration/jboss5/VFSClassLoaderScopingPolicy.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,82 @@
+/*
+* 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.aop.asintegration.jboss5;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.classpool.ExtraClassPoolFactoryParameters;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.logging.Logger;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class VFSClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicyWithRegistry
+{
+   static Logger log = Logger.getLogger(VFSClassLoaderScopingPolicy.class);
+   AOPDomainRegistry registry = new AOPVFSClassLoaderDomainRegistry();
+   
+   public AOPDomainRegistry getRegistry()
+   {
+      return registry;
+   }
+
+   public void registerClassLoader(Module module, ClassLoader loader)
+   {
+      //Need to pass some data through to the classpoolfactory here
+      Map<Object, Object> properties = new HashMap<Object, Object>();
+      //The module is needed by the JBoss5ClassPoolFactory, the legacy JBossClassPoolFactory will ignore this
+      properties.put(Module.class, module);
+      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
+      Domain domain = registry.getRegisteredDomain(classLoader);
+      if (domain != null)
+      {
+         return domain;
+      }
+      
+      return null;
+   }
+
+   public Domain getTopLevelDomain(AspectManager parent)
+   {
+      Thread.currentThread().getContextClassLoader();
+      return null;
+   }
+}
\ No newline at end of file

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/AlwaysWritablePermissionCollectionTestPolicyPlugin.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/AlwaysWritablePermissionCollectionTestPolicyPlugin.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/AlwaysWritablePermissionCollectionTestPolicyPlugin.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,118 +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.test.aop.classpool.jbosscl.support;
-
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.SecurityPermission;
-import java.util.Enumeration;
-import java.util.PropertyPermission;
-
-import org.jboss.test.security.TestsPolicyPlugin;
-
-/**
- * The original TestPolicyPlugin reuses the underlying PermissionCollection. This causes problems
- * for tests creating several ProtectionDomains, since the ProtectionDomain's constructor 
- * marks the PolicyCollection as read-only so we get errors
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class AlwaysWritablePermissionCollectionTestPolicyPlugin extends TestsPolicyPlugin
-{
-   public AlwaysWritablePermissionCollectionTestPolicyPlugin(Class<?> clazz)
-   {
-      super(clazz);
-   }
-
-   public synchronized PermissionCollection getPermissions(CodeSource codesource)
-   {
-      return new AlwaysWritablePermissionCollection(super.getPermissions(codesource));
-   }
-   
-   public static void initialisePlugin()
-   {
-      System.setProperty("org.jboss.test.security.PolicyPlugin", AlwaysWritablePermissionCollectionTestPolicyPlugin.class.getName());
-   }
-   
-   public static void cleanupPlugin()
-   {
-      System.clearProperty("org.jboss.test.security.PolicyPlugin");
-   }
-   
-   private static class AlwaysWritablePermissionCollection extends PermissionCollection
-   {
-      private static final long serialVersionUID = 1L;
-      
-      volatile PermissionCollection lastDelegate;
-      volatile PermissionCollection delegate;
-      
-      final static Permission GET_POLICY = new SecurityPermission("getPolicy");
-      final static Permission PARENT_PKGS = new PropertyPermission("jboss.test.parent.pkgs", "read");
-      
-      private AlwaysWritablePermissionCollection(PermissionCollection delegate)
-      {
-         this.delegate = delegate;
-      }
-
-      public void add(Permission permission)
-      {
-         delegate.add(permission);
-      }
-
-      public Enumeration<Permission> elements()
-      {
-         return delegate.elements();
-      }
-
-      public boolean equals(Object obj)
-      {
-         return delegate.equals(obj);
-      }
-
-      public int hashCode()
-      {
-         return delegate.hashCode();
-      }
-
-      public boolean implies(Permission permission)
-      {
-         return delegate.implies(permission);
-      }
-
-      public boolean isReadOnly()
-      {
-         return delegate.isReadOnly();
-      }
-
-      public void setReadOnly()
-      {
-         //ignore
-      }
-
-      public String toString()
-      {
-         return delegate.toString();
-      }
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/BundleInfoBuilder.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/BundleInfoBuilder.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/BundleInfoBuilder.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,179 +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.test.aop.classpool.jbosscl.support;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.classloading.spi.metadata.Capability;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
-import org.jboss.classloading.spi.metadata.Requirement;
-import org.jboss.classloading.spi.version.VersionRange;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class BundleInfoBuilder
-{
-   static ClassLoadingMetaDataFactory clmdf = ClassLoadingMetaDataFactory.getInstance();
-   
-   List<Capability> capabilities = new ArrayList<Capability>();
-   List<Requirement> requirements = new ArrayList<Requirement>();
-   
-   private BundleInfoBuilder()
-   {
-      
-   }
-   
-   public static BundleInfoBuilder getBuilder()
-   {
-      return new BundleInfoBuilder();
-   }
-   
-   public BundleInfoBuilder createModule(String name)
-   {
-      capabilities.add(clmdf.createModule(name));
-      return this;
-   }
-   
-   public BundleInfoBuilder createModule(String name, Object version)
-   {
-      capabilities.add(clmdf.createModule(name, version));
-      return this;
-   }
-   
-   public BundleInfoBuilder createRequireModule(String name)
-   {
-      requirements.add(clmdf.createRequireModule(name, null));
-      return this;
-   }
-
-   public BundleInfoBuilder createRequireModule(String name, VersionRange versionRange)
-   {
-      requirements.add(clmdf.createRequireModule(name, versionRange));
-      return this;
-   }
-
-   public BundleInfoBuilder createRequireModule(String name, VersionRange versionRange, boolean optional, boolean reExport, boolean dynamic)
-   {
-      requirements.add(clmdf.createRequireModule(name, versionRange, optional, reExport, dynamic));
-      return this;
-   }
-
-   public BundleInfoBuilder createPackage(String name)
-   {
-      capabilities.add(clmdf.createPackage(name));
-      return this;
-   }
-
-   public BundleInfoBuilder createPackage(String name, Object version)
-   {
-      capabilities.add(clmdf.createPackage(name, version));
-      return this;
-   }
-
-   public BundleInfoBuilder createRequirePackage(String name)
-   {
-      requirements.add(clmdf.createRequirePackage(name));
-      return this;
-   }
-
-   public BundleInfoBuilder createRequirePackage(String name, VersionRange versionRange)
-   {
-      requirements.add(clmdf.createRequirePackage(name, versionRange));
-      return this;
-   }
-
-   public BundleInfoBuilder createRequirePackage(String name, VersionRange versionRange, boolean optional, boolean reExport, boolean dynamic)
-   {
-      requirements.add(clmdf.createRequirePackage(name, versionRange, optional, reExport, dynamic));
-      return this;
-   }
-
-   public BundleInfoBuilder createReExportModule(String name)
-   {
-      requirements.add(clmdf.createReExportModule(name));
-      return this;
-   }
-
-   public BundleInfoBuilder createReExportModule(String name, VersionRange versionRange)
-   {
-      requirements.add(clmdf.createReExportModule(name, versionRange));
-      return this;
-   }
-
-   public BundleInfoBuilder createReExportModule(String name, VersionRange versionRange, boolean optional)
-   {
-      requirements.add(clmdf.createReExportModule(name, versionRange, optional));
-      return this;
-   }
-
-   public BundleInfoBuilder createReExportPackage(String name)
-   {
-      requirements.add(clmdf.createReExportPackage(name));
-      return this;
-   }
-
-   public BundleInfoBuilder createReExportPackage(String name, VersionRange versionRange)
-   {
-      requirements.add(clmdf.createReExportPackage(name, versionRange));
-      return this;
-   }
-
-   public BundleInfoBuilder createReExportPackage(String name, VersionRange versionRange, boolean optional)
-   {
-      requirements.add(clmdf.createReExportPackage(name, versionRange, optional));
-      return this;
-   }
-   
-   public BundleInfoBuilder createUsesPackage(String name)
-   {
-      requirements.add(clmdf.createUsesPackage(name));
-      return this;
-   }
-
-   public BundleInfoBuilder createUsesPackage(String name, VersionRange versionRange)
-   {
-      requirements.add(clmdf.createUsesPackage(name, versionRange));
-      return this;
-   }
-
-   public BundleInfoBuilder createUsesPackage(String name, VersionRange versionRange, boolean reExport)
-   {
-      requirements.add(clmdf.createUsesPackage(name, versionRange, reExport));
-      return this;
-   }
-
-   
-   
-   public List<Capability> getCapabilities()
-   {
-      return capabilities;
-   }
-   
-   public List<Requirement> getRequirements()
-   {
-      return requirements;
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/CapabilityInfo.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/CapabilityInfo.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/CapabilityInfo.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,42 +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.test.aop.classpool.jbosscl.support;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class CapabilityInfo extends ModuleOrPackageInfo
-{
-   public CapabilityInfo(String name, Object version)
-   {
-      // FIXME ModuleCapabilityInfo constructor
-      super(name, version);
-   }
-
-   public CapabilityInfo(String name)
-   {
-      // FIXME ModuleCapabilityInfo constructor
-      super(name);
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/ModuleOrPackageInfo.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/ModuleOrPackageInfo.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/ModuleOrPackageInfo.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,55 +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.test.aop.classpool.jbosscl.support;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public abstract class ModuleOrPackageInfo
-{
-   private String name;
-   
-   private Object version;
-
-   public ModuleOrPackageInfo(String name, Object version)
-   {
-      this.name = name;
-      this.version = version;
-   }
-
-   public ModuleOrPackageInfo(String name)
-   {
-      this(name, null);
-   }
-
-   public String getName()
-   {
-      return name;
-   }
-
-   public Object getVersion()
-   {
-      return version;
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/NoMatchClassFilter.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/NoMatchClassFilter.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/NoMatchClassFilter.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2007, 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.aop.classpool.jbosscl.support;
-
-import org.jboss.classloader.plugins.ClassLoaderUtils;
-import org.jboss.classloader.spi.filter.ClassFilter;
-
-/**
- * NoMatchClassFilter.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class NoMatchClassFilter implements ClassFilter
-{
-   String className;
-   
-   public boolean filtered = false;
-   
-   public NoMatchClassFilter(String classname)
-   {
-      this.className = classname;
-   }
-   
-   public boolean matchesClassName(String className)
-   {
-      if (this.className.equals(className))
-      {
-         filtered = true;
-         return false;
-      }
-      return true;
-   }
-   
-   public boolean matchesResourcePath(String resourcePath)
-   {
-      if (ClassLoaderUtils.classNameToPath(this.className).equals(resourcePath))
-      {
-         filtered = true;
-         return false;
-      }
-      return true;
-   }
-   
-   public boolean matchesPackageName(String packageName)
-   {
-      if (ClassLoaderUtils.getClassPackageName(this.className).equals(packageName))
-         return false;
-      return true;
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/RequirementInfo.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/RequirementInfo.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/RequirementInfo.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,75 +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.test.aop.classpool.jbosscl.support;
-
-import org.jboss.classloading.spi.version.VersionRange;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class RequirementInfo extends ModuleOrPackageInfo
-{
-   boolean optional;
-   boolean reExport;
-   boolean dynamic;
-   
-   public RequirementInfo(String name, VersionRange range)
-   {
-      super(name, range);
-   }
-
-   public RequirementInfo(String name)
-   {
-      super(name);
-   }
-
-   public RequirementInfo(String name, VersionRange range, boolean optional, boolean reExport, boolean dynamic)
-   {
-      super(name, range);
-      this.optional = optional;
-      this.reExport = reExport;
-      this.dynamic = dynamic;
-   }
-   
-   @Override
-   public VersionRange getVersion()
-   {
-      return (VersionRange)super.getVersion();
-   }
-
-   public boolean isOptional()
-   {
-      return optional;
-   }
-
-   public boolean isReExport()
-   {
-      return reExport;
-   }
-
-   public boolean isDynamic()
-   {
-      return dynamic;
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/Result.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/Result.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/Result.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,42 +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.test.aop.classpool.jbosscl.support;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class Result
-{
-   private TestVFSClassLoaderFactory factory;
-
-   public TestVFSClassLoaderFactory getFactory()
-   {
-      return factory;
-   }
-
-   public void setFactory(TestVFSClassLoaderFactory factory)
-   {
-      this.factory = factory;
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactory.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactory.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactory.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,104 +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.test.aop.classpool.jbosscl.support;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule;
-import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class TestVFSClassLoaderFactory extends VFSClassLoaderFactory
-{
-   private static final long serialVersionUID = 1L;
-   
-   private ClassLoader parent;
-
-   @Override
-   protected Class<? extends VFSClassLoaderPolicyModule> getModuleClass()
-   {
-      return TestVFSClassLoaderPolicyModule.class;
-   }
-   
-   public void setParent(ClassLoader parent)
-   {
-      this.parent = parent;
-   }
-   
-   @Override
-   public List<BeanMetaData> getBeans()
-   {
-
-       List<BeanMetaData> result = super.getBeans();
-      if (parent != null)
-      {
-         //We need to modify the Module factory method used to create the classloader to pass in the parent
-         if (result.size() != 2)
-         {
-            throw new IllegalStateException("Expected size=2, was " + result.size());
-         }
-      
-         BeanMetaData classLoader = null;
-         BeanMetaData module = null;
-         for (BeanMetaData bean : result)
-         {
-            if (bean.getBean().equals(ClassLoader.class.getName()))
-            {
-               classLoader = bean;
-            }
-            else
-            {
-               module = bean;
-            }
-         }
-         
-         if (module == null)
-         {
-            throw new IllegalStateException("Could not find module");
-         }
-         if (classLoader == null)
-         {
-            throw new IllegalStateException("Could not find module");
-         }
-         
-         BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(classLoader.getName(), ClassLoader.class.getName());
-         builder.setNoClassLoader();
-         builder.setFactory(module.getName());
-         builder.setFactoryMethod("registerClassLoaderPolicy");
-         builder.addConstructorParameter(ClassLoaderSystem.class.getName(), builder.createInject(getClassLoaderSystemName()));
-         builder.addConstructorParameter(ClassLoader.class.getName(), parent);
-         classLoader = builder.getBeanMetaData();
-
-         result = Arrays.asList(classLoader, module);
-      }
-      
-      return result;
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactoryFactory.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactoryFactory.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactoryFactory.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,135 +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.test.aop.classpool.jbosscl.support;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.metadata.ExportAll;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class TestVFSClassLoaderFactoryFactory
-{
-   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, URL... urls) throws Exception
-   {
-      return createClassLoaderFactory(name, importAll, null, false, urls);
-   }
-   
-   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, BundleInfoBuilder builder, URL... urls) throws Exception
-   {
-      return createClassLoaderFactory(name, importAll, null, null, builder, false, urls);
-   }
-   
-   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, String domainName, BundleInfoBuilder builder, boolean parentFirst, URL... urls) throws Exception
-   {
-      return createClassLoaderFactory(name, domainName, null, builder, parentFirst, urls);
-   }
-   
-   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, String domainName, String parentDomainName, BundleInfoBuilder builder, boolean parentFirst, URL... urls) throws Exception
-   {
-      return createClassLoaderFactory(name, false, domainName, parentDomainName, builder, false, urls);
-   }
-
-   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, String moduleName, URL... urls) throws Exception
-   {
-      return createClassLoaderFactory(name, importAll, null, false, urls);
-   }
-   
-   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, String domainName, boolean parentFirst, URL... urls) throws Exception
-   {
-      return createClassLoaderFactory(name, importAll, domainName, null, parentFirst, urls);
-   }
-
-   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, String domainName, String parentDomainName, boolean parentFirst, URL... urls) throws Exception
-   {
-      return createClassLoaderFactory(name, importAll, domainName, parentDomainName, null, parentFirst, urls);
-   }
-   
-   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, String domainName, String parentDomainName, BundleInfoBuilder builder, boolean parentFirst, URL... urls) throws Exception
-   {
-      TestVFSClassLoaderFactory factory = new TestVFSClassLoaderFactory();
-      factory.setName(name);
-      factory.setImportAll(importAll);
-      if (importAll)
-      {
-         factory.setExportAll(ExportAll.NON_EMPTY);
-      }
-      factory.setRoots(urlsToStringList(urls));
-      addCapabilitiesAndRequirements(factory, builder);
-      setupDomain(factory, domainName, parentDomainName, parentFirst);
-      return factory;
-   }
-
-   private static void addCapabilitiesAndRequirements(ClassLoadingMetaData md, BundleInfoBuilder builder)
-   {
-      if (builder != null)
-      {
-         md.getCapabilities().setCapabilities(builder.getCapabilities());
-         md.getRequirements().setRequirements(builder.getRequirements());
-      }
-   }
-
-   private static void setupDomain(ClassLoadingMetaData md, String domainName, String parentDomainName, boolean parentFirst)
-   {
-      if (domainName != null)
-      {
-         md.setDomain(domainName);
-         md.setJ2seClassLoadingCompliance(parentFirst);
-         if (parentDomainName != null)
-         {
-            md.setParentDomain(parentDomainName);
-         }
-         else
-         {
-            md.setParentDomain(ClassLoaderSystem.DEFAULT_DOMAIN_NAME);
-         }
-      }
-      else
-      {
-         md.setDomain(ClassLoaderSystem.DEFAULT_DOMAIN_NAME);
-      }
-   }
-   
-   private static List<String> urlsToStringList(URL... urls)
-   {
-      List<String> urlList = new ArrayList<String>(urls.length);
-      if (urls.length > 0)
-      {
-         for (URL url : urls)
-         {
-            if (url != null)
-            {
-               urlList.add(url.toString());
-            }
-         }
-      }
-      return urlList;
-   }
-
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderPolicyModule.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderPolicyModule.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderPolicyModule.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,92 +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.test.aop.classpool.jbosscl.support;
-
-import java.net.URL;
-
-import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule;
-import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
-import org.jboss.util.id.GUID;
-import org.jboss.virtual.MemoryFileFactory;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class TestVFSClassLoaderPolicyModule extends VFSClassLoaderPolicyModule
-{
-   private static final long serialVersionUID = 1;
-   
-   /** In AS we need a URL to create the temporary files */
-   URL dynamicClassRoot;
-   VirtualFile classes;
-
-   public TestVFSClassLoaderPolicyModule(VFSClassLoaderFactory classLoadingMetaData, String contextName)
-   {
-      // FIXME TesetMockClassLoaderPolicyModule constructor
-      super(classLoadingMetaData, contextName);
-   }
-
-   /**
-    * Get/Create the vfs memory file where we will create dynamic classes
-    */
-   @Override
-   public URL getDynamicClassRoot()
-   {
-      initDynamicClassRoot();
-      return dynamicClassRoot;
-   }
-   
-   /**
-    * Prepend the dynamic URL location to the classpath
-    */
-   @Override
-   protected VirtualFile[] determineVFSRoots()
-   {
-      initDynamicClassRoot();
-      VirtualFile[] roots = super.determineVFSRoots();
-      VirtualFile[] newRoots = new VirtualFile[roots.length + 1];
-      newRoots[0] = classes;
-      System.arraycopy(roots, 0, newRoots, 1, roots.length);
-      
-      return newRoots;
-   }
-   
-   private synchronized void initDynamicClassRoot()
-   {
-      if (dynamicClassRoot == null)
-      {
-         try
-         {
-            dynamicClassRoot = new URL("vfsmemory", GUID.asString(), "");
-            classes = MemoryFileFactory.createRoot(dynamicClassRoot).getRoot();
-         }
-         catch (Exception e)
-         {
-            // AutoGenerated
-            throw new RuntimeException(e);
-         }
-      }
-   }
-}

Deleted: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/excluded/replacereferences/Invoked.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/excluded/replacereferences/Invoked.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/support/excluded/replacereferences/Invoked.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -1,39 +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.test.aop.classpool.jbosscl.support.excluded.replacereferences;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class Invoked
-{
-   public static boolean invoked;
-   
-   public static boolean getAndReset()
-   {
-      boolean inv = invoked;
-      invoked = false;
-      return inv;
-   }
-}

Modified: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/weaving/test/WeavingTest.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/weaving/test/WeavingTest.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/classpool/jbosscl/weaving/test/WeavingTest.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -28,9 +28,9 @@
 
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.AspectXmlLoader;
-import org.jboss.test.aop.classpool.jbosscl.support.BundleInfoBuilder;
-import org.jboss.test.aop.classpool.jbosscl.test.JBossClClassPoolTest;
 import org.jboss.test.aop.classpool.jbosscl.weaving.support.TestTranslator;
+import org.jboss.test.classpool.jbosscl.test.JBossClClassPoolTest;
+import org.jboss.test.classpool.support.BundleInfoBuilder;
 
 /**
  * 
@@ -41,9 +41,9 @@
 {
    public final static String DOMAIN = "AOPClasses";
    
-   public final static URL JAR_TARGET = getURLRelativeToProjectRoot("target/jboss-aop-asintegration-mc-test-weaving-target.jar");
-   public final static URL JAR_ASPECTS = getURLRelativeToProjectRoot("target/jboss-aop-asintegration-mc-test-weaving-aspects.jar");
-   public final static URL JAR_INTERCEPTIONS = getURLRelativeToProjectRoot("target/jboss-aop-asintegration-mc-test-weaving-interceptions.jar");
+   public final static URL JAR_TARGET = getURLRelativeToProjectRoot("jboss-aop-asintegration-mc-test-weaving-target.jar");
+   public final static URL JAR_ASPECTS = getURLRelativeToProjectRoot("jboss-aop-asintegration-mc-test-weaving-aspects.jar");
+   public final static URL JAR_INTERCEPTIONS = getURLRelativeToProjectRoot("jboss-aop-asintegration-mc-test-weaving-interceptions.jar");
 
 
    public static final String PACKAGE_TARGET = "org.jboss.test.aop.classpool.jbosscl.weaving.support.excluded.target";

Modified: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/scopeddomain/test/ScopedVFSClassLoaderDomainTestCase.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/scopeddomain/test/ScopedVFSClassLoaderDomainTestCase.java	2009-08-14 12:08:27 UTC (rev 92353)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/aop/scopeddomain/test/ScopedVFSClassLoaderDomainTestCase.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -45,6 +45,8 @@
 import org.jboss.aop.advice.Scope;
 import org.jboss.aop.advice.ScopedInterceptorFactory;
 import org.jboss.aop.array.ArrayReplacement;
+import org.jboss.aop.asintegration.jboss5.AOPDomainRegistry;
+import org.jboss.aop.asintegration.jboss5.AOPVFSClassLoaderDomainRegistry;
 import org.jboss.aop.asintegration.jboss5.ScopedVFSClassLoaderDomain;
 import org.jboss.aop.introduction.AnnotationIntroduction;
 import org.jboss.aop.introduction.InterfaceIntroduction;
@@ -58,7 +60,12 @@
 import org.jboss.aop.pointcut.Typedef;
 import org.jboss.aop.pointcut.TypedefExpression;
 import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.test.aop.classpool.jbosscl.test.JBossClClassPoolTest;
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classpool.ClassPoolRepository;
+import org.jboss.classpool.jboss5.RegisterModuleCallback;
+import org.jboss.classpool.jbosscl.JBossClDelegatingClassPoolFactory;
+import org.jboss.test.classpool.jbosscl.test.JBossClClassPoolTest;
+import org.jboss.virtual.VFS;
 
 /**
  * 
@@ -67,6 +74,16 @@
  */
 public class ScopedVFSClassLoaderDomainTestCase extends JBossClClassPoolTest
 {
+   //protected static AOPVFSClassLoaderDomainRegistry aopDomainRegistry;
+   
+   ClassLoading classLoading = new ClassLoading();
+
+   static
+   {
+      ClassPoolRepository.getInstance().setClassPoolFactory(new JBossClDelegatingClassPoolFactory(domainRegistry, new RegisterModuleCallback()));
+      VFS.init();
+   }
+   
    public static Test suite()
    {
       return new TestSuite(ScopedVFSClassLoaderDomainTestCase.class);
@@ -1730,4 +1747,37 @@
          unregisterDomain(middleDomain);
       }
    }
+
+   public class ScopedVFSClassLoaderDomainSetup
+   {
+      ScopedVFSClassLoaderDomain domain;
+      
+      String name;
+      boolean parentDelegation;
+      AspectManager manager;
+      boolean parentFirst; 
+      AOPDomainRegistry registry;
+      
+      public ScopedVFSClassLoaderDomainSetup(String name, boolean parentDelegation, AspectManager manager, boolean parentFirst, AOPDomainRegistry registry)
+      {
+         this.name = name;
+         this.parentDelegation = parentDelegation;
+         this.manager = manager;
+         this.parentFirst = parentFirst;
+         this.registry = registry;
+      }
+      
+      public ScopedVFSClassLoaderDomain getDomain()
+      {
+         return domain;
+      }
+
+      public void setClassLoaderAndDomain(ClassLoader loader, ClassLoaderDomain clDomain)
+      {
+         if (domain == null)
+         {
+            domain = new ScopedVFSClassLoaderDomain(loader, name, parentDelegation, manager, parentFirst, clDomain, registry);
+         }
+      }
+   }
 }
\ No newline at end of file

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTest.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,1014 @@
+/*
+* 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.test.classpool.jbosscl.test;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import junit.framework.Test;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.asintegration.jboss5.AOPVFSClassLoaderDomainRegistry;
+import org.jboss.aop.asintegration.jboss5.ScopedVFSClassLoaderDomain;
+import org.jboss.aop.newclasspool.AOPClassPoolFactory;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.classloader.plugins.filter.CombiningClassFilter;
+import org.jboss.classloader.plugins.filter.PatternClassFilter;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.classloader.spi.filter.PackageClassFilter;
+import org.jboss.classloader.test.support.IsolatedClassLoaderTestHelper;
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classpool.ClassPoolRepository;
+import org.jboss.classpool.jboss5.RegisterModuleCallback;
+import org.jboss.classpool.jbosscl.JBossClDelegatingClassPoolFactory;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.test.AbstractTestCaseWithSetup;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.aop.scopeddomain.test.ScopedVFSClassLoaderDomainTestCase.ScopedVFSClassLoaderDomainSetup;
+import org.jboss.test.classpool.support.BundleInfoBuilder;
+import org.jboss.test.classpool.support.Result;
+import org.jboss.test.classpool.support.SupportClasses;
+import org.jboss.test.classpool.support.TestVFSClassLoaderFactory;
+import org.jboss.test.classpool.support.TestVFSClassLoaderFactoryFactory;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.virtual.VFS;
+
+/**
+ * Base class for testing the new JBoss classloaders
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossClClassPoolTest extends MicrocontainerTest
+{
+   public final static URL JAR_A_1 = getURLRelativeToProjectRoot(SupportClasses.JAR_A_1);
+   public final static URL JAR_A_2 = getURLRelativeToProjectRoot(SupportClasses.JAR_A_2);
+   public final static URL JAR_B_1 = getURLRelativeToProjectRoot(SupportClasses.JAR_B_1);
+   public final static URL JAR_B_2 = getURLRelativeToProjectRoot(SupportClasses.JAR_B_2);
+   public final static URL JAR_C_1 = getURLRelativeToProjectRoot(SupportClasses.JAR_C_1);
+   public final static URL JAR_C_2 = getURLRelativeToProjectRoot(SupportClasses.JAR_C_2);
+
+   //Keep a strong reference to the URL classloaders so that they are not garbage collected
+   final static Set<URLClassLoader> registeredURLClassLoaders = new HashSet<URLClassLoader>();
+
+   private Map<ClassLoader, ClassLoaderDomain> scopedChildDomainsByLoader = new WeakHashMap<ClassLoader, ClassLoaderDomain>();
+   
+   private LoaderNameDeploymentRegistry loaderNameDeploymentRegistry = new LoaderNameDeploymentRegistry();
+   
+   /** The classloader helper */
+   protected static final ClassLoaderSystem system = ClassLoaderSystem.getInstance();
+   private static boolean initialisedDefaultDomain;
+   private static final ClassFilter aopFilter;
+   static
+   {
+      String[] classPatterns = new String[] {
+            "org\\.jboss\\.aop\\..+", 
+            "org\\.jboss\\.classloading\\..+", 
+            "org\\.jboss\\.classloader\\..+", 
+            "org\\.jboss\\.virtual\\..+", 
+            "org\\.jboss\\.test\\.classpool\\.jbosscl\\..+\\..+", 
+            "org\\.jboss\\.metadata\\..+",
+            "org\\.test\\.classpool\\.proxy\\..+"};
+      String[] resourcePatterns = new String[] {
+            "org/jboss/aop/.+", 
+            "org/jboss/classloading/.+", 
+            "org/jboss/classloader/.+", 
+            "org/jboss/virtual/.+", 
+            "org/jboss/test/classpool/jbosscl/.+\\..+", 
+            "org/jboss/metadata/.+",
+            "org/test/classpool/proxy/.+"};
+      aopFilter = new PatternClassFilter(classPatterns, resourcePatterns, null);
+   }
+   
+   protected static AOPVFSClassLoaderDomainRegistry domainRegistry;
+   
+   ClassLoading classLoading = new ClassLoading();
+
+   static
+   {
+
+      domainRegistry = new AOPVFSClassLoaderDomainRegistry();
+      
+      // TODO remove this later; currently, AspectManager sets the classpoolfactory
+      // at ScopedClassPoolRepositoryImpl, overwriting the setClassPoolFactory command below
+      // Notice that AspectManager.instance() is invoked by AOPDependencyBuilder, so
+      // we have no way of avoiding AspectManager creation
+      AspectManager.instance();
+      ClassPoolRepository.getInstance().setClassPoolFactory(new AOPClassPoolFactory());
+      AOPClassPoolFactory.setDelegateClassPoolFactory(new JBossClDelegatingClassPoolFactory(domainRegistry, new RegisterModuleCallback()));
+      VFS.init();
+   }
+
+
+   public static ClassLoaderSystem getSystem()
+   {
+      if (!initialisedDefaultDomain)
+      {
+         ClassLoaderDomain defaultDomain = system.getDefaultDomain();
+         
+         Set<String> parentPackages = IsolatedClassLoaderTestHelper.getParentPackages();
+         String[] parentPkgs = parentPackages.toArray(new String[parentPackages.size()]);
+         PackageClassFilter filter = new PackageClassFilter(parentPkgs);
+         filter.setIncludeJava(true);
+         CombiningClassFilter beforeFilter = CombiningClassFilter.create(filter, aopFilter);
+         ParentPolicy parentPolicy = new ParentPolicy(beforeFilter, ClassFilter.NOTHING);
+         
+         defaultDomain.setParentPolicy(parentPolicy);
+      }
+      return system;
+   }
+   
+   public static Test suite(Class<?> clazz)
+   {
+      return AbstractTestCaseWithSetup.suite(clazz);
+   }
+   
+   public JBossClClassPoolTest(String name)
+   {
+      super(name);
+   }
+
+
+   public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+   {
+      return new JBossClClassPoolTestDelegate(clazz);
+   }
+   
+
+   protected static URL getURLRelativeToProjectRoot(String relativePath)
+   {
+      try
+      {
+         URL url = JBossClClassPoolTest.class.getProtectionDomain().getCodeSource().getLocation();
+         String location = url.toString();
+         int index = location.lastIndexOf("/target/") + "/target/".length();
+         location = location.substring(0, index);
+         
+         location = location + relativePath;
+         return new URL(location);
+      }
+      catch (MalformedURLException e)
+      {
+         // AutoGenerated
+         throw new RuntimeException(e);
+      }
+   }
+   
+   protected ClassLoaderDomain getDefaultDomain()
+   {
+      return getSystem().getDefaultDomain();
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      //enableTrace("org.jboss.aop.classpool");
+      //enableTrace("org.jboss.classpool.jbosscl");
+      deploy("/org/jboss/test/classpool/jbosscl/Common.xml");
+   }
+
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      undeploy("/org/jboss/test/classpool/jbosscl/Common.xml");
+      super.tearDown();
+   }
+
+   protected String array(String name)
+   {
+      return name + "[]";
+   }
+
+   protected ClassLoader createClassLoader(String name, boolean importAll, URL... urls) throws Exception
+   {
+      return createClassLoader(null, name, importAll, urls);
+   }
+   
+   protected ClassLoader createClassLoader(Result result, String name, boolean importAll, URL... urls) throws Exception
+   {
+      TestVFSClassLoaderFactory factory = TestVFSClassLoaderFactoryFactory.createClassLoaderFactory(name, importAll, urls);
+      return createClassLoader(result, factory);
+   }
+   
+   protected ClassLoader createClassLoader(String name, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createClassLoader(null, name, builder, urls);
+   }
+   
+   protected ClassLoader createClassLoader(Result result, String name, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createClassLoader(result, name, false, builder, urls);
+   }
+      
+   protected ClassLoader createClassLoader(String name, boolean importAll, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createClassLoader(null, name, importAll, builder, urls);
+   }
+      
+   protected ClassLoader createClassLoader(Result result, String name, boolean importAll, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      TestVFSClassLoaderFactory factory = TestVFSClassLoaderFactoryFactory.createClassLoaderFactory(name, importAll, builder, urls);
+      return createClassLoader(result, factory);
+   }
+      
+   protected ClassLoader createChildDomainParentFirstClassLoader(String name, String domainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassLoader((Result)null, name, domainName, importAll, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentFirstClassLoader(Result result, String name, String domainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassLoader(result, name, domainName, importAll, null, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentFirstClassLoader(String name, String domainName, boolean importAll, ClassLoader parent, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassLoader(null, name, domainName, importAll, parent, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentFirstClassLoader(Result result, String name, String domainName, boolean importAll, ClassLoader parent, URL... urls) throws Exception
+   {
+      return createChildDomainClassLoader(result, name, domainName, null, true, importAll, parent, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentFirstClassLoader(String name, String domainName, String parentDomainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassLoader(null, name, domainName, parentDomainName, importAll, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentFirstClassLoader(Result result, String name, String domainName, String parentDomainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainClassLoader(result, name, domainName, parentDomainName, true, importAll, null, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentLastClassLoader(String name, String domainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassLoader((Result)null, name, domainName, importAll, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentLastClassLoader(Result result, String name, String domainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassLoader(result, name, domainName, importAll, null, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentLastClassLoader(String name, String domainName, boolean importAll, ClassLoader parent, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassLoader(null, name, domainName, importAll, parent, urls);
+   }
+
+   protected ClassLoader createChildDomainParentLastClassLoader(Result result, String name, String domainName, boolean importAll, ClassLoader parent, URL... urls) throws Exception
+   {
+      return createChildDomainClassLoader(result, name, domainName, null, false, importAll, parent, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentLastClassLoader(String name, String domainName, String parentDomainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassLoader(null, name, domainName, parentDomainName, importAll, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentLastClassLoader(Result result, String name, String domainName, String parentDomainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainClassLoader(result, name, domainName, parentDomainName, false, importAll, null, urls);
+   }
+
+   protected ClassLoader createChildDomainClassLoader(String name, String domainName, String parentDomainName, boolean parentFirst, boolean importAll, ClassLoader parent, URL... urls) throws Exception
+   {
+      return createChildDomainClassLoader(null, name, domainName, parentDomainName, parentFirst, importAll, parent, urls);
+   }
+   
+   protected ClassLoader createChildDomainClassLoader(Result result, String name, String domainName, String parentDomainName, boolean parentFirst, boolean importAll, ClassLoader parent, URL... urls) throws Exception
+   {
+      TestVFSClassLoaderFactory factory = TestVFSClassLoaderFactoryFactory.createClassLoaderFactory(name, importAll, domainName, parentDomainName, parentFirst, urls);
+      
+      ClassLoader classLoader = createClassLoader(result, factory, parent);
+
+      registerDomainAndLoader(classLoader, domainName);
+      return classLoader;
+   }
+
+   protected ClassLoader createChildDomainParentFirstClassLoader(String name, String domainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassLoader((Result)null, name, domainName, builder, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentFirstClassLoader(Result result, String name, String domainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassLoader(result, name, domainName, null, builder, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentFirstClassLoader(String name, String domainName, String parentDomainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassLoader(null, name, domainName, parentDomainName, builder, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentFirstClassLoader(Result result, String name, String domainName, String parentDomainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainClassLoader(result, name, domainName, parentDomainName, builder, true, urls);
+   }
+      
+   protected ClassLoader createChildDomainParentLastClassLoader(String name, String domainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassLoader((Result)null, name, domainName, builder, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentLastClassLoader(Result result, String name, String domainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassLoader(result, name, domainName, null, builder, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentLastClassLoader(String name, String domainName, String parentDomainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassLoader(null, name, domainName, parentDomainName, builder, urls);
+   }
+   
+   protected ClassLoader createChildDomainParentLastClassLoader(Result result, String name, String domainName, String parentDomainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainClassLoader(result, name, domainName, parentDomainName, builder, false, urls);
+   }
+   
+   protected ClassLoader createChildDomainClassLoader(String name, String domainName, String parentDomainName, BundleInfoBuilder builder, boolean parentFirst, URL... urls) throws Exception
+   {
+      return createChildDomainClassLoader(null, name, domainName, parentDomainName, builder, parentFirst, urls);
+   }
+   
+   protected ClassLoader createChildDomainClassLoader(Result result, String name, String domainName, String parentDomainName, BundleInfoBuilder builder, boolean parentFirst, URL... urls) throws Exception
+   {
+      TestVFSClassLoaderFactory factory = TestVFSClassLoaderFactoryFactory.createClassLoaderFactory(name, domainName, parentDomainName, builder, parentFirst, urls);
+
+      ClassLoader classLoader = createClassLoader(result, factory);
+
+      registerDomainAndLoader(classLoader, domainName);
+      return classLoader;
+   }
+   
+   private void registerDomainAndLoader(ClassLoader classLoader, String domainName)
+   {
+      ClassLoaderDomain domain = getSystem().getDomain(domainName);
+      scopedChildDomainsByLoader.put(classLoader, domain);
+   }
+   
+   protected ClassLoader createChildURLClassLoader(ClassLoader parent, URL url)
+   {
+      URLClassLoader cl = new URLClassLoader(new URL[] {url}, parent);
+      registeredURLClassLoaders.add(cl);
+      return cl;
+   }
+   
+   private ClassLoader createClassLoader(Result result, TestVFSClassLoaderFactory factory) throws Exception
+   {
+      return createClassLoader(result, factory, null);
+   }
+   
+   private ClassLoader createClassLoader(Result result, TestVFSClassLoaderFactory factory, ClassLoader parent) throws Exception
+   {
+      if (parent != null)
+      {
+         factory.setParent(parent);
+      }
+      
+      KernelDeployment deployment = install(factory);
+      loaderNameDeploymentRegistry.registerDeployment(factory.getName(), deployment);
+      if (result != null)
+      {
+         result.setFactory(factory);
+      }
+      ClassLoader loader = assertClassLoader(factory, parent);
+
+      return loader;
+   }
+
+   /**
+    * Here since we cannot access this via the classloading api
+    */
+   protected ClassLoaderDomain getChildDomainForLoader(ClassLoader loader)
+   {
+      return scopedChildDomainsByLoader.get(loader);
+   }
+   
+   protected ClassLoaderDomain getChildDomainForPool(ClassPool pool)
+   {
+      return getChildDomainForLoader(pool.getClassLoader());
+   }
+   
+   protected void unregisterDomain(ClassLoaderDomain domain)
+   {
+      if (domain != null)
+      {
+         ClassLoaderDomain registeredDomain = getSystem().getDomain(domain.getName());
+         if (registeredDomain == null)
+            throw new IllegalStateException("Domain is not registered: " + domain.getName());
+         if (registeredDomain != domain)
+            throw new IllegalStateException(domain + " is not the same as " + registeredDomain);
+         getSystem().unregisterDomain(domain);
+      }
+   }
+   
+   protected void unregisterDomain(ClassLoader loader)
+   {
+      if (loader != null)
+      {
+         ClassLoaderDomain domain = getChildDomainForLoader(loader);
+         unregisterDomain(domain);
+      }
+   }
+
+   protected void unregisterDomain(ClassPool pool)
+   {
+      if (pool != null)
+      {
+         ClassLoaderDomain domain = getChildDomainForPool(pool);
+         unregisterDomain(domain);
+      }
+   }
+
+   protected void assertCannotLoadClass(ClassLoader cl, String className)
+   {
+      try
+      {
+         cl.loadClass(className);
+         fail("Should not have been able to load " + className);
+      }
+      catch(Exception expected)
+      {
+      }
+   }
+   
+   protected void assertCannotLoadClass(String className, ClassLoader cl)
+   {
+      assertCannotLoadClass(cl, className);
+   }
+   
+   protected void assertCannotLoadCtClass(ClassPool pool, String className)
+   {
+      try
+      {
+         pool.get(className);
+      }
+      catch(Exception e)
+      {
+      }
+   }
+
+   protected void assertCannotLoadCtClass(String className, ClassPool pool)
+   {
+      assertCannotLoadCtClass(pool, className);
+   }
+
+   protected void assertCannotLoadClass(ClassLoaderDomain domain, String className)
+   {
+      try
+      {
+         Class<?> clazz = domain.loadClass(className);
+         if (clazz == null)
+         {
+            return;
+         }
+         fail("Should not have been able to load " + className);
+      }
+      catch(Exception expected)
+      {
+      }
+   }
+
+   protected ClassPool createClassPool(String name, boolean importAll, URL... urls) throws Exception
+   {
+      return createClassPool(null, name, importAll, urls);
+   }
+   
+   protected ClassPool createClassPool(Result result, String name, boolean importAll, URL... urls) throws Exception
+   {
+      ClassLoader loader = createClassLoader(result, name, importAll, urls);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+   
+   protected ClassPool createClassPool(String name, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createClassPool(null, name, builder, urls);
+   }
+   
+   protected ClassPool createClassPool(Result result, String name, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createClassPool(result, name, false, builder, urls);
+   }
+   
+   protected ClassPool createClassPool(String name, boolean importAll, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createClassPool(null, name, importAll, builder, urls);
+   }
+
+   protected ClassPool createClassPool(Result result, String name, boolean importAll, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      TestVFSClassLoaderFactory factory = TestVFSClassLoaderFactoryFactory.createClassLoaderFactory(name, importAll, builder, urls);
+      ClassLoader loader = createClassLoader(result, factory);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+
+   protected ClassPool createChildDomainParentFirstClassPool(String name, String domainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassPool((Result)null, name, domainName, importAll, urls);
+   }
+   
+   protected ClassPool createChildDomainParentFirstClassPool(Result result, String name, String domainName, boolean importAll, URL... urls) throws Exception
+   {
+      ClassLoader loader = createChildDomainParentFirstClassLoader(result, name, domainName, importAll, urls);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+   
+   protected ClassPool createChildDomainParentFirstClassPool(String name, String domainName, boolean importAll, ClassPool parent, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassPool(null, name, domainName, importAll, parent, urls);
+   }
+
+   protected ClassPool createChildDomainParentFirstClassPool(Result result, String name, String domainName, boolean importAll, ClassPool parent, URL... urls) throws Exception
+   {
+      ClassLoader loader = createChildDomainParentFirstClassLoader(result, name, domainName, importAll, parent.getClassLoader(), urls);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+   
+   protected ClassPool createChildDomainParentFirstClassPool(String name, String domainName, String parentDomainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassPool(null, name, domainName, parentDomainName, importAll, urls);
+   }
+   
+   protected ClassPool createChildDomainParentFirstClassPool(Result result, String name, String domainName, String parentDomainName, boolean importAll, URL... urls) throws Exception
+   {
+      ClassLoader loader = createChildDomainParentFirstClassLoader(result, name, domainName, parentDomainName, importAll, urls);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+
+   protected ClassPool createChildDomainParentLastClassPool(String name, String domainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassPool((Result)null, name, domainName, importAll, urls);
+   }
+   
+   protected ClassPool createChildDomainParentLastClassPool(Result result, String name, String domainName, boolean importAll, URL... urls) throws Exception
+   {
+      ClassLoader loader = createChildDomainParentLastClassLoader(result, name, domainName, importAll, urls);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+
+   protected ClassPool createChildDomainParentLastClassPool(String name, String domainName, boolean importAll, ClassPool parent, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassPool(null, name, domainName, importAll, parent, urls);
+   }
+
+   protected ClassPool createChildDomainParentLastClassPool(Result result, String name, String domainName, boolean importAll, ClassPool parent, URL... urls) throws Exception
+   {
+      ClassLoader loader = createChildDomainParentLastClassLoader(result, name, domainName, importAll, parent.getClassLoader(), urls);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+   
+   protected ClassPool createChildDomainParentLastClassPool(String name, String domainName, String parentDomainName, boolean importAll, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassPool(null, name, domainName, parentDomainName, importAll, urls);
+   }
+   
+   protected ClassPool createChildDomainParentLastClassPool(Result result, String name, String domainName, String parentDomainName, boolean importAll, URL... urls) throws Exception
+   {
+      ClassLoader loader = createChildDomainParentLastClassLoader(result, name, domainName, parentDomainName, importAll, urls);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+   
+   protected ClassPool createChildDomainParentFirstClassPool(String name, String domainName, String parentDomainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassPool(null, name, domainName, parentDomainName, builder, urls);
+   }
+   
+   protected ClassPool createChildDomainParentFirstClassPool(Result result, String name, String domainName, String parentDomainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      ClassLoader loader = createChildDomainParentFirstClassLoader(result, name, domainName, parentDomainName, builder, urls);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+
+   protected ClassPool createChildDomainParentFirstClassPool(String name, String domainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainParentFirstClassPool((Result)null, name, domainName, builder, urls);
+   }
+   
+   protected ClassPool createChildDomainParentFirstClassPool(Result result, String name, String domainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      ClassLoader loader = createChildDomainParentFirstClassLoader(result, name, domainName, builder, urls);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+
+   protected ClassPool createChildDomainParentLastClassPool(String name, String domainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createChildDomainParentLastClassPool(null, name, domainName, builder, urls);
+   }
+
+   protected ClassPool createChildDomainParentLastClassPool(Result result, String name, String domainName, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      ClassLoader loader = createChildDomainParentLastClassLoader(result, name, domainName, builder, urls);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+
+   protected ClassPool createChildURLClassPool(ClassPool parent, URL url)
+   {
+      ClassLoader parentLoader = null;
+      if (parent != null)
+      {
+         parentLoader = parent.getClassLoader();
+      }
+      ClassLoader loader = createChildURLClassLoader(parentLoader, url);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+   
+   protected void registerModule(ClassLoader loader, Module module)
+   {
+      registerModule(loader, module, null);
+   }
+   
+   protected void registerModule(ClassLoader loader, Module module, ClassLoader parent)
+   {
+      if (getSystem() != domainRegistry.getSystem())
+      {
+         domainRegistry.setSystem(getSystem());
+      }
+      
+      //TODO I have just hacked the domain here so this might cause problems
+      //with the tests if we try to do weaving. However, it should be fine while just testing pools
+      //and loaders
+      ScopedVFSClassLoaderDomainSetup setup = peekClassLoaderDomainSetup();
+      ScopedVFSClassLoaderDomain domain = null;
+      if (setup != null)
+      {
+         ClassLoaderDomain clDomain = getSystem().getDomain(module.getDomainName());
+         setup.setClassLoaderAndDomain(loader, clDomain);
+         domain = setup.getDomain();
+      }
+      domainRegistry.initMapsForLoader(loader, module, domain, parent);
+   }
+   
+   protected void unregisterModule(ClassLoader loader)
+   {
+      domainRegistry.cleanupLoader(loader);
+   }
+   
+   protected void assertModule(ClassLoader loader)
+   {
+      ClassLoaderDomain domainForLoader = scopedChildDomainsByLoader.get(loader);
+      if (domainForLoader == null)
+      {
+         //domainForLoader = helper.getDomain();
+         domainForLoader = getSystem().getDefaultDomain();
+      }
+      assertNotNull(domainForLoader);
+      
+      ClassLoaderDomain domainForModule = domainRegistry.getClassLoaderDomainForLoader(loader);
+      assertNotNull(domainForModule);
+      assertSame(domainForLoader, domainForModule);
+      
+      Module module = domainRegistry.getModule(loader);
+      assertNotNull(module);
+      assertEquals(domainForModule.getName(), module.getDomainName());
+      assertEquals(domainForModule.getParentDomainName(), module.getParentDomainName());
+   }
+  
+   
+   protected void assertNoClassLoader(Result result) throws Exception
+   {
+      if (result == null)
+      {
+         throw new IllegalStateException("Null result");
+      }
+      assertNoClassLoader(getContextName(result.getFactory()));
+   }
+  
+   protected void assertNoClassPool(Result result) throws Exception
+   {
+      if (result == null)
+      {
+         throw new IllegalStateException("Null result");
+      }
+      assertNoClassLoader(getContextName(result.getFactory()));
+   }
+   
+   protected void assertNoClassLoader(String name) throws Exception
+   {
+      try
+      {
+         Object bean = getBean(name, null);
+         if (bean != null)
+            fail("Should not be here: " + bean);
+      }
+      catch (Throwable t)
+      {
+         checkThrowable(IllegalStateException.class, t);
+      }
+   }
+
+   protected void unregisterClassPool(ClassPool pool) throws Exception
+   {
+      if (pool != null)
+      {
+         ClassLoader loader = pool.getClassLoader();
+         ClassPoolRepository.getInstance().unregisterClassLoader(loader);
+         if (loader != null)
+         {
+            unregisterClassLoader(loader);
+         }
+      }
+   }
+
+   protected void unregisterClassLoader(ClassLoader classLoader) throws Exception
+   {
+      if (classLoader != null)
+      {
+         if (registeredURLClassLoaders.remove(classLoader) == false)
+         {
+            domainRegistry.cleanupLoader(classLoader);
+            KernelDeployment deployment = loaderNameDeploymentRegistry.unregisterDeployment(classLoader);
+            unregisterDeployment(deployment);
+         }
+      }
+   }
+   
+   protected void unregisterClassLoader(String name) throws Exception
+   {
+      KernelDeployment deployment = loaderNameDeploymentRegistry.unregisterDeployment(name);
+      unregisterDeployment(deployment);
+   }
+   
+   private void unregisterDeployment(KernelDeployment deployment)
+   {
+      if (deployment != null)
+      {
+         undeploy(deployment);
+      }
+   }
+
+   /**
+    * Unregister a domain
+    * 
+    * @param name the domain name
+    */
+   protected void unregisterDomain(String name)
+   {
+      if (name != null)
+      {
+         ClassLoaderDomain registeredDomain = getSystem().getDomain(name);
+         unregisterDomain(registeredDomain);
+      }
+   }
+   
+   protected KernelDeployment install(TestVFSClassLoaderFactory metaData) throws Exception
+   {
+      AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+      deployment.setName(metaData.getName() + ":" + metaData.getVersion());
+      deployment.setBeanFactories(Collections.singletonList((BeanMetaDataFactory) metaData));
+      deploy(deployment);
+      return deployment;
+   }
+
+   protected String getContextName(TestVFSClassLoaderFactory factory)
+   {
+      String contextName = factory.getContextName();
+      if (contextName == null)
+         contextName = factory.getName() + ":" + factory.getVersion();
+      return contextName;
+   }
+
+   protected ClassLoader assertClassLoader(TestVFSClassLoaderFactory factory) throws Exception
+   {
+      return assertClassLoader(factory, null);
+   }
+   
+   protected ClassLoader assertClassLoader(TestVFSClassLoaderFactory factory, ClassLoader parent) throws Exception
+   {
+      try
+      {
+         Object obj = getBean(getContextName(factory));
+         ClassLoader loader = assertInstanceOf(obj, ClassLoader.class);
+         
+         Module module = assertModule(getContextName(factory));
+         registerModule(loader, module, parent);
+         loaderNameDeploymentRegistry.registerLoaderName(factory.getName(), loader);
+         
+         return loader;
+      }
+      catch (IllegalStateException e)
+      {
+         throw new NoSuchClassLoaderException(e);
+      }
+   }
+   
+   protected ClassPool assertClassPool(TestVFSClassLoaderFactory factory) throws Exception
+   {
+      ClassLoader loader = assertClassLoader(factory);
+      return ClassPoolRepository.getInstance().registerClassLoader(loader);
+   }
+   
+   protected Class<?> assertLoadClass(String name, ClassLoader initiating) throws Exception
+   {
+      return assertLoadClass(name, initiating, initiating);
+   }
+   
+   protected Class<?> assertLoadClass(String name, ClassLoader initiating, ClassLoader expected) throws Exception
+   {
+      Class<?> clazz = initiating.loadClass(name);
+      if (expected != null)
+      {
+         assertSame(expected, clazz.getClassLoader());
+      }
+      return clazz;
+   }
+
+   protected CtClass assertLoadCtClass(String name, ClassPool initiating) throws Exception
+   {
+      return assertLoadCtClass(name, initiating, initiating);
+   }
+   
+   protected CtClass assertLoadCtClass(String name, ClassPool initiating, ClassPool expected) throws Exception
+   {
+      CtClass clazz = initiating.get(name);
+      if (expected != null)
+      {
+         assertSame(expected, clazz.getClassPool());
+      }
+      
+      //Load twice to test both create and cache
+      clazz = initiating.get(name);
+      if (expected != null)
+      {
+         assertSame(expected, clazz.getClassPool());
+      }
+      
+      assertLoadCtClassArray(name, clazz, initiating, expected);
+      
+      return clazz;
+   }
+   
+   private void assertLoadCtClassArray(String name, CtClass clazz, ClassPool initiating, ClassPool expected) throws Exception
+   {
+      assertLoadCtClassArray(name, clazz, 1, initiating, expected);
+      assertLoadCtClassArray(name, clazz, 2, initiating, expected);
+   }
+   
+   private void assertLoadCtClassArray(String name, CtClass clazz, int dimensions, ClassPool initiating, ClassPool expected) throws Exception
+   {
+      String arrayName = name;
+      for (int i = 0 ; i < dimensions ; i++)
+      {
+         arrayName = array(arrayName);
+      }
+      CtClass array = initiating.get(arrayName);
+      
+      if (expected != null)
+      {
+         assertSame(expected, array.getClassPool());
+      }
+      
+      assertSame(clazz.getClassPool(), array.getClassPool());
+      
+      CtClass type = array;
+      for (int i = 0 ; i < dimensions ; i++)
+      {
+         type = type.getComponentType();
+      }
+      assertSame(type, clazz);
+   }
+
+   protected Module assertModule(String contextName)
+   {
+      return assertBean(contextName + "$MODULE", Module.class);
+   }
+
+   /**
+    * The test classes should not be on the launcher classpath
+    */
+   public void testClassesNotOnClasspath()
+   {
+      assertCannotLoadClass(this.getClass().getClassLoader(), SupportClasses.CLASS_A);
+      assertCannotLoadClass(this.getClass().getClassLoader(), SupportClasses.CLASS_B);
+      assertCannotLoadClass(this.getClass().getClassLoader(), SupportClasses.CLASS_C);
+   }
+   
+   static class NoSuchClassLoaderException extends Exception
+   {
+      private static final long serialVersionUID = 1L;
+
+      public NoSuchClassLoaderException(Exception e)
+      {
+         super(e);
+      }
+   }
+   
+   private static class LoaderNameDeploymentRegistry
+   {
+      private Map<String, KernelDeployment> deploymentsByName = new HashMap<String, KernelDeployment>();
+      
+      private Map<ClassLoader, String> namesByLoader = new HashMap<ClassLoader, String>();
+
+      private void registerDeployment(String name, KernelDeployment deployment)
+      {
+         if (!deploymentsByName.containsKey(name))
+         {
+            deploymentsByName.put(name, deployment);
+         }
+      }
+      
+      private void registerLoaderName(String name, ClassLoader loader)
+      {
+         if (loader != null)
+         {
+            namesByLoader.put(loader, name);
+         }
+      }
+      
+      private KernelDeployment unregisterDeployment(String name)
+      {
+         return deploymentsByName.remove(name);
+      }
+      
+      private KernelDeployment unregisterDeployment(ClassLoader loader)
+      {
+         String name = namesByLoader.remove(loader);
+         return unregisterDeployment(name);
+      }
+   }
+
+   private static ScopedVFSClassLoaderDomainSetup classLoaderDomainSetup;
+   
+   protected static void pushClassLoaderDomainSetup(ScopedVFSClassLoaderDomainSetup setup)
+   {
+      classLoaderDomainSetup = setup;
+   }
+   
+   protected static ScopedVFSClassLoaderDomainSetup popClassLoaderDomainSetup()
+   {
+      ScopedVFSClassLoaderDomainSetup setup = classLoaderDomainSetup;
+      classLoaderDomainSetup = null;
+      return setup;
+   }
+   
+   protected static ScopedVFSClassLoaderDomainSetup peekClassLoaderDomainSetup()
+   {
+      return classLoaderDomainSetup;
+   }
+   
+   /*public class ScopedVFSClassLoaderDomainSetup
+   {
+      ScopedVFSClassLoaderDomain domain;
+      
+      String name;
+      boolean parentDelegation;
+      boolean parentFirst; 
+      DomainRegistry registry;
+      
+      public ScopedVFSClassLoaderDomainSetup(String name, boolean parentDelegation, boolean parentFirst, DomainRegistry registry)
+      {
+         this.name = name;
+         this.parentDelegation = parentDelegation;
+         this.parentFirst = parentFirst;
+         this.registry = registry;
+      }
+      
+      public ScopedVFSClassLoaderDomain getDomain()
+      {
+         return domain;
+      }
+
+      public void setClassLoaderAndDomain(ClassLoader loader, ClassLoaderDomain clDomain)
+      {
+         if (domain == null)
+         {
+            domain = new ScopedVFSClassLoaderDomain(loader, name, parentDelegation, parentFirst, clDomain, registry);
+         }
+      }
+   }*/
+}

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,41 @@
+/*
+* 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.test.classpool.jbosscl.test;
+
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossClClassPoolTestDelegate extends MicrocontainerTestDelegate
+{
+
+   public JBossClClassPoolTestDelegate(Class<?> clazz) throws Exception
+   {
+      super(clazz);
+//      String property = System.getProperty("jboss.aop.secure", "true");
+//      boolean enableSecurity = Boolean.valueOf(property).booleanValue();
+//      this.enableSecurity = enableSecurity;
+   }
+}

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/BundleInfoBuilder.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/BundleInfoBuilder.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/BundleInfoBuilder.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,179 @@
+/*
+* 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.test.classpool.support;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.classloading.spi.metadata.Capability;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaDataFactory;
+import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.classloading.spi.version.VersionRange;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BundleInfoBuilder
+{
+   static ClassLoadingMetaDataFactory clmdf = ClassLoadingMetaDataFactory.getInstance();
+   
+   List<Capability> capabilities = new ArrayList<Capability>();
+   List<Requirement> requirements = new ArrayList<Requirement>();
+   
+   private BundleInfoBuilder()
+   {
+      
+   }
+   
+   public static BundleInfoBuilder getBuilder()
+   {
+      return new BundleInfoBuilder();
+   }
+   
+   public BundleInfoBuilder createModule(String name)
+   {
+      capabilities.add(clmdf.createModule(name));
+      return this;
+   }
+   
+   public BundleInfoBuilder createModule(String name, Object version)
+   {
+      capabilities.add(clmdf.createModule(name, version));
+      return this;
+   }
+   
+   public BundleInfoBuilder createRequireModule(String name)
+   {
+      requirements.add(clmdf.createRequireModule(name, null));
+      return this;
+   }
+
+   public BundleInfoBuilder createRequireModule(String name, VersionRange versionRange)
+   {
+      requirements.add(clmdf.createRequireModule(name, versionRange));
+      return this;
+   }
+
+   public BundleInfoBuilder createRequireModule(String name, VersionRange versionRange, boolean optional, boolean reExport, boolean dynamic)
+   {
+      requirements.add(clmdf.createRequireModule(name, versionRange, optional, reExport, dynamic));
+      return this;
+   }
+
+   public BundleInfoBuilder createPackage(String name)
+   {
+      capabilities.add(clmdf.createPackage(name));
+      return this;
+   }
+
+   public BundleInfoBuilder createPackage(String name, Object version)
+   {
+      capabilities.add(clmdf.createPackage(name, version));
+      return this;
+   }
+
+   public BundleInfoBuilder createRequirePackage(String name)
+   {
+      requirements.add(clmdf.createRequirePackage(name));
+      return this;
+   }
+
+   public BundleInfoBuilder createRequirePackage(String name, VersionRange versionRange)
+   {
+      requirements.add(clmdf.createRequirePackage(name, versionRange));
+      return this;
+   }
+
+   public BundleInfoBuilder createRequirePackage(String name, VersionRange versionRange, boolean optional, boolean reExport, boolean dynamic)
+   {
+      requirements.add(clmdf.createRequirePackage(name, versionRange, optional, reExport, dynamic));
+      return this;
+   }
+
+   public BundleInfoBuilder createReExportModule(String name)
+   {
+      requirements.add(clmdf.createReExportModule(name));
+      return this;
+   }
+
+   public BundleInfoBuilder createReExportModule(String name, VersionRange versionRange)
+   {
+      requirements.add(clmdf.createReExportModule(name, versionRange));
+      return this;
+   }
+
+   public BundleInfoBuilder createReExportModule(String name, VersionRange versionRange, boolean optional)
+   {
+      requirements.add(clmdf.createReExportModule(name, versionRange, optional));
+      return this;
+   }
+
+   public BundleInfoBuilder createReExportPackage(String name)
+   {
+      requirements.add(clmdf.createReExportPackage(name));
+      return this;
+   }
+
+   public BundleInfoBuilder createReExportPackage(String name, VersionRange versionRange)
+   {
+      requirements.add(clmdf.createReExportPackage(name, versionRange));
+      return this;
+   }
+
+   public BundleInfoBuilder createReExportPackage(String name, VersionRange versionRange, boolean optional)
+   {
+      requirements.add(clmdf.createReExportPackage(name, versionRange, optional));
+      return this;
+   }
+   
+   public BundleInfoBuilder createUsesPackage(String name)
+   {
+      requirements.add(clmdf.createUsesPackage(name));
+      return this;
+   }
+
+   public BundleInfoBuilder createUsesPackage(String name, VersionRange versionRange)
+   {
+      requirements.add(clmdf.createUsesPackage(name, versionRange));
+      return this;
+   }
+
+   public BundleInfoBuilder createUsesPackage(String name, VersionRange versionRange, boolean reExport)
+   {
+      requirements.add(clmdf.createUsesPackage(name, versionRange, reExport));
+      return this;
+   }
+
+   
+   
+   public List<Capability> getCapabilities()
+   {
+      return capabilities;
+   }
+   
+   public List<Requirement> getRequirements()
+   {
+      return requirements;
+   }
+}

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/Result.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/Result.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/Result.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,42 @@
+/*
+* 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.test.classpool.support;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Result
+{
+   private TestVFSClassLoaderFactory factory;
+
+   public TestVFSClassLoaderFactory getFactory()
+   {
+      return factory;
+   }
+
+   public void setFactory(TestVFSClassLoaderFactory factory)
+   {
+      this.factory = factory;
+   }
+}

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/SupportClasses.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/SupportClasses.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/SupportClasses.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.classpool.support;
+
+import java.net.URL;
+
+/**
+ * 
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision: 1.1 $
+ */
+public class SupportClasses
+{
+   public final static String JAR_A_1 = "a1.jar";
+   public final static String JAR_A_2 = "a2.jar";
+   public final static String JAR_B_1 = "b1.jar";
+   public final static String JAR_B_2 = "b2.jar";
+   public final static String JAR_C_1 = "c1.jar";
+   public final static String JAR_C_2 = "c2.jar";
+   
+   public static final String PACKAGE_ROOT = SupportClasses.class.getPackage().getName() + ".excluded";
+   public final static String PACKAGE_A = PACKAGE_ROOT + ".a";
+   public final static String PACKAGE_B = PACKAGE_ROOT + ".b";
+   public final static String PACKAGE_C = PACKAGE_ROOT + ".c";
+   
+   public final static String CLASS_A = PACKAGE_A + ".A";
+   public final static String CLASS_B = PACKAGE_B + ".B";
+   public final static String CLASS_C = PACKAGE_C + ".C";
+}
\ No newline at end of file

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderFactory.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderFactory.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderFactory.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,104 @@
+/*
+* 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.test.classpool.support;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestVFSClassLoaderFactory extends VFSClassLoaderFactory
+{
+   private static final long serialVersionUID = 1L;
+   
+   private ClassLoader parent;
+
+   @Override
+   protected Class<? extends VFSClassLoaderPolicyModule> getModuleClass()
+   {
+      return TestVFSClassLoaderPolicyModule.class;
+   }
+   
+   public void setParent(ClassLoader parent)
+   {
+      this.parent = parent;
+   }
+   
+   @Override
+   public List<BeanMetaData> getBeans()
+   {
+
+       List<BeanMetaData> result = super.getBeans();
+      if (parent != null)
+      {
+         //We need to modify the Module factory method used to create the classloader to pass in the parent
+         if (result.size() != 2)
+         {
+            throw new IllegalStateException("Expected size=2, was " + result.size());
+         }
+      
+         BeanMetaData classLoader = null;
+         BeanMetaData module = null;
+         for (BeanMetaData bean : result)
+         {
+            if (bean.getBean().equals(ClassLoader.class.getName()))
+            {
+               classLoader = bean;
+            }
+            else
+            {
+               module = bean;
+            }
+         }
+         
+         if (module == null)
+         {
+            throw new IllegalStateException("Could not find module");
+         }
+         if (classLoader == null)
+         {
+            throw new IllegalStateException("Could not find module");
+         }
+         
+         BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(classLoader.getName(), ClassLoader.class.getName());
+         builder.setNoClassLoader();
+         builder.setFactory(module.getName());
+         builder.setFactoryMethod("registerClassLoaderPolicy");
+         builder.addConstructorParameter(ClassLoaderSystem.class.getName(), builder.createInject(getClassLoaderSystemName()));
+         builder.addConstructorParameter(ClassLoader.class.getName(), parent);
+         classLoader = builder.getBeanMetaData();
+
+         result = Arrays.asList(classLoader, module);
+      }
+      
+      return result;
+   }
+}

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderFactoryFactory.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderFactoryFactory.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderFactoryFactory.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,135 @@
+/*
+* 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.test.classpool.support;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.ExportAll;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestVFSClassLoaderFactoryFactory
+{
+   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, URL... urls) throws Exception
+   {
+      return createClassLoaderFactory(name, importAll, null, false, urls);
+   }
+   
+   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, BundleInfoBuilder builder, URL... urls) throws Exception
+   {
+      return createClassLoaderFactory(name, importAll, null, null, builder, false, urls);
+   }
+   
+   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, String domainName, BundleInfoBuilder builder, boolean parentFirst, URL... urls) throws Exception
+   {
+      return createClassLoaderFactory(name, domainName, null, builder, parentFirst, urls);
+   }
+   
+   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, String domainName, String parentDomainName, BundleInfoBuilder builder, boolean parentFirst, URL... urls) throws Exception
+   {
+      return createClassLoaderFactory(name, false, domainName, parentDomainName, builder, false, urls);
+   }
+
+   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, String moduleName, URL... urls) throws Exception
+   {
+      return createClassLoaderFactory(name, importAll, null, false, urls);
+   }
+   
+   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, String domainName, boolean parentFirst, URL... urls) throws Exception
+   {
+      return createClassLoaderFactory(name, importAll, domainName, null, parentFirst, urls);
+   }
+
+   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, String domainName, String parentDomainName, boolean parentFirst, URL... urls) throws Exception
+   {
+      return createClassLoaderFactory(name, importAll, domainName, parentDomainName, null, parentFirst, urls);
+   }
+   
+   public static TestVFSClassLoaderFactory createClassLoaderFactory(String name, boolean importAll, String domainName, String parentDomainName, BundleInfoBuilder builder, boolean parentFirst, URL... urls) throws Exception
+   {
+      TestVFSClassLoaderFactory factory = new TestVFSClassLoaderFactory();
+      factory.setName(name);
+      factory.setImportAll(importAll);
+      if (importAll)
+      {
+         factory.setExportAll(ExportAll.NON_EMPTY);
+      }
+      factory.setRoots(urlsToStringList(urls));
+      addCapabilitiesAndRequirements(factory, builder);
+      setupDomain(factory, domainName, parentDomainName, parentFirst);
+      return factory;
+   }
+
+   private static void addCapabilitiesAndRequirements(ClassLoadingMetaData md, BundleInfoBuilder builder)
+   {
+      if (builder != null)
+      {
+         md.getCapabilities().setCapabilities(builder.getCapabilities());
+         md.getRequirements().setRequirements(builder.getRequirements());
+      }
+   }
+
+   private static void setupDomain(ClassLoadingMetaData md, String domainName, String parentDomainName, boolean parentFirst)
+   {
+      if (domainName != null)
+      {
+         md.setDomain(domainName);
+         md.setJ2seClassLoadingCompliance(parentFirst);
+         if (parentDomainName != null)
+         {
+            md.setParentDomain(parentDomainName);
+         }
+         else
+         {
+            md.setParentDomain(ClassLoaderSystem.DEFAULT_DOMAIN_NAME);
+         }
+      }
+      else
+      {
+         md.setDomain(ClassLoaderSystem.DEFAULT_DOMAIN_NAME);
+      }
+   }
+   
+   private static List<String> urlsToStringList(URL... urls)
+   {
+      List<String> urlList = new ArrayList<String>(urls.length);
+      if (urls.length > 0)
+      {
+         for (URL url : urls)
+         {
+            if (url != null)
+            {
+               urlList.add(url.toString());
+            }
+         }
+      }
+      return urlList;
+   }
+
+}

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderPolicyModule.java
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderPolicyModule.java	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/java/org/jboss/test/classpool/support/TestVFSClassLoaderPolicyModule.java	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,92 @@
+/*
+* 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.test.classpool.support;
+
+import java.net.URL;
+
+import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.util.id.GUID;
+import org.jboss.virtual.MemoryFileFactory;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestVFSClassLoaderPolicyModule extends VFSClassLoaderPolicyModule
+{
+   private static final long serialVersionUID = 1;
+   
+   /** In AS we need a URL to create the temporary files */
+   URL dynamicClassRoot;
+   VirtualFile classes;
+
+   public TestVFSClassLoaderPolicyModule(VFSClassLoaderFactory classLoadingMetaData, String contextName)
+   {
+      // FIXME TesetMockClassLoaderPolicyModule constructor
+      super(classLoadingMetaData, contextName);
+   }
+
+   /**
+    * Get/Create the vfs memory file where we will create dynamic classes
+    */
+   @Override
+   public URL getDynamicClassRoot()
+   {
+      initDynamicClassRoot();
+      return dynamicClassRoot;
+   }
+   
+   /**
+    * Prepend the dynamic URL location to the classpath
+    */
+   @Override
+   protected VirtualFile[] determineVFSRoots()
+   {
+      initDynamicClassRoot();
+      VirtualFile[] roots = super.determineVFSRoots();
+      VirtualFile[] newRoots = new VirtualFile[roots.length + 1];
+      newRoots[0] = classes;
+      System.arraycopy(roots, 0, newRoots, 1, roots.length);
+      
+      return newRoots;
+   }
+   
+   private synchronized void initDynamicClassRoot()
+   {
+      if (dynamicClassRoot == null)
+      {
+         try
+         {
+            dynamicClassRoot = new URL("vfsmemory", GUID.asString(), "");
+            classes = MemoryFileFactory.createRoot(dynamicClassRoot).getRoot();
+         }
+         catch (Exception e)
+         {
+            // AutoGenerated
+            throw new RuntimeException(e);
+         }
+      }
+   }
+}

Added: projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/resources/org/jboss/test/classpool/jbosscl/Common.xml
===================================================================
--- projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/resources/org/jboss/test/classpool/jbosscl/Common.xml	                        (rev 0)
+++ projects/aop/branches/classpool_JBAOP-742/asintegration-mc/src/test/resources/org/jboss/test/classpool/jbosscl/Common.xml	2009-08-14 12:12:49 UTC (rev 92354)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="ClassLoaderSystem" class="org.jboss.classloader.spi.ClassLoaderSystem">
+      <constructor factoryClass="org.jboss.test.classpool.jbosscl.test.JBossClClassPoolTest" factoryMethod="getSystem"/>
+   </bean>
+
+   <bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
+      <incallback method="addModule" state="Configured"/>
+      <uncallback method="removeModule" state="Configured"/>
+   </bean>
+
+</deployment>




More information about the jboss-cvs-commits mailing list