[jboss-cvs] JBossAS SVN: r82712 - in projects/aop/trunk: asintegration-core/src/tests/org/jboss/test/aop/classpool/test and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 8 17:17:38 EST 2009


Author: kabir.khan at jboss.com
Date: 2009-01-08 17:17:38 -0500 (Thu, 08 Jan 2009)
New Revision: 82712

Added:
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/AbstractParentDelegationStrategy.java
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BaseClassPoolDomain.java
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ClassPoolToClassPoolDomainAdaptorFactory.java
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/DefaultClassPoolToClassPoolDomainAdaptorFactory.java
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/DefaultParentDelegationStrategy.java
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ParentDelegationStrategy.java
   projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolToClassPoolDomainAdaptorFactory.java
   projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClParentDelegationStrategy.java
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/NoMatchClassFilter.java
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithHierarchicalDomainSanityTestCase.java
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithHierarchicalParentLoaderSanityTestCase.java
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithHierarchicalDomainTestCase.java
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithHierarchicalParentLoaderTestCase.java
Removed:
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BasicClassPoolDomain.java
Modified:
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ClassPoolDomain.java
   projects/aop/trunk/asintegration-core/src/tests/org/jboss/test/aop/classpool/test/ClassPoolTest.java
   projects/aop/trunk/asintegration-core/src/tests/org/jboss/test/aop/classpool/test/IsLocalResourcePluginFactoryTestCase.java
   projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/classpool/ucl/JBossUclClassPoolFactory.java
   projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolDomain.java
   projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolFactory.java
   projects/aop/trunk/asintegration-mc/src/resources/tests/org/jboss/test/aop/classpool/jbosscl/Common.xml
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactoryFactory.java
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithModuleDependencyTestCase.java
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolDelegatingTestSuite.java
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolSanityTestSuite.java
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTest.java
   projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java
Log:
[JBAOP-666] Refactor to enable ParentPolicy in JBossClClassPoolDomain, rather than the simple parentFirst flag
Fresh ClassLoading bean for every test run in asintegration-mc so that we don't get old domains hanging around (this is what is done in jboss-cl)


Added: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/AbstractParentDelegationStrategy.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/AbstractParentDelegationStrategy.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/AbstractParentDelegationStrategy.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,67 @@
+/*
+* 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.classpool;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractParentDelegationStrategy implements ParentDelegationStrategy
+{
+   private ClassPoolDomainInternal parent;
+   
+   protected AbstractParentDelegationStrategy(ClassPoolDomain parent, ClassPoolToClassPoolDomainAdaptorFactory adaptorFactory)
+   {
+      if (parent == null)
+      {
+         if (adaptorFactory == null)
+         {
+            throw new IllegalStateException("Null parent and null adaptorFactory");
+         }
+         this.parent = adaptorFactory.createAdaptor();
+      }
+      else 
+      {
+         if (parent instanceof ClassPoolDomainInternal == false)
+         {
+            throw new IllegalArgumentException("Parent must implement ClassPoolDomainInternal");         
+         }
+         this.parent = (ClassPoolDomainInternal)parent;
+      }
+      
+      if (this.parent == null)
+      {
+         throw new IllegalStateException("Parent was not set");
+      }
+   }
+   
+   protected boolean hasParent()
+   {
+      return parent != null;
+   }
+   
+   public ClassPoolDomainInternal getParent()
+   {
+      return parent;
+   }
+}

Copied: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BaseClassPoolDomain.java (from rev 82658, projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BasicClassPoolDomain.java)
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BaseClassPoolDomain.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BaseClassPoolDomain.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,146 @@
+/*
+* 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.classpool;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javassist.CtClass;
+
+import org.jboss.aop.util.ClassLoaderUtils;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class BaseClassPoolDomain extends AbstractClassPoolDomain implements ClassPoolDomainInternal
+{
+   private String domainName;
+   
+   private List<DelegatingClassPool> delegatingPools = new ArrayList<DelegatingClassPool>();
+   
+   private ParentDelegationStrategy parentDelegationStrategy;
+
+   public BaseClassPoolDomain(String domainName, ClassPoolDomain parent, boolean parentFirst)
+   {
+      this(domainName, 
+            new DefaultParentDelegationStrategy(
+                  parent, 
+                  parentFirst, 
+                  DefaultClassPoolToClassPoolDomainAdaptorFactory.getInstance())
+      );
+   }
+   
+   protected BaseClassPoolDomain(String domainName, ParentDelegationStrategy parentDelegationStrategy)
+   {
+      this.domainName = domainName;
+      this.parentDelegationStrategy = parentDelegationStrategy;
+   }
+   
+   public String getDomainName()
+   {
+      return domainName;
+   }
+ 
+   public synchronized void addClassPool(DelegatingClassPool pool)
+   {
+      if (!delegatingPools.contains(pool))
+      {
+         delegatingPools.add(pool);
+      }
+   }
+   
+   public synchronized void removeClassPool(DelegatingClassPool pool)
+   {
+      delegatingPools.remove(pool);
+   }
+   
+   public synchronized CtClass getCachedOrCreate(DelegatingClassPool initiatingPool, String classname, boolean create)
+   {
+      String resourceName = ClassLoaderUtils.getResourceName(classname);
+      
+      CtClass clazz = getCachedOrCreateInternal(initiatingPool, classname, resourceName, create);
+      
+      if (clazz == null)
+      {
+         clazz = getCachedOrCreateFromPoolParent(initiatingPool, classname, create);
+      }
+      return clazz;
+   }
+   
+   public CtClass getCachedOrCreateInternal(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create)
+   {
+      CtClass clazz = null;
+      if (isParentBefore(classname))
+      {
+         clazz = getCachedOrCreateInternalFromParent(initiatingPool, classname, resourceName, create);
+      }
+      if (clazz == null)
+      {
+         String packageName = ClassLoaderUtils.getPackageName(classname);
+         for (DelegatingClassPool pool : getPoolsForPackage(packageName))
+         {
+            clazz = pool.loadLocally(classname, resourceName, create);
+            if (clazz != null)
+            {
+               break;
+            }
+         }
+      }
+      if (clazz == null && isParentAfter(classname))
+      {
+         clazz = getCachedOrCreateInternalFromParent(initiatingPool, classname, resourceName, create);
+      }
+      return clazz;
+   }
+
+   public CtClass getCachedOrCreateInternalFromParent(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create)
+   {
+      return parentDelegationStrategy.getParent().getCachedOrCreateInternal(initiatingPool, classname, resourceName, create);
+   }
+   
+   public String toString()
+   {
+      return super.toString() + "[" + domainName + "]";
+   }
+
+   public List<DelegatingClassPool> getClassPools()
+   {
+      return delegatingPools; 
+   }
+   
+   protected boolean isParentBefore(String classname)
+   {
+      return parentDelegationStrategy.isParentBefore(classname);
+   }
+   
+   protected boolean isParentAfter(String classname)
+   {
+      return parentDelegationStrategy.isParentAfter(classname);
+   }
+   
+   protected List<DelegatingClassPool> getPoolsForPackage(String packageName)
+   {
+      return delegatingPools;
+   }
+}

Deleted: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BasicClassPoolDomain.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BasicClassPoolDomain.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/BasicClassPoolDomain.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -1,171 +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.classpool;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javassist.CtClass;
-
-import org.jboss.aop.util.ClassLoaderUtils;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class BasicClassPoolDomain extends AbstractClassPoolDomain implements ClassPoolDomainInternal
-{
-   private String domainName;
-   
-   private ClassPoolDomainInternal parent;
-   
-   private List<DelegatingClassPool> delegatingPools = new ArrayList<DelegatingClassPool>();
-   
-   private boolean parentFirst;
-
-   public BasicClassPoolDomain(String domainName, ClassPoolDomain parent)
-   {
-      if (parent != null && parent instanceof ClassPoolDomainInternal == false)
-      {
-         throw new IllegalArgumentException("Parent must implement ClassPoolDomainInternal");
-      }
-      this.parent = (ClassPoolDomainInternal)parent;
-      this.domainName = domainName;
-
-      if (parent == null)
-      {
-         this.parent = createParentClassPoolToClassPoolDomainAdaptor();
-         if (this.parent == null)
-         {
-            throw new IllegalStateException("No ClassPoolToClassPool");
-         }
-      }
-   }
-
-   protected ClassPoolToClassPoolDomainAdapter createParentClassPoolToClassPoolDomainAdaptor()
-   {
-      return new ClassPoolToClassPoolDomainAdapter();
-   }
-   
-   public String getDomainName()
-   {
-      return domainName;
-   }
- 
-   public boolean isParentFirst()
-   {
-      return parentFirst;
-   }
-
-   public void setParentFirst(boolean parentFirst)
-   {
-      this.parentFirst = parentFirst;
-   }
-
-   public synchronized void addClassPool(DelegatingClassPool pool)
-   {
-      if (!delegatingPools.contains(pool))
-      {
-         delegatingPools.add(pool);
-      }
-   }
-   
-   public synchronized void removeClassPool(DelegatingClassPool pool)
-   {
-      delegatingPools.remove(pool);
-   }
-   
-   public synchronized CtClass getCachedOrCreate(DelegatingClassPool initiatingPool, String classname, boolean create)
-   {
-      String resourceName = ClassLoaderUtils.getResourceName(classname);
-      
-      CtClass clazz = getCachedOrCreateInternal(initiatingPool, classname, resourceName, create);
-      
-      if (clazz == null)
-      {
-         clazz = getCachedOrCreateFromPoolParent(initiatingPool, classname, create);
-      }
-      return clazz;
-   }
-   
-   public CtClass getCachedOrCreateInternal(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create)
-   {
-      CtClass clazz = null;
-      if (isParentBefore())
-      {
-         clazz = getCachedOrCreateInternalFromParent(initiatingPool, classname, resourceName, create);
-      }
-      if (clazz == null)
-      {
-         String packageName = ClassLoaderUtils.getPackageName(classname);
-         for (DelegatingClassPool pool : getPoolsForPackage(packageName))
-         {
-            clazz = pool.loadLocally(classname, resourceName, create);
-            if (clazz != null)
-            {
-               break;
-            }
-         }
-      }
-      if (clazz == null && isParentAfter())
-      {
-         clazz = getCachedOrCreateInternalFromParent(initiatingPool, classname, resourceName, create);
-      }
-      return clazz;
-   }
-
-   public CtClass getCachedOrCreateInternalFromParent(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create)
-   {
-      return parent.getCachedOrCreateInternal(initiatingPool, classname, resourceName, create);
-   }
-   
-   public String toString()
-   {
-      return super.toString() + "[" + domainName + "]";
-   }
-
-   public List<DelegatingClassPool> getClassPools()
-   {
-      return delegatingPools; 
-   }
-   
-   protected boolean isParentBefore()
-   {
-      return parentFirst && parent!= null;
-   }
-   
-   protected boolean isParentAfter()
-   {
-      return parent != null && !parentFirst;
-   }
-   
-   protected ClassPoolDomainInternal getParentDomain()
-   {
-      return parent;
-   }
-   
-   protected List<DelegatingClassPool> getPoolsForPackage(String packageName)
-   {
-      return delegatingPools;
-   }
-}

Modified: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ClassPoolDomain.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ClassPoolDomain.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ClassPoolDomain.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -30,10 +30,6 @@
 {
    String getDomainName();
  
-   boolean isParentFirst();
-
-   void setParentFirst(boolean parentFirst);
-
    void addClassPool(DelegatingClassPool pool);
    
    void removeClassPool(DelegatingClassPool pool);

Added: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ClassPoolToClassPoolDomainAdaptorFactory.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ClassPoolToClassPoolDomainAdaptorFactory.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ClassPoolToClassPoolDomainAdaptorFactory.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,32 @@
+/*
+* 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.classpool;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ClassPoolToClassPoolDomainAdaptorFactory
+{
+   ClassPoolToClassPoolDomainAdapter createAdaptor();
+}

Added: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/DefaultClassPoolToClassPoolDomainAdaptorFactory.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/DefaultClassPoolToClassPoolDomainAdaptorFactory.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/DefaultClassPoolToClassPoolDomainAdaptorFactory.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,48 @@
+/*
+* 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.classpool;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultClassPoolToClassPoolDomainAdaptorFactory implements ClassPoolToClassPoolDomainAdaptorFactory
+{
+   private static final DefaultClassPoolToClassPoolDomainAdaptorFactory INSTANCE = new DefaultClassPoolToClassPoolDomainAdaptorFactory();
+   
+   private DefaultClassPoolToClassPoolDomainAdaptorFactory()
+   {
+      
+   }
+   
+   public static ClassPoolToClassPoolDomainAdaptorFactory getInstance()
+   {
+      return INSTANCE;
+   }
+   
+   public ClassPoolToClassPoolDomainAdapter createAdaptor()
+   {
+      return new ClassPoolToClassPoolDomainAdapter();
+   }
+
+}

Added: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/DefaultParentDelegationStrategy.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/DefaultParentDelegationStrategy.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/DefaultParentDelegationStrategy.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -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.classpool;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class DefaultParentDelegationStrategy extends AbstractParentDelegationStrategy
+{
+   boolean parentFirst;
+   DefaultParentDelegationStrategy(ClassPoolDomain parent, boolean parentFirst, ClassPoolToClassPoolDomainAdaptorFactory adaptorFactory)
+   {
+      super(parent, adaptorFactory);
+      this.parentFirst = parentFirst;
+   }
+   
+   public boolean isParentBefore(String classname)
+   {
+      return hasParent() && parentFirst == true;
+   }
+   
+   public boolean isParentAfter(String classname)
+   {
+      return hasParent() && parentFirst == false;
+   }
+}

Added: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ParentDelegationStrategy.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ParentDelegationStrategy.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/classpool/ParentDelegationStrategy.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,36 @@
+/*
+* 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.classpool;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface ParentDelegationStrategy
+{
+   ClassPoolDomainInternal getParent();
+   
+   boolean isParentBefore(String classname);
+
+   boolean isParentAfter(String classname);
+}

Modified: projects/aop/trunk/asintegration-core/src/tests/org/jboss/test/aop/classpool/test/ClassPoolTest.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/tests/org/jboss/test/aop/classpool/test/ClassPoolTest.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-core/src/tests/org/jboss/test/aop/classpool/test/ClassPoolTest.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -30,7 +30,7 @@
 import javassist.ClassPool;
 
 import org.jboss.aop.classpool.AOPClassPoolRepository;
-import org.jboss.aop.classpool.BasicClassPoolDomain;
+import org.jboss.aop.classpool.BaseClassPoolDomain;
 import org.jboss.aop.classpool.ClassPoolDomain;
 import org.jboss.aop.classpool.DelegatingClassPool;
 import org.jboss.test.AbstractTestCaseWithSetup;
@@ -82,8 +82,7 @@
 
    protected static ClassPoolDomain createClassPoolDomain(String name, ClassPoolDomain parent, boolean parentFirst)
    {
-      ClassPoolDomain domain = new BasicClassPoolDomain(name, parent);
-      domain.setParentFirst(parentFirst);
+      ClassPoolDomain domain = new BaseClassPoolDomain(name, parent, parentFirst);
       return domain;
    }
    

Modified: projects/aop/trunk/asintegration-core/src/tests/org/jboss/test/aop/classpool/test/IsLocalResourcePluginFactoryTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-core/src/tests/org/jboss/test/aop/classpool/test/IsLocalResourcePluginFactoryTestCase.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-core/src/tests/org/jboss/test/aop/classpool/test/IsLocalResourcePluginFactoryTestCase.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -31,7 +31,7 @@
 import junit.framework.TestSuite;
 
 import org.jboss.aop.classpool.AOPClassPoolRepository;
-import org.jboss.aop.classpool.BasicClassPoolDomain;
+import org.jboss.aop.classpool.BaseClassPoolDomain;
 import org.jboss.aop.classpool.ClassPoolDomain;
 import org.jboss.aop.classpool.DefaultClassLoaderIsLocalResourcePlugin;
 import org.jboss.aop.classpool.DefaultClassLoaderIsLocalResourcePluginFactory;
@@ -52,7 +52,7 @@
  */
 public class IsLocalResourcePluginFactoryTestCase extends TestCase
 {
-   final static ClassPoolDomain DOMAIN = new BasicClassPoolDomain("Test", null);
+   final static ClassPoolDomain DOMAIN = new BaseClassPoolDomain("Test", null, true);
    final static URL[] URLS;
    static 
    {

Modified: projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/classpool/ucl/JBossUclClassPoolFactory.java
===================================================================
--- projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/classpool/ucl/JBossUclClassPoolFactory.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/classpool/ucl/JBossUclClassPoolFactory.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -31,7 +31,7 @@
 import javassist.scopedpool.ScopedClassPoolRepository;
 
 import org.jboss.aop.classpool.AbstractJBossClassPoolFactory;
-import org.jboss.aop.classpool.BasicClassPoolDomain;
+import org.jboss.aop.classpool.BaseClassPoolDomain;
 import org.jboss.aop.classpool.ClassPoolDomain;
 import org.jboss.aop.classpool.ClassPoolDomainRegistry;
 import org.jboss.aop.classpool.NonDelegatingClassPool;
@@ -82,15 +82,14 @@
          if (loaderRepository instanceof HeirarchicalLoaderRepository3)
          {
             
-            domain = new BasicClassPoolDomain("Scoped" + System.identityHashCode(loaderRepository), mainDomain);
             boolean parentFirst = ((HeirarchicalLoaderRepository3)loaderRepository).getUseParentFirst();
-            domain.setParentFirst(parentFirst);
+            domain = new BaseClassPoolDomain("Scoped" + System.identityHashCode(loaderRepository), mainDomain, parentFirst);
          }
          else
          {
             if (mainDomain == null)
             {
-               domain = new BasicClassPoolDomain(ServerConstants.DEFAULT_LOADER_NAME, null);
+               domain = new BaseClassPoolDomain(ServerConstants.DEFAULT_LOADER_NAME, null, true);
                mainDomain = domain;
             }
             else

Modified: projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolDomain.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolDomain.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolDomain.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -34,11 +34,11 @@
 import javassist.NotFoundException;
 
 import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.BasicClassPoolDomain;
+import org.jboss.aop.classpool.BaseClassPoolDomain;
 import org.jboss.aop.classpool.ClassPoolDomain;
-import org.jboss.aop.classpool.ClassPoolToClassPoolDomainAdapter;
 import org.jboss.aop.classpool.DelegatingClassPool;
 import org.jboss.classloader.spi.DelegateLoader;
+import org.jboss.classloader.spi.ParentPolicy;
 import org.jboss.classloading.spi.dependency.Module;
 
 /**
@@ -46,24 +46,23 @@
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  * @version $Revision: 1.1 $
  */
-public class JBossClClassPoolDomain extends BasicClassPoolDomain
+public class JBossClClassPoolDomain extends BaseClassPoolDomain
 {
    Map<String, Set<DelegatingClassPool>> poolsByPackage = new HashMap<String, Set<DelegatingClassPool>>();
    final static List<DelegatingClassPool> EMPTY_LIST = Collections.unmodifiableList(Collections.EMPTY_LIST);
    
    AspectManager manager = AspectManager.instance();
    
-   public JBossClClassPoolDomain(String domainName, ClassPoolDomain parent)
+   public JBossClClassPoolDomain(String domainName, ClassPoolDomain parent, ParentPolicy parentPolicy)
    {
-      // FIXME JBossClClassPool constructor
-      super(domainName, parent);
+      super(domainName, 
+            new JBossClParentDelegationStrategy(
+                  parent, 
+                  parentPolicy, 
+                  JBossClClassPoolToClassPoolDomainAdaptorFactory.getInstance())
+      );
    }
 
-   protected ClassPoolToClassPoolDomainAdapter createParentClassPoolToClassPoolDomainAdaptor()
-   {
-      return new JBossClClassPoolToClassPoolDomainAdapter();
-   }
-   
    synchronized void setupPoolsByPackage(DelegatingClassPool pool)
    {
       if (pool instanceof JBossClDelegatingClassPool == false)
@@ -106,7 +105,7 @@
    public CtClass getCachedOrCreateInternal(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create)
    {
       Module module = getModuleForPool(initiatingPool);
-      if (module.isImportAll())
+      if (module != null && module.isImportAll())
       {
          //Use the old "big ball of mud" model
          return super.getCachedOrCreateInternal(initiatingPool, classname, resourceName, create);
@@ -114,30 +113,33 @@
       
       //Attempt OSGi style loading
       CtClass clazz = null;
-      if (isParentBefore())
+      if (isParentBefore(classname))
       {
          clazz = getCachedOrCreateInternalFromParent(null, classname, resourceName, create);
       }
       
       //Check imports first
-      List<? extends DelegateLoader> delegates = module.getDelegates();
-      if (delegates != null)
+      if (module != null)
       {
-         for (DelegateLoader delegate : delegates)
+         List<? extends DelegateLoader> delegates = module.getDelegates();
+         if (delegates != null)
          {
-            //TODO This is a hack, need a proper API in jboss-cl
-            System.err.println("Commented out loader from delegate in JBossClClassPoolDomain");
-            ClassLoader loader = null;//delegate.getBaseClassLoader("a BaseClassLoader", "");
-            
-            //TODO Should be a nicer way to do this
-            ClassPool pool = manager.findClassPool(loader);
-            try
+            for (DelegateLoader delegate : delegates)
             {
-               clazz = pool.get(classname);
+               //TODO This is a hack, need a proper API in jboss-cl
+               System.err.println("Commented out loader from delegate in JBossClClassPoolDomain");
+               ClassLoader loader = delegate.getBaseClassLoader("a BaseClassLoader", "");
+               
+               //TODO Should be a nicer way to do this
+               ClassPool pool = manager.findClassPool(loader);
+               try
+               {
+                  clazz = pool.get(classname);
+               }
+               catch(NotFoundException e)
+               {
+               }
             }
-            catch(NotFoundException e)
-            {
-            }
          }
       }
       
@@ -147,7 +149,7 @@
          clazz = initiatingPool.loadLocally(classname, resourceName, create);
       }
       
-      if (clazz == null && isParentAfter())
+      if (clazz == null && isParentAfter(classname))
       {
          clazz = getCachedOrCreateInternalFromParent(null, classname, resourceName, create);
       }
@@ -156,6 +158,10 @@
    
    private Module getModuleForPool(DelegatingClassPool pool)
    {
+      if (pool == null)
+      {
+         return null;
+      }
       return ((JBossClDelegatingClassPool)pool).getModule();
    }
    

Modified: projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolFactory.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolFactory.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolFactory.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -33,7 +33,6 @@
 import org.jboss.aop.classpool.NonDelegatingClassPool;
 import org.jboss.classloader.spi.ClassLoaderDomain;
 import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.ParentPolicy;
 import org.jboss.classloading.spi.RealClassLoader;
 import org.jboss.classloading.spi.dependency.Module;
 
@@ -94,11 +93,8 @@
             }
             parentPoolDomain = ClassPoolDomainRegistry.getInstance().getDomain(parentDomain);
          }
-         poolDomain = new JBossClClassPoolDomain(domain.getName(), parentPoolDomain);
+         poolDomain = new JBossClClassPoolDomain(domain.getName(), parentPoolDomain, domain.getParentPolicy());
          
-         //The determination of parentFirst/-Last might need revisiting
-         poolDomain.setParentFirst(domain.getParentPolicy() == ParentPolicy.BEFORE);
-         
          ClassPoolDomainRegistry.getInstance().addClassPoolDomain(domain, poolDomain);
       }
       return poolDomain;

Added: projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolToClassPoolDomainAdaptorFactory.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolToClassPoolDomainAdaptorFactory.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClClassPoolToClassPoolDomainAdaptorFactory.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,51 @@
+/*
+* 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.classpool.jbosscl;
+
+import org.jboss.aop.classpool.ClassPoolToClassPoolDomainAdapter;
+import org.jboss.aop.classpool.ClassPoolToClassPoolDomainAdaptorFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossClClassPoolToClassPoolDomainAdaptorFactory implements ClassPoolToClassPoolDomainAdaptorFactory
+{
+   private static final JBossClClassPoolToClassPoolDomainAdaptorFactory INSTANCE = new JBossClClassPoolToClassPoolDomainAdaptorFactory();
+   
+   private JBossClClassPoolToClassPoolDomainAdaptorFactory()
+   {
+      
+   }
+   
+   public static ClassPoolToClassPoolDomainAdaptorFactory getInstance()
+   {
+      return INSTANCE;
+   }
+   
+   public ClassPoolToClassPoolDomainAdapter createAdaptor()
+   {
+      return new JBossClClassPoolToClassPoolDomainAdapter();
+   }
+
+}

Added: projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClParentDelegationStrategy.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClParentDelegationStrategy.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/classpool/jbosscl/JBossClParentDelegationStrategy.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,60 @@
+/*
+* 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.classpool.jbosscl;
+
+import org.jboss.aop.classpool.AbstractParentDelegationStrategy;
+import org.jboss.aop.classpool.ClassPoolDomain;
+import org.jboss.aop.classpool.ClassPoolToClassPoolDomainAdaptorFactory;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.filter.ClassFilter;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class JBossClParentDelegationStrategy extends AbstractParentDelegationStrategy
+{
+   ParentPolicy parentPolicy;
+   
+   JBossClParentDelegationStrategy(ClassPoolDomain parent, ParentPolicy parentPolicy, ClassPoolToClassPoolDomainAdaptorFactory adaptorFactory)
+   {
+      super(parent, adaptorFactory);
+      if (parentPolicy == null)
+      {
+         throw new IllegalStateException("Null parent policy");
+      }
+      this.parentPolicy = parentPolicy;
+   }
+
+   public boolean isParentAfter(String classname)
+   {
+      ClassFilter filter = parentPolicy.getAfterFilter();
+      return filter.matchesClassName(classname);
+   }
+
+   public boolean isParentBefore(String classname)
+   {
+      ClassFilter filter = parentPolicy.getBeforeFilter();
+      return filter.matchesClassName(classname);
+   }
+}

Modified: projects/aop/trunk/asintegration-mc/src/resources/tests/org/jboss/test/aop/classpool/jbosscl/Common.xml
===================================================================
--- projects/aop/trunk/asintegration-mc/src/resources/tests/org/jboss/test/aop/classpool/jbosscl/Common.xml	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-mc/src/resources/tests/org/jboss/test/aop/classpool/jbosscl/Common.xml	2009-01-08 22:17:38 UTC (rev 82712)
@@ -11,15 +11,4 @@
       <uncallback method="removeModule" state="Configured"/>
    </bean>
 
-   <!-- bean name="SchemaResolverConfig" class="org.jboss.xb.binding.sunday.unmarshalling.SchemaResolverConfig">
-      <property name="bindingClasses">
-         <map keyClass="java.lang.String" valueClass="java.lang.String">
-            <entry>
-               <key>urn:jboss:classloader:1.0</key>
-               <value>org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10</value>
-            </entry>
-         </map>
-      </property>
-   </bean -->
-
 </deployment>

Added: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/NoMatchClassFilter.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/NoMatchClassFilter.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/NoMatchClassFilter.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,70 @@
+/*
+ * 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;
+   }
+}

Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactoryFactory.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactoryFactory.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/support/TestVFSClassLoaderFactoryFactory.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -46,6 +46,16 @@
       return createClassLoaderFactory(name, false, 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);
@@ -109,9 +119,15 @@
    private static List<String> urlsToStringList(URL... urls)
    {
       List<String> urlList = new ArrayList<String>(urls.length);
-      for (URL url : urls)
+      if (urls.length > 0)
       {
-         urlList.add(url.toString());
+         for (URL url : urls)
+         {
+            if (url != null)
+            {
+               urlList.add(url.toString());
+            }
+         }
       }
       return urlList;
    }

Added: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithHierarchicalDomainSanityTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithHierarchicalDomainSanityTestCase.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithHierarchicalDomainSanityTestCase.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,495 @@
+/*
+* 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.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.aop.classpool.jbosscl.support.BundleInfoBuilder;
+import org.jboss.test.aop.classpool.jbosscl.support.Result;
+
+/**
+ * Tests the behaviour of the new classloaders so that we can get the same in the new classpools
+ * Reproduces org.jboss.test.classloading.dependency.test.HierarchicalDomainUnitTestCase using our test framework, 
+ * ClassPoolWithHierarchicalDomainSanityTestCase replicates this with the javassist classpools
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassLoaderWithHierarchicalDomainSanityTestCase extends JBossClClassPoolTest
+{
+   public ClassLoaderWithHierarchicalDomainSanityTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ClassLoaderWithHierarchicalDomainSanityTestCase.class);
+   }
+   
+   public void testParentFirst() throws Exception
+   {
+      ClassLoader clParentA = null;
+      Result resultParentA = new Result();
+      try
+      {
+         clParentA = createClassLoader(resultParentA, "aParent", true, JAR_A_1);
+         assertLoadClass(CLASS_A, clParentA);
+         assertCannotLoadClass(CLASS_B, clParentA);
+         
+         ClassLoader clChildA = null;
+         Result resultChildA = new Result();
+         final String childDomainName = "ChildDomain";
+         try
+         {
+            clChildA = createChildDomainParentFirstClassLoader(resultChildA, "aChild", childDomainName, true, JAR_A_2);
+            assertLoadClass(CLASS_A, clParentA);
+            assertLoadClass(CLASS_A, clChildA, clParentA);
+            assertCannotLoadClass(CLASS_B, clChildA);
+            
+            ClassLoader clB = null;
+            Result resultB = new Result();
+            try
+            {
+               BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+                  createRequirePackage(PACKAGE_A);
+               clB = createChildDomainParentFirstClassLoader(resultB, "b", childDomainName, builderB, JAR_B_1);
+               
+               assertLoadClass(CLASS_A, clParentA);
+               assertLoadClass(CLASS_B, clB);
+               assertLoadClass(CLASS_A, clB, clParentA);
+            }
+            finally
+            {
+               unregisterClassLoader(clB);
+            }
+            assertNoClassLoader(resultB);
+         }
+         finally
+         {
+            unregisterClassLoader(clChildA);
+            unregisterDomain(childDomainName);
+         }
+         assertNoClassLoader(resultChildA);
+      }
+      finally
+      {
+         unregisterClassLoader(clParentA);
+      }
+      assertNoClassLoader(resultParentA);
+   }
+   
+   public void testParentLast() throws Exception
+   {
+      ClassLoader clParentA = null;
+      Result resultParentA = new Result();
+      try
+      {
+         clParentA = createClassLoader(resultParentA, "aParent", true, JAR_A_1);
+         assertLoadClass(CLASS_A, clParentA);
+         assertCannotLoadClass(CLASS_B, clParentA);
+         
+         ClassLoader clChildA = null;
+         Result resultChildA = new Result();
+         final String childDomainName = "ChildDomain";
+         try
+         {
+            clChildA = createChildDomainParentLastClassLoader(resultChildA, "aChild", childDomainName, true, JAR_A_2);
+            assertLoadClass(CLASS_A, clParentA);
+            assertLoadClass(CLASS_A, clChildA);
+            assertCannotLoadClass(CLASS_B, clChildA);
+            
+            ClassLoader clB = null;
+            Result resultB = new Result();
+            try
+            {
+               BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+                  createRequirePackage(PACKAGE_A);
+               clB = createChildDomainParentLastClassLoader(resultB, "b", childDomainName, builderB, JAR_B_1);
+               
+               assertLoadClass(CLASS_A, clChildA);
+               assertLoadClass(CLASS_B, clB);
+               assertLoadClass(CLASS_A, clB, clChildA);
+            }
+            finally
+            {
+               unregisterClassLoader(clB);
+            }
+            assertNoClassLoader(resultB);
+         }
+         finally
+         {
+            unregisterClassLoader(clChildA);
+            unregisterDomain(childDomainName);
+         }
+         assertNoClassLoader(resultChildA);
+      }
+      finally
+      {
+         unregisterClassLoader(clParentA);
+      }
+      assertNoClassLoader(resultParentA);
+   }
+   
+   public void testParentLastNotInChild() throws Exception
+   {
+      ClassLoader clParentA = null;
+      Result resultParentA = new Result();
+      try
+      {
+         clParentA = createClassLoader(resultParentA, "aParent", true, JAR_A_1);
+         assertLoadClass(CLASS_A, clParentA);
+         assertCannotLoadClass(CLASS_B, clParentA);
+         
+         ClassLoader clB = null;
+         Result resultB = new Result();
+         final String childDomainName = "ChildDomain";
+         try
+         {
+            BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+               createRequirePackage(PACKAGE_A);
+            clB = createChildDomainParentLastClassLoader(resultB, "b", childDomainName, builderB, JAR_B_1);
+            
+            assertLoadClass(CLASS_A, clParentA);
+            assertLoadClass(CLASS_B, clB);
+            assertLoadClass(CLASS_A, clB, clParentA);
+         }
+         finally
+         {
+            unregisterClassLoader(clB);
+            unregisterDomain(childDomainName);
+         }
+         assertNoClassLoader(resultB);
+      }
+      finally
+      {
+         unregisterClassLoader(clParentA);
+      }
+      assertNoClassLoader(resultParentA);
+   }
+   
+   public void testParentFirstWrongWayAround() throws Exception
+   {
+      ClassLoader clB = null;
+      Result resultB = new Result();
+      final String childDomainName = "ChildDomain";
+      try
+      {
+         BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+            createRequirePackage(PACKAGE_A);
+         try
+         {
+            clB = createChildDomainParentFirstClassLoader(resultB, "b", childDomainName, builderB, JAR_B_1);
+            fail("Should be no loader");
+         }
+         catch(NoSuchClassLoaderException e)
+         {
+         }
+         assertNoClassLoader(resultB);
+         
+         ClassLoader clParentA = null;
+         Result resultParentA = new Result();
+         try
+         {
+            clParentA = createClassLoader(resultParentA, "aParent", true, JAR_A_1);
+            assertLoadClass(CLASS_A, clParentA);
+            assertCannotLoadClass(CLASS_B, clParentA);
+            
+            clB = assertClassLoader(resultB.getFactory());
+            assertLoadClass(CLASS_A, clParentA);
+            assertLoadClass(CLASS_A, clB, clParentA);
+            assertLoadClass(CLASS_B, clB);
+         }
+         finally
+         {
+            unregisterClassLoader(clParentA);
+         }
+         assertNoClassLoader(resultParentA);
+      }
+      finally
+      {
+         unregisterClassLoader(clB);
+         unregisterDomain(childDomainName);
+      }
+      assertNoClassLoader(resultB);
+   }
+   
+   public void testParentLastWrongWayAround() throws Exception
+   {
+      ClassLoader clB = null;
+      Result resultB = new Result();
+      final String childDomainName = "ChildDomain";
+      try
+      {
+         BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+            createRequirePackage(PACKAGE_A);
+         try
+         {
+            clB = createChildDomainParentLastClassLoader(resultB, "b", childDomainName, builderB, JAR_B_1);
+            fail("Should be no loader");
+         }
+         catch(NoSuchClassLoaderException e)
+         {
+         }
+         assertNoClassLoader(resultB);
+         
+         ClassLoader clParentA = null;
+         Result resultParentA = new Result();
+         try
+         {
+            clParentA = createClassLoader(resultParentA, "aParent", true, JAR_A_1);
+            assertLoadClass(CLASS_A, clParentA);
+            assertCannotLoadClass(CLASS_B, clParentA);
+            
+            clB = assertClassLoader(resultB.getFactory());
+            assertLoadClass(CLASS_A, clParentA);
+            assertLoadClass(CLASS_A, clB, clParentA);
+            assertLoadClass(CLASS_B, clB);
+         }
+         finally
+         {
+            unregisterClassLoader(clParentA);
+         }
+         assertNoClassLoader(resultParentA);
+      }
+      finally
+      {
+         unregisterClassLoader(clB);
+         unregisterDomain(childDomainName);
+      }
+   }
+   
+   public void testParentRedeploy() throws Exception
+   {
+      ClassLoader clB = null;
+      Result resultB = new Result();
+      final String childDomainName = "ChildDomain";
+      try
+      {
+         BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+            createRequirePackage(PACKAGE_A);
+         try
+         {
+            clB = createChildDomainParentFirstClassLoader(resultB, "b", childDomainName, builderB, JAR_B_1);
+            fail("Should be no loader");
+         }
+         catch(NoSuchClassLoaderException e)
+         {
+         }
+         assertNoClassLoader(resultB);
+
+         ClassLoader clParentA = null;
+         Result resultParentA = new Result();
+         try
+         {
+            clParentA = createClassLoader(resultParentA, "aParent", true, JAR_A_1);
+            assertLoadClass(CLASS_A, clParentA);
+            assertCannotLoadClass(CLASS_B, clParentA);
+            
+            clB = assertClassLoader(resultB.getFactory());
+            assertLoadClass(CLASS_A, clParentA);
+            assertLoadClass(CLASS_A, clB, clParentA);
+            assertLoadClass(CLASS_B, clB);
+         }
+         finally
+         {
+            unregisterClassLoader(clParentA);
+         }
+
+         assertNoClassLoader(resultParentA);
+         assertNoClassLoader(resultB);
+      
+         try
+         {
+            clParentA = createClassLoader(resultParentA, "aParent", true, JAR_A_1);
+            assertLoadClass(CLASS_A, clParentA);
+            assertCannotLoadClass(CLASS_B, clParentA);
+            
+            clB = assertClassLoader(resultB.getFactory());
+            assertLoadClass(CLASS_A, clParentA);
+            assertLoadClass(CLASS_A, clB, clParentA);
+            assertLoadClass(CLASS_B, clB);
+         }
+         finally
+         {
+            unregisterClassLoader(clParentA);
+         }
+         assertNoClassLoader(resultParentA);
+      }
+      finally
+      {
+         unregisterClassLoader(clB);
+         unregisterDomain(childDomainName);
+      }
+      assertNoClassLoader(resultB);
+   }
+   
+   public void testParentOtherDomain() throws Exception
+   {
+      ClassLoader clParentA = null;
+      Result resultParentA = new Result();
+      final String parentDomainName = "ParentDomain";
+      try
+      {
+         clParentA = createChildDomainParentFirstClassLoader(resultParentA, "aParent", parentDomainName, true, JAR_A_1);
+         assertLoadClass(CLASS_A, clParentA);
+         assertCannotLoadClass(CLASS_B, clParentA);
+         
+         ClassLoader clB = null;
+         Result resultB = new Result();
+         final String childDomainName = "ChildDomain";
+         try
+         {
+            BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+               createRequirePackage(PACKAGE_A);
+            clB = createChildDomainParentFirstClassLoader(resultB, "b", childDomainName, parentDomainName, builderB, JAR_B_1);
+            assertLoadClass(CLASS_A, clParentA);
+            assertLoadClass(CLASS_B, clB);
+            assertLoadClass(CLASS_A, clB, clParentA);
+         }
+         finally
+         {
+            unregisterClassLoader(clB);
+            unregisterDomain(childDomainName);
+         }
+      }
+      finally
+      {
+         unregisterClassLoader(clParentA);
+         unregisterDomain(parentDomainName);
+      }
+   }
+   
+   public void testParentOtherDomainLazy() throws Exception
+   {
+      ClassLoader clB = null;
+      Result resultB = new Result();
+      final String parentDomainName = "ParentDomain";
+      final String childDomainName = "ChildDomain";
+      try
+      {
+         BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+            createRequirePackage(PACKAGE_A);
+         try
+         {
+            clB = createChildDomainParentFirstClassLoader(resultB, "b", childDomainName, parentDomainName, builderB, JAR_B_1);
+            fail("Should be no loader");
+         }
+         catch(NoSuchClassLoaderException e)
+         {
+         }
+         assertNoClassLoader(resultB);
+         
+         ClassLoader clParentA = null;
+         Result resultParentA = new Result();
+         try
+         {
+            clParentA = createChildDomainParentFirstClassLoader(resultParentA, "aParent", parentDomainName, true, JAR_A_1);
+            assertLoadClass(CLASS_A, clParentA);
+            assertCannotLoadClass(CLASS_B, clParentA);
+
+            clB = assertClassLoader(resultB.getFactory());
+            assertLoadClass(CLASS_A, clParentA);
+            assertCannotLoadClass(CLASS_B, clParentA);
+            assertLoadClass(CLASS_A, clB, clParentA);
+         }
+         finally
+         {
+            unregisterClassLoader(clParentA);
+            unregisterDomain(parentDomainName);
+         }
+         assertNoClassLoader(resultParentA);
+      }
+      finally
+      {
+         unregisterClassLoader(clB);
+         unregisterDomain(childDomainName);
+      }
+      assertNoClassLoader(resultB);
+   }
+
+   public void testParentRedeployOtherDomain() throws Exception
+   {
+      ClassLoader clB = null;
+      Result resultB = new Result();
+      final String parentDomainName = "ParentDomain";
+      final String childDomainName = "ChildDomain";
+      try
+      {
+         BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+            createRequirePackage(PACKAGE_A);
+         try
+         {
+            clB = createChildDomainParentFirstClassLoader(resultB, "b", childDomainName, parentDomainName, builderB, JAR_B_1);
+            fail("Should be no loader");
+         }
+         catch(NoSuchClassLoaderException e)
+         {
+         }
+         assertNoClassLoader(resultB);
+         
+         ClassLoader clParentA = null;
+         Result resultParentA = new Result();
+         try
+         {
+            clParentA = createChildDomainParentFirstClassLoader(resultParentA, "aParent", parentDomainName, true, JAR_A_1);
+            assertLoadClass(CLASS_A, clParentA);
+            assertCannotLoadClass(CLASS_B, clParentA);
+
+            clB = assertClassLoader(resultB.getFactory());
+            assertLoadClass(CLASS_A, clParentA);
+            assertCannotLoadClass(CLASS_B, clParentA);
+            assertLoadClass(CLASS_A, clB, clParentA);
+         }
+         finally
+         {
+            unregisterClassLoader(clParentA);
+            unregisterDomain(parentDomainName);
+         }
+         assertNoClassLoader(resultParentA);
+         assertNoClassLoader(resultB);
+
+         try
+         {
+            clParentA = createChildDomainParentFirstClassLoader(resultParentA, "aParent", parentDomainName, true, JAR_A_1);
+            assertLoadClass(CLASS_A, clParentA);
+            assertCannotLoadClass(CLASS_B, clParentA);
+
+            clB = assertClassLoader(resultB.getFactory());
+            assertLoadClass(CLASS_A, clParentA);
+            assertCannotLoadClass(CLASS_B, clParentA);
+            assertLoadClass(CLASS_A, clB, clParentA);
+         }
+         finally
+         {
+            unregisterClassLoader(clParentA);
+            unregisterDomain(parentDomainName);
+         }
+      }
+      finally
+      {
+         unregisterClassLoader(clB);
+         unregisterDomain(childDomainName);
+      }
+      assertNoClassLoader(resultB);
+   }
+}

Added: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithHierarchicalParentLoaderSanityTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithHierarchicalParentLoaderSanityTestCase.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassLoaderWithHierarchicalParentLoaderSanityTestCase.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,126 @@
+/*
+* 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.test;
+
+import java.net.URL;
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.test.aop.classpool.jbosscl.support.NoMatchClassFilter;
+
+import junit.framework.Test;
+
+/**
+ * Tests the behaviour of the new classloaders so that we can get the same in the new classpools
+ * Reproduces org.jboss.test.classloader.domain.test.HierarchicalParentLoaderUnitTestCase using our test framework, 
+ * ClassPoolWithHierarchicalParentLoaderUnitTestCaseSanityTestCase replicates this with the javassist classpools
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassLoaderWithHierarchicalParentLoaderSanityTestCase extends JBossClClassPoolTest
+{
+   public ClassLoaderWithHierarchicalParentLoaderSanityTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ClassLoaderWithHierarchicalParentLoaderSanityTestCase.class);
+   }
+   
+   public void testHierarchyBefore() throws Exception
+   {
+      runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.BEFORE, true);
+   }
+   
+   
+   public void testHierarchyBeforeNotFound() throws Exception
+   {
+      runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.BEFORE, false, false);
+   }
+   
+   public void testHierarchyAfterNotReached() throws Exception
+   {
+      runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.AFTER_BUT_JAVA_BEFORE, false);
+   }
+   
+   public void testHierarchyAfterReached() throws Exception
+   {
+      runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.AFTER_BUT_JAVA_BEFORE, null, true);
+   }
+   
+   public void testHierarchyFiltered() throws Exception
+   {
+      NoMatchClassFilter filter = new NoMatchClassFilter(CLASS_A);
+      runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, new ParentPolicy(filter, ClassFilter.NOTHING), false);
+
+      assertTrue("Should have been filtered", filter.filtered);
+   }
+
+
+   private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, boolean expectedParent) throws Exception
+   {
+      runTest(parentParentPolicy, childParentPolicy, true, JAR_A_2, expectedParent);
+   }
+   
+   private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, boolean createParent, boolean expectedParent) throws Exception
+   {
+      runTest(parentParentPolicy, childParentPolicy, createParent, JAR_A_2, expectedParent);
+   }
+   
+   private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, URL url, boolean expectedParent) throws Exception
+   {
+      runTest(parentParentPolicy, childParentPolicy, true, null, expectedParent);
+   }
+   
+   private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, boolean createParent, URL childURL, boolean expectedParent) throws Exception
+   {
+      final String parentName = "parent";
+      final String childName = "child";
+      ClassLoaderDomain parent = getSystem().createAndRegisterDomain(parentName, parentParentPolicy);
+      ClassLoaderDomain child = getSystem().createAndRegisterDomain(childName, childParentPolicy, parent);
+
+      ClassLoader parentLoader = null;
+      ClassLoader childLoader = null;
+      try
+      {
+         //Since the domain is created first, the first/last flag from these two methods is ignored, instead the
+         //policy used when creating the domain is used
+         if (createParent)
+         {
+            parentLoader = createChildDomainParentLastClassLoader("ParentLoader", parentName, true, JAR_A_1);
+         }
+         childLoader = createChildDomainParentLastClassLoader("ChildLoader", childName, parentName, true, childURL);
+         assertLoadClass(CLASS_A, childLoader, expectedParent ? parentLoader : childLoader);
+      }
+      finally
+      {
+         unregisterClassLoader(parentLoader);
+         unregisterClassLoader(childLoader);
+         unregisterDomain(child);
+         unregisterDomain(parent);
+      }
+   }
+}

Added: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithHierarchicalDomainTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithHierarchicalDomainTestCase.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithHierarchicalDomainTestCase.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,498 @@
+/*
+* 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.test;
+
+import java.net.URL;
+
+import javassist.ClassPool;
+import junit.framework.Test;
+
+import org.jboss.test.aop.classpool.jbosscl.support.BundleInfoBuilder;
+import org.jboss.test.aop.classpool.jbosscl.support.Result;
+
+/**
+ * Tests the behaviour of the new classloaders so that we can get the same in the new classpools
+ * Reproduces org.jboss.test.classloading.dependency.test.HierarchicalDomainUnitTestCase using our test framework, 
+ * ClassPoolWithHierarchicalDomainSanityTestCase replicates this with the javassist classpools
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassPoolWithHierarchicalDomainTestCase extends JBossClClassPoolTest
+{
+   public ClassPoolWithHierarchicalDomainTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ClassPoolWithHierarchicalDomainTestCase.class);
+   }
+
+   public void testParentFirst() throws Exception
+   {
+      ClassPool poolParentA = null;
+      Result resultParentA = new Result();
+      try
+      {
+         poolParentA = createClassPool(resultParentA, "aParent", true, JAR_A_1);
+         assertLoadCtClass(CLASS_A, poolParentA);
+         assertCannotLoadCtClass(CLASS_B, poolParentA);
+         
+         ClassPool poolChildA = null;
+         Result resultChildA = new Result();
+         final String childDomainName = "ChildDomain";
+         try
+         {
+            poolChildA = createChildDomainParentFirstClassPool(resultChildA, "aChild", childDomainName, true, JAR_A_2);
+            assertLoadCtClass(CLASS_A, poolParentA);
+            assertLoadCtClass(CLASS_A, poolChildA, poolParentA);
+            assertCannotLoadCtClass(CLASS_B, poolChildA);
+            
+            ClassPool poolB = null;
+            Result resultB = new Result();
+            try
+            {
+               BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+                  createRequirePackage(PACKAGE_A);
+               poolB = createChildDomainParentFirstClassPool(resultB, "b", childDomainName, builderB, JAR_B_1);
+               
+               assertLoadCtClass(CLASS_A, poolParentA);
+               assertLoadCtClass(CLASS_B, poolB);
+               assertLoadCtClass(CLASS_A, poolB, poolParentA);
+            }
+            finally
+            {
+               unregisterClassPool(poolB);
+            }
+            assertNoClassPool(resultB);
+         }
+         finally
+         {
+            unregisterClassPool(poolChildA);
+            unregisterDomain(childDomainName);
+         }
+         assertNoClassPool(resultChildA);
+      }
+      finally
+      {
+         unregisterClassPool(poolParentA);
+      }
+      assertNoClassPool(resultParentA);
+   }
+   
+   public void testParentLast() throws Exception
+   {
+      ClassPool clParentA = null;
+      Result resultParentA = new Result();
+      try
+      {
+         clParentA = createClassPool(resultParentA, "aParent", true, JAR_A_1);
+         assertLoadCtClass(CLASS_A, clParentA);
+         assertCannotLoadCtClass(CLASS_B, clParentA);
+         
+         ClassPool poolChildA = null;
+         Result resultChildA = new Result();
+         final String childDomainName = "ChildDomain";
+         try
+         {
+            poolChildA = createChildDomainParentLastClassPool(resultChildA, "aChild", childDomainName, true, JAR_A_2);
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertLoadCtClass(CLASS_A, poolChildA);
+            assertCannotLoadCtClass(CLASS_B, poolChildA);
+            
+            ClassPool poolB = null;
+            Result resultB = new Result();
+            try
+            {
+               BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+                  createRequirePackage(PACKAGE_A);
+               poolB = createChildDomainParentLastClassPool(resultB, "b", childDomainName, builderB, JAR_B_1);
+               
+               assertLoadCtClass(CLASS_A, poolChildA);
+               assertLoadCtClass(CLASS_B, poolB);
+               assertLoadCtClass(CLASS_A, poolB, poolChildA);
+            }
+            finally
+            {
+               unregisterClassPool(poolB);
+            }
+            assertNoClassPool(resultB);
+         }
+         finally
+         {
+            unregisterClassPool(poolChildA);
+            unregisterDomain(childDomainName);
+         }
+         assertNoClassPool(resultChildA);
+      }
+      finally
+      {
+         unregisterClassPool(clParentA);
+      }
+      assertNoClassPool(resultParentA);
+   }
+   
+   public void testParentLastNotInChild() throws Exception
+   {
+      ClassPool clParentA = null;
+      Result resultParentA = new Result();
+      try
+      {
+         clParentA = createClassPool(resultParentA, "aParent", true, JAR_A_1);
+         assertLoadCtClass(CLASS_A, clParentA);
+         assertCannotLoadCtClass(CLASS_B, clParentA);
+         
+         ClassPool poolB = null;
+         Result resultB = new Result();
+         final String childDomainName = "ChildDomain";
+         try
+         {
+            BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+               createRequirePackage(PACKAGE_A);
+            poolB = createChildDomainParentLastClassPool(resultB, "b", childDomainName, builderB, JAR_B_1);
+            
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertLoadCtClass(CLASS_B, poolB);
+            assertLoadCtClass(CLASS_A, poolB, clParentA);
+         }
+         finally
+         {
+            unregisterClassPool(poolB);
+            unregisterDomain(childDomainName);
+         }
+         assertNoClassPool(resultB);
+      }
+      finally
+      {
+         unregisterClassPool(clParentA);
+      }
+      assertNoClassPool(resultParentA);
+   }
+   
+   public void testParentFirstWrongWayAround() throws Exception
+   {
+      ClassPool poolB = null;
+      Result resultB = new Result();
+      final String childDomainName = "ChildDomain";
+      try
+      {
+         BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+            createRequirePackage(PACKAGE_A);
+         try
+         {
+            poolB = createChildDomainParentFirstClassPool(resultB, "b", childDomainName, builderB, JAR_B_1);
+            fail("Should be no loader");
+         }
+         catch(NoSuchClassLoaderException e)
+         {
+         }
+         assertNoClassPool(resultB);
+         
+         ClassPool clParentA = null;
+         Result resultParentA = new Result();
+         try
+         {
+            clParentA = createClassPool(resultParentA, "aParent", true, JAR_A_1);
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertCannotLoadCtClass(CLASS_B, clParentA);
+            
+            poolB = assertClassPool(resultB.getFactory());
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertLoadCtClass(CLASS_A, poolB, clParentA);
+            assertLoadCtClass(CLASS_B, poolB);
+         }
+         finally
+         {
+            unregisterClassPool(clParentA);
+         }
+         assertNoClassPool(resultParentA);
+      }
+      finally
+      {
+         unregisterClassPool(poolB);
+         unregisterDomain(childDomainName);
+      }
+      assertNoClassPool(resultB);
+   }
+   
+   public void testParentLastWrongWayAround() throws Exception
+   {
+      ClassPool poolB = null;
+      Result resultB = new Result();
+      final String childDomainName = "ChildDomain";
+      try
+      {
+         BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+            createRequirePackage(PACKAGE_A);
+         try
+         {
+            poolB = createChildDomainParentLastClassPool(resultB, "b", childDomainName, builderB, JAR_B_1);
+            fail("Should be no loader");
+         }
+         catch(NoSuchClassLoaderException e)
+         {
+         }
+         assertNoClassPool(resultB);
+         
+         ClassPool clParentA = null;
+         Result resultParentA = new Result();
+         try
+         {
+            clParentA = createClassPool(resultParentA, "aParent", true, JAR_A_1);
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertCannotLoadCtClass(CLASS_B, clParentA);
+            
+            poolB = assertClassPool(resultB.getFactory());
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertLoadCtClass(CLASS_A, poolB, clParentA);
+            assertLoadCtClass(CLASS_B, poolB);
+         }
+         finally
+         {
+            unregisterClassPool(clParentA);
+         }
+         assertNoClassPool(resultParentA);
+      }
+      finally
+      {
+         unregisterClassPool(poolB);
+         unregisterDomain(childDomainName);
+      }
+   }
+   
+   public void testParentRedeploy() throws Exception
+   {
+      ClassPool poolB = null;
+      Result resultB = new Result();
+      final String childDomainName = "ChildDomain";
+      try
+      {
+         BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+            createRequirePackage(PACKAGE_A);
+         try
+         {
+            poolB = createChildDomainParentFirstClassPool(resultB, "b", childDomainName, builderB, JAR_B_1);
+            fail("Should be no loader");
+         }
+         catch(NoSuchClassLoaderException e)
+         {
+         }
+         assertNoClassPool(resultB);
+
+         ClassPool clParentA = null;
+         Result resultParentA = new Result();
+         try
+         {
+            clParentA = createClassPool(resultParentA, "aParent", true, JAR_A_1);
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertCannotLoadCtClass(CLASS_B, clParentA);
+            
+            poolB = assertClassPool(resultB.getFactory());
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertLoadCtClass(CLASS_A, poolB, clParentA);
+            assertLoadCtClass(CLASS_B, poolB);
+         }
+         finally
+         {
+            unregisterClassPool(clParentA);
+         }
+
+         assertNoClassPool(resultParentA);
+         assertNoClassPool(resultB);
+      
+         try
+         {
+            clParentA = createClassPool(resultParentA, "aParent", true, JAR_A_1);
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertCannotLoadCtClass(CLASS_B, clParentA);
+            
+            poolB = assertClassPool(resultB.getFactory());
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertLoadCtClass(CLASS_A, poolB, clParentA);
+            assertLoadCtClass(CLASS_B, poolB);
+         }
+         finally
+         {
+            unregisterClassPool(clParentA);
+         }
+         assertNoClassPool(resultParentA);
+      }
+      finally
+      {
+         unregisterClassPool(poolB);
+         unregisterDomain(childDomainName);
+      }
+      assertNoClassPool(resultB);
+   }
+   
+   public void testParentOtherDomain() throws Exception
+   {
+      ClassPool clParentA = null;
+      Result resultParentA = new Result();
+      final String parentDomainName = "ParentDomain";
+      try
+      {
+         clParentA = createChildDomainParentFirstClassPool(resultParentA, "aParent", parentDomainName, true, JAR_A_1);
+         assertLoadCtClass(CLASS_A, clParentA);
+         assertCannotLoadCtClass(CLASS_B, clParentA);
+         
+         ClassPool poolB = null;
+         Result resultB = new Result();
+         final String childDomainName = "ChildDomain";
+         try
+         {
+            BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+               createRequirePackage(PACKAGE_A);
+            poolB = createChildDomainParentFirstClassPool(resultB, "b", childDomainName, parentDomainName, builderB, JAR_B_1);
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertLoadCtClass(CLASS_B, poolB);
+            assertLoadCtClass(CLASS_A, poolB, clParentA);
+         }
+         finally
+         {
+            unregisterClassPool(poolB);
+            unregisterDomain(childDomainName);
+         }
+      }
+      finally
+      {
+         unregisterClassPool(clParentA);
+         unregisterDomain(parentDomainName);
+      }
+   }
+   
+   public void testParentOtherDomainLazy() throws Exception
+   {
+      ClassPool poolB = null;
+      Result resultB = new Result();
+      final String parentDomainName = "ParentDomain";
+      final String childDomainName = "ChildDomain";
+      try
+      {
+         BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+            createRequirePackage(PACKAGE_A);
+         try
+         {
+            poolB = createChildDomainParentFirstClassPool(resultB, "b", childDomainName, parentDomainName, builderB, JAR_B_1);
+            fail("Should be no loader");
+         }
+         catch(NoSuchClassLoaderException e)
+         {
+         }
+         assertNoClassPool(resultB);
+         
+         ClassPool clParentA = null;
+         Result resultParentA = new Result();
+         try
+         {
+            clParentA = createChildDomainParentFirstClassPool(resultParentA, "aParent", parentDomainName, true, JAR_A_1);
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertCannotLoadCtClass(CLASS_B, clParentA);
+
+            poolB = assertClassPool(resultB.getFactory());
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertCannotLoadCtClass(CLASS_B, clParentA);
+            assertLoadCtClass(CLASS_A, poolB, clParentA);
+         }
+         finally
+         {
+            unregisterClassPool(clParentA);
+            unregisterDomain(parentDomainName);
+         }
+         assertNoClassPool(resultParentA);
+      }
+      finally
+      {
+         unregisterClassPool(poolB);
+         unregisterDomain(childDomainName);
+      }
+      assertNoClassPool(resultB);
+   }
+
+   public void testParentRedeployOtherDomain() throws Exception
+   {
+      ClassPool poolB = null;
+      Result resultB = new Result();
+      final String parentDomainName = "ParentDomain";
+      final String childDomainName = "ChildDomain";
+      try
+      {
+         BundleInfoBuilder builderB = BundleInfoBuilder.getBuilder().
+            createRequirePackage(PACKAGE_A);
+         try
+         {
+            poolB = createChildDomainParentFirstClassPool(resultB, "b", childDomainName, parentDomainName, builderB, JAR_B_1);
+            fail("Should be no loader");
+         }
+         catch(NoSuchClassLoaderException e)
+         {
+         }
+         assertNoClassPool(resultB);
+         
+         ClassPool clParentA = null;
+         Result resultParentA = new Result();
+         try
+         {
+            clParentA = createChildDomainParentFirstClassPool(resultParentA, "aParent", parentDomainName, true, JAR_A_1);
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertCannotLoadCtClass(CLASS_B, clParentA);
+
+            poolB = assertClassPool(resultB.getFactory());
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertCannotLoadCtClass(CLASS_B, clParentA);
+            assertLoadCtClass(CLASS_A, poolB, clParentA);
+         }
+         finally
+         {
+            unregisterClassPool(clParentA);
+            unregisterDomain(parentDomainName);
+         }
+         assertNoClassPool(resultParentA);
+         assertNoClassPool(resultB);
+
+         try
+         {
+            clParentA = createChildDomainParentFirstClassPool(resultParentA, "aParent", parentDomainName, true, JAR_A_1);
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertCannotLoadCtClass(CLASS_B, clParentA);
+
+            poolB = assertClassPool(resultB.getFactory());
+            assertLoadCtClass(CLASS_A, clParentA);
+            assertCannotLoadCtClass(CLASS_B, clParentA);
+            assertLoadCtClass(CLASS_A, poolB, clParentA);
+         }
+         finally
+         {
+            unregisterClassPool(clParentA);
+            unregisterDomain(parentDomainName);
+         }
+      }
+      finally
+      {
+         unregisterClassPool(poolB);
+         unregisterDomain(childDomainName);
+      }
+      assertNoClassPool(resultB);
+   }
+}

Added: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithHierarchicalParentLoaderTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithHierarchicalParentLoaderTestCase.java	                        (rev 0)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithHierarchicalParentLoaderTestCase.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -0,0 +1,128 @@
+/*
+* 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.test;
+
+import java.net.URL;
+
+import javassist.ClassPool;
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.filter.ClassFilter;
+import org.jboss.test.aop.classpool.jbosscl.support.NoMatchClassFilter;
+
+import junit.framework.Test;
+
+/**
+ * Tests the behaviour of the new classloaders so that we can get the same in the new classpools
+ * Reproduces org.jboss.test.classloader.domain.test.HierarchicalParentLoaderUnitTestCase using our test framework, 
+ * ClassPoolWithHierarchicalParentLoaderUnitTestCaseSanityTestCase replicates this with the javassist classpools
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClassPoolWithHierarchicalParentLoaderTestCase extends JBossClClassPoolTest
+{
+   public ClassPoolWithHierarchicalParentLoaderTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(ClassPoolWithHierarchicalParentLoaderTestCase.class);
+   }
+   
+   public void testHierarchyBefore() throws Exception
+   {
+      runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.BEFORE, true);
+   }
+   
+   
+   public void testHierarchyBeforeNotFound() throws Exception
+   {
+      runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.BEFORE, false, false);
+   }
+   
+   public void testHierarchyAfterNotReached() throws Exception
+   {
+      runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.AFTER_BUT_JAVA_BEFORE, false);
+   }
+   
+   public void testHierarchyAfterReached() throws Exception
+   {
+      runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, ParentPolicy.AFTER_BUT_JAVA_BEFORE, null, true);
+   }
+   
+   public void testHierarchyFiltered() throws Exception
+   {
+      NoMatchClassFilter filter = new NoMatchClassFilter(CLASS_A);
+      runTest(ParentPolicy.BEFORE_BUT_JAVA_ONLY, new ParentPolicy(filter, ClassFilter.NOTHING), false);
+
+      assertTrue("Should have been filtered", filter.filtered);
+   }
+
+
+   private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, boolean expectedParent) throws Exception
+   {
+      runTest(parentParentPolicy, childParentPolicy, true, JAR_A_2, expectedParent);
+   }
+   
+   private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, boolean createParent, boolean expectedParent) throws Exception
+   {
+      runTest(parentParentPolicy, childParentPolicy, createParent, JAR_A_2, expectedParent);
+   }
+   
+   private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, URL url, boolean expectedParent) throws Exception
+   {
+      runTest(parentParentPolicy, childParentPolicy, true, null, expectedParent);
+   }
+   
+   private void runTest(ParentPolicy parentParentPolicy, ParentPolicy childParentPolicy, boolean createParent, URL childURL, boolean expectedParent) throws Exception
+   {
+      final String parentName = "parent";
+      final String childName = "child";
+      ClassLoaderDomain parent = getSystem().createAndRegisterDomain(parentName, parentParentPolicy);
+      ClassLoaderDomain child = getSystem().createAndRegisterDomain(childName, childParentPolicy, parent);
+
+      ClassPool parentPool = null;
+      ClassPool childPool = null;
+      try
+      {
+         //Since the domain is created first, the first/last flag from these two methods is ignored, instead the
+         //policy used when creating the domain is used
+         if (createParent)
+         {
+            parentPool = createChildDomainParentLastClassPool("ParentLoader", parentName, true, JAR_A_1);
+         }
+         childPool = createChildDomainParentLastClassPool("ChildLoader", childName, parentName, true, childURL);
+         assertLoadCtClass(CLASS_A, childPool, expectedParent ? parentPool : childPool);
+      }
+      finally
+      {
+         unregisterClassPool(parentPool);
+         unregisterClassPool(childPool);
+         unregisterDomain(child);
+         unregisterDomain(parent);
+      }
+   }
+}

Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithModuleDependencyTestCase.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithModuleDependencyTestCase.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/ClassPoolWithModuleDependencyTestCase.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -150,7 +150,7 @@
          BundleInfoBuilder builderA = BundleInfoBuilder.getBuilder().
             createModule("ModuleA", "3.0.0").
             createPackage(PACKAGE_A);
-         clA = createClassPool("A", builderA, JAR_A_1);
+         clA = createClassPool(resultA, "A", builderA, JAR_A_1);
          CtClass classA = assertLoadCtClass(CLASS_A, clA);
          assertCannotLoadCtClass(clA, CLASS_B);
          Result resultB = new Result();
@@ -186,6 +186,7 @@
       {
          unregisterClassPool(clA);
       }
+      assertNoClassLoader(resultA);
    }
    
    //These are my extra tests

Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolDelegatingTestSuite.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolDelegatingTestSuite.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolDelegatingTestSuite.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -47,7 +47,8 @@
       suite.addTest(ClassPoolWithReExportModuleTestCase.suite());
       suite.addTest(ClassPoolWithReExportPackageTestCase.suite());
       suite.addTest(ClassPoolWithUsesPackageTestCase.suite());
-
+      suite.addTest(ClassPoolWithHierarchicalDomainTestCase.suite());
+      suite.addTest(ClassPoolWithHierarchicalParentLoaderTestCase.suite());
       return suite;
    }
 

Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolSanityTestSuite.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolSanityTestSuite.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolSanityTestSuite.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -47,6 +47,8 @@
       suite.addTest(ClassLoaderWithReExportModuleSanityTestCase.suite());
       suite.addTest(ClassLoaderWithReExportPackageSanityTestCase.suite());
       suite.addTest(ClassLoaderWithUsesPackageSanityTestCase.suite());
+      suite.addTest(ClassLoaderWithHierarchicalDomainSanityTestCase.suite());
+      suite.addTest(ClassLoaderWithHierarchicalParentLoaderSanityTestCase.suite());
 
       return suite;
    }

Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTest.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTest.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTest.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -183,6 +183,22 @@
       return getSystem().getDefaultDomain();
    }
 
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      deploy("/org/jboss/test/aop/classpool/jbosscl/Common.xml");
+   }
+
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      undeploy("/org/jboss/test/aop/classpool/jbosscl/Common.xml");
+      super.tearDown();
+   }
+
+
    protected ClassLoader createClassLoader(String name, boolean importAll, URL... urls) throws Exception
    {
       return createClassLoader(null, name, importAll, urls);
@@ -275,10 +291,70 @@
       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);
-      return classLoader;
    }
    
    protected ClassLoader createChildURLClassLoader(ClassLoader parent, URL url)
@@ -307,9 +383,6 @@
          result.setFactory(factory);
       }
       ClassLoader loader = assertClassLoader(factory);
-      Module module = assertModule(getContextName(factory));
-      registerModule(loader, module);
-      loaderNameDeploymentRegistry.registerLoaderName(factory.getName(), loader);
 
       return loader;
    }
@@ -370,6 +443,11 @@
       }
    }
    
+   protected void assertCannotLoadClass(String className, ClassLoader cl)
+   {
+      assertCannotLoadClass(cl, className);
+   }
+   
    protected void assertCannotLoadCtClass(ClassPool pool, String className)
    {
       try
@@ -380,7 +458,12 @@
       {
       }
    }
-   
+
+   protected void assertCannotLoadCtClass(String className, ClassPool pool)
+   {
+      assertCannotLoadCtClass(pool, className);
+   }
+
    protected void assertCannotLoadClass(ClassLoaderDomain domain, String className)
    {
       try
@@ -473,7 +556,40 @@
       ClassLoader loader = createChildDomainParentLastClassLoader(result, name, domainName, parentDomainName, importAll, urls);
       return AspectManager.instance().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 AspectManager.instance().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 AspectManager.instance().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 AspectManager.instance().registerClassLoader(loader);
+   }
+
    protected ClassPool createChildURLClassPool(ClassPool parent, URL url)
    {
       ClassLoader parentLoader = null;
@@ -521,6 +637,7 @@
       assertEquals(domainForModule.getName(), module.getDomainName());
       assertEquals(domainForModule.getParentDomainName(), module.getParentDomainName());
    }
+  
    
    protected void assertNoClassLoader(Result result) throws Exception
    {
@@ -530,6 +647,15 @@
       }
       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
    {
@@ -618,15 +744,16 @@
 
    protected ClassLoader assertClassLoader(TestVFSClassLoaderFactory factory) throws Exception
    {
-      return assertClassLoader(getContextName(factory));
-   }
-   
-   protected ClassLoader assertClassLoader(String name) throws Exception
-   {
       try
       {
-         Object obj = getBean(name);
-         return assertInstanceOf(obj, ClassLoader.class);
+         Object obj = getBean(getContextName(factory));
+         ClassLoader loader = assertInstanceOf(obj, ClassLoader.class);
+         
+         Module module = assertModule(getContextName(factory));
+         registerModule(loader, module);
+         loaderNameDeploymentRegistry.registerLoaderName(factory.getName(), loader);
+         
+         return loader;
       }
       catch (IllegalStateException e)
       {
@@ -634,6 +761,12 @@
       }
    }
    
+   protected ClassPool assertClassPool(TestVFSClassLoaderFactory factory) throws Exception
+   {
+      ClassLoader loader = assertClassLoader(factory);
+      return AspectManager.instance().registerClassLoader(loader);
+   }
+   
    protected Class<?> assertLoadClass(String name, ClassLoader initiating) throws Exception
    {
       return assertLoadClass(name, initiating, initiating);

Modified: projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java
===================================================================
--- projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java	2009-01-08 20:16:44 UTC (rev 82711)
+++ projects/aop/trunk/asintegration-mc/src/tests/org/jboss/test/aop/classpool/jbosscl/test/JBossClClassPoolTestDelegate.java	2009-01-08 22:17:38 UTC (rev 82712)
@@ -21,8 +21,6 @@
 */ 
 package org.jboss.test.aop.classpool.jbosscl.test;
 
-import java.net.URL;
-
 import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
 
 /**
@@ -37,15 +35,4 @@
    {
       super(clazz);
    }
-   
-   protected void deploy() throws Exception
-   {
-      String common = "/org/jboss/test/aop/classpool/jbosscl/Common.xml";
-      URL url = getClass().getResource(common);
-      if (url == null)
-         throw new IllegalStateException(common + " not found");
-      deploy(url);
-
-      super.deploy();
-   }
 }




More information about the jboss-cvs-commits mailing list