[jboss-cvs] JBossAS SVN: r97733 - in projects/jboss-classpool/trunk/classpool: src and 27 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Dec 11 08:36:21 EST 2009


Author: flavia.rainone at jboss.com
Date: 2009-12-11 08:36:20 -0500 (Fri, 11 Dec 2009)
New Revision: 97733

Added:
   projects/jboss-classpool/trunk/classpool/src/
   projects/jboss-classpool/trunk/classpool/src/main/
   projects/jboss-classpool/trunk/classpool/src/main/java/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/AbstractIsLocalResourcePlugin.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/AbstractParentDelegationStrategy.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/BaseClassPool.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/BaseClassPoolDomain.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassLoaderIsLocalResourcePlugin.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassLoaderIsLocalResourcePluginFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassPoolToClassPoolDomainAdaptorFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultParentDelegationStrategy.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePlugin.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePluginFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePluginFactoryRegistry.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/ParentDelegationStrategy.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/TranslatableClassLoaderIsLocalResourcePlugin.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/TranslatableClassLoaderIsLocalResourcePluginFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/URLClassLoaderIsLocalResourcePlugin.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/URLClassLoaderIsLocalResourcePluginFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/AbstractClassPoolDomain.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolDomain.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolDomainRegistry.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolToClassPoolDomainAdapter.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolToClassPoolDomainAdaptorFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/helpers/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/helpers/ClassLoaderUtils.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/AbstractJBossClassPoolFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/DelegatingClassPool.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/NonDelegatingClassPool.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/SecurityActions.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempClassPoolFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempJBossClassPool.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempJBossDelegatingClassPool.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/AbstractClassPool.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/AbstractClassPoolFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/ClassPoolRepository.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/ClassPoolRepositoryCallback.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/SecurityActions.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassLoaderFactory.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassLoaderInfo.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassPoolTestScenario.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/MicrocontainerFacade.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/SanityTestScenario.java
   projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/TestScenario.java
   projects/jboss-classpool/trunk/classpool/src/main/resources/
   projects/jboss-classpool/trunk/classpool/src/main/resources/jbossorg-eula.txt
   projects/jboss-classpool/trunk/classpool/src/test/
   projects/jboss-classpool/trunk/classpool/src/test/java/
   projects/jboss-classpool/trunk/classpool/src/test/java/org/
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/DelegatingClassPoolTestSuite.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/SupportArchives.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/SupportClasses.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/a/
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/a/A.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/b/
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/b/B.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ClassPoolTest.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ClassPoolTestDelegate.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/IsLocalResourcePluginFactoryTestCase.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ParentFirstDelegatingClassPoolTestCase.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ParentLastDelegatingClassPoolTestCase.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ScopedSiblingDelegatingClassPoolTestCase.java
   projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/SimpleDelegatingClassPoolTestCase.java
   projects/jboss-classpool/trunk/classpool/src/test/resources/
   projects/jboss-classpool/trunk/classpool/src/test/resources/log4j.xml
Log:
[JBREFLECT-75] Src dir of classpool module

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/AbstractIsLocalResourcePlugin.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/AbstractIsLocalResourcePlugin.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/AbstractIsLocalResourcePlugin.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,80 @@
+/*
+* 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.classpool.base;
+
+import java.net.URL;
+
+import org.jboss.classpool.spi.AbstractClassPool;
+
+import javassist.ClassPool;
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+abstract class AbstractIsLocalResourcePlugin implements IsLocalResourcePlugin
+{
+   private final BaseClassPool pool;
+   
+   public AbstractIsLocalResourcePlugin(BaseClassPool pool)
+   {
+      this.pool = pool;
+      initialise();
+   }
+
+   protected void initialise()
+   {
+      
+   }
+   
+   protected AbstractClassPool getPool()
+   {
+      return pool;
+   }
+   
+   /**
+    * Checks if the resource can be found in the parent classpool's loader
+    * and returns true if it either does not exist in the parent or if
+    * the parent has a different URL for the resource 
+    */
+   protected boolean isSameInParent(String classResourceName, URL foundURL)
+   {
+      ClassPool  parent = pool.getParent(); 
+      if (parent != null)
+      {
+         ClassLoader parentLoader = parent.getClassLoader();
+         URL parentURL = parentLoader.getResource(classResourceName);
+         if (parentURL == null)
+         {
+            return false;
+         }
+         if (parentURL.equals(foundURL))
+         {
+            return true;
+         }
+      }
+      
+      return false;
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/AbstractIsLocalResourcePlugin.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/AbstractParentDelegationStrategy.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/AbstractParentDelegationStrategy.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/AbstractParentDelegationStrategy.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,103 @@
+/*
+* 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.classpool.base;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.classpool.domain.AbstractClassPoolDomain;
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.domain.ClassPoolToClassPoolDomainAdaptorFactory;
+import org.jboss.classpool.plugins.DelegatingClassPool;
+import org.jboss.logging.Logger;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public abstract class AbstractParentDelegationStrategy implements ParentDelegationStrategy
+{
+   protected final Logger logger = Logger.getLogger(this.getClass().getName());
+   private ClassPoolDomain domain;
+   private ClassPoolDomain 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 AbstractClassPoolDomain == false)
+         {
+            throw new IllegalArgumentException("Parent must implement AbstractClassPoolDomain");         
+         }
+         this.parent = parent;
+      }
+      
+      if (this.parent == null)
+      {
+         throw new IllegalStateException("Parent was not set");
+      }
+   }
+   
+   protected AbstractParentDelegationStrategy(ClassPool parent, ClassPoolToClassPoolDomainAdaptorFactory adaptorFactory)
+   {
+      this.parent = adaptorFactory.createAdaptor(parent);
+   }
+   
+   protected boolean hasParent()
+   {
+      if (logger.isTraceEnabled()) logger.trace(this + " " + getDomain() + " hasParent " + parent != null);
+      return parent != null;
+   }
+   
+   protected ClassPoolDomain getDomain()
+   {
+      return domain;
+   }
+   
+   public CtClass getCachedOrCreateFromParent(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create, boolean trace)
+   {
+      return parent.getCachedOrCreate(initiatingPool, classname, resourceName, create, trace);
+   }
+   
+   public void setDomain(ClassPoolDomain domain)
+   {
+      if (domain == null)
+      {
+         throw new IllegalArgumentException("Null domain");
+      }
+      if (this.domain != null)
+      {
+         throw new IllegalArgumentException("Cannot change domain");
+      }
+      this.domain = domain;
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/AbstractParentDelegationStrategy.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/BaseClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/BaseClassPool.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/BaseClassPool.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,171 @@
+/*
+* 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.classpool.base;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.classpool.spi.AbstractClassPool;
+
+
+/**
+ * Intermediate class containing commonly needed functionality for the new classpools. I don't want to
+ * modify AbstractClassPool too much
+ *  
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class BaseClassPool extends AbstractClassPool
+{
+   private IsLocalResourcePlugin isLocalResourcePlugin;
+   
+   public BaseClassPool(ClassLoader cl, ClassPool parent, ScopedClassPoolRepository repository)
+   {
+      super(cl, parent, repository);
+      isLocalResourcePlugin = IsLocalResourcePluginFactoryRegistry.getPluginFactory(cl).create(this);
+      if (logger.isTraceEnabled()) logger.trace(this + " isLocalResourcePlugin:" + isLocalResourcePlugin);
+   }
+
+   public BaseClassPool(ClassLoader cl, ClassPool parent, ScopedClassPoolRepository repository, Class<? extends ClassPoolSearchStrategy> searchStrategy)
+   {
+      super(cl, parent, repository, searchStrategy);
+      isLocalResourcePlugin = IsLocalResourcePluginFactoryRegistry.getPluginFactory(cl).create(this);
+      if (logger.isTraceEnabled()) logger.trace(this + " isLocalResourcePlugin:" + isLocalResourcePlugin);
+   }
+   
+   
+   /**
+    * Stores the classes created in the ScopedClassPool cache.
+    */
+   @Override
+   public CtClass createCtClass(String classname, boolean useCache)
+   {
+      CtClass clazz = super.createCtClass(classname, useCache);
+      if (clazz != null)
+      {
+         lockInCache(clazz);
+      }
+      return clazz;
+   }
+
+   /**
+    * Uses the parent ClassPool, if available, to create the CtClass representing
+    * {@code classname}.
+    * 
+    * @param classname the name of the queried CtClass
+    * @param useCache  whether the ScopedClassPool cache should be used to search for the CtClass
+    * @param trace     enables tracing
+    * @return          a {@code CtClass} representing {@code classname}
+    */
+   protected CtClass createParentCtClass(String classname, boolean useCache, boolean trace)
+   {
+      if (parent == null)
+      {
+         return null;
+      }
+
+      //Make parent create class
+      if (parent instanceof BaseClassPool)
+      {
+         return ((BaseClassPool)parent).createCtClass(classname, useCache);
+      }
+      else
+      {
+         return plainParentGet(classname);
+      }
+   }
+   
+   private CtClass plainParentGet(String classname)
+   {
+      try
+      {
+         return parent.get(classname);
+      }
+      catch (NotFoundException e)
+      {
+      }
+      return null;
+   }
+
+   public ClassPool getParent()
+   {
+      return parent;
+   }
+   
+   public void setParent(ClassPool parent)
+   {
+      this.parent = parent;
+   }
+   
+   @Override
+   protected boolean isLocalClassLoaderResource(String classResourceName)
+   {
+      return isLocalResourcePlugin.isMyResource(classResourceName);
+   }
+
+   @Override
+   public final CtClass get(String classname) throws NotFoundException 
+   {
+      boolean trace = logger.isTraceEnabled();
+      if (trace) logger.trace(this + " initiating get of " + classname);
+
+      if (this.getClassLoader() == null)
+      {
+         throw new IllegalStateException("Illegal call. " + 
+         " A class cannot be retrieved from ClassPool " + this +
+         " because the corresponding ClassLoader is garbage collected");
+      }
+      try
+      {
+         CtClass clazz = super.get(classname);
+         if (trace)
+         {
+            logger.trace(this + " completed get of " + classname + " " + getClassPoolLogStringForClass(clazz));
+         }
+         return clazz;
+      }
+      catch (NotFoundException e)
+      {
+         // AutoGenerated
+         NotFoundException wrapped = new NotFoundException(e.getMessage() + " could not be found from " + this);
+         wrapped.setStackTrace(e.getStackTrace());
+         throw wrapped;
+      }
+   }
+   
+   @Override
+   public CtClass get0(String classname, boolean useCache) throws NotFoundException
+   {
+      return super.get0(classname, useCache);
+   }
+   
+   @Override
+   public void close()
+   {
+      super.close();
+
+      if (logger.isTraceEnabled()) logger.trace(this + " closing");
+   }
+
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/BaseClassPool.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/BaseClassPoolDomain.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/BaseClassPoolDomain.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/BaseClassPoolDomain.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,154 @@
+/*
+* 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.classpool.base;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.classpool.domain.AbstractClassPoolDomain;
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.helpers.ClassLoaderUtils;
+import org.jboss.classpool.plugins.DelegatingClassPool;
+
+
+import javassist.CtClass;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class BaseClassPoolDomain extends AbstractClassPoolDomain
+{
+   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;
+      parentDelegationStrategy.setDomain(this);
+      if (logger.isTraceEnabled()) logger.trace("Created " + this + " parentDelegationStrategy:" + parentDelegationStrategy);
+   }
+   
+   public synchronized void addClassPool(DelegatingClassPool pool)
+   {
+      if (!delegatingPools.contains(pool))
+      {
+         if (logger.isTraceEnabled()) logger.trace(this + " adding pool " + pool);
+         delegatingPools.add(pool);
+      }
+   }
+   
+   public synchronized void removeClassPool(DelegatingClassPool pool)
+   {
+      if (logger.isTraceEnabled()) logger.trace(this + " removing pool " + pool);
+      delegatingPools.remove(pool);
+   }
+   
+   public synchronized CtClass getCachedOrCreate(DelegatingClassPool initiatingPool, String classname, boolean create)
+   {
+      boolean trace = logger.isTraceEnabled();
+      String resourceName = ClassLoaderUtils.getResourceName(classname);
+      
+      CtClass clazz = getCachedOrCreate(initiatingPool, classname, resourceName, create, trace);
+      
+      if (clazz == null)
+      {
+         clazz = getCachedOrCreateFromPoolParent(initiatingPool, classname, create, trace);
+      }
+      return clazz;
+   }
+   
+   public CtClass getCachedOrCreate(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create, boolean trace)
+   {
+      if (trace) logger.trace(this + " looking for " + classname);
+         
+      CtClass clazz = null;
+      if (isParentBefore(classname))
+      {
+         if (trace) logger.trace(this + " checking parent first for " + classname);
+         clazz = getCachedOrCreateFromParent(initiatingPool, classname, resourceName, create, trace);
+      }
+      if (clazz == null)
+      {
+         List<DelegatingClassPool> pools = getPoolsForClassName(classname);
+         if (pools.size() > 0)
+         {
+            for (DelegatingClassPool pool : pools)
+            {
+               clazz = pool.loadLocally(classname, resourceName, create);
+               if (clazz != null)
+               {
+                  break;
+               }
+            }
+         }
+      }
+      if (clazz == null && isParentAfter(classname))
+      {
+         if (trace) logger.trace(this + " checking parent last for " + classname);
+         clazz = getCachedOrCreateFromParent(initiatingPool, classname, resourceName, create, trace);
+      }
+      if (trace) logger.trace(this + " found " + classname + " in " + (clazz == null ? "null" : clazz.getClassPool()));
+      return clazz;
+   }
+
+   @Override
+   protected CtClass getCachedOrCreateFromParent(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create, boolean trace)
+   {
+      return parentDelegationStrategy.getCachedOrCreateFromParent(initiatingPool, classname, resourceName, create, trace);
+   }
+   
+   public String toString()
+   {
+      return "[" + super.toString() + " name:" + domainName + "]";
+   }
+
+   protected boolean isParentBefore(String classname)
+   {
+      return parentDelegationStrategy.isParentBefore(classname);
+   }
+   
+   protected boolean isParentAfter(String classname)
+   {
+      return parentDelegationStrategy.isParentAfter(classname);
+   }
+   
+   protected List<DelegatingClassPool> getPoolsForClassName(String classname)
+   {
+      return delegatingPools;
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/BaseClassPoolDomain.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassLoaderIsLocalResourcePlugin.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassLoaderIsLocalResourcePlugin.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassLoaderIsLocalResourcePlugin.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,43 @@
+/*
+* 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.classpool.base;
+
+
+/**
+ * 
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class DefaultClassLoaderIsLocalResourcePlugin extends AbstractIsLocalResourcePlugin implements IsLocalResourcePlugin
+{
+   public DefaultClassLoaderIsLocalResourcePlugin(BaseClassPool pool)
+   {
+      super(pool);
+   }
+
+   public boolean isMyResource(String resourceName)
+   {
+      return getPool().getClassLoader().getResource(resourceName) != null;
+   }
+
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassLoaderIsLocalResourcePlugin.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassLoaderIsLocalResourcePluginFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassLoaderIsLocalResourcePluginFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassLoaderIsLocalResourcePluginFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,38 @@
+/*
+* 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.classpool.base;
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class DefaultClassLoaderIsLocalResourcePluginFactory implements IsLocalResourcePluginFactory
+{
+
+   public IsLocalResourcePlugin create(BaseClassPool pool)
+   {
+      return new DefaultClassLoaderIsLocalResourcePlugin(pool);
+   }
+
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassLoaderIsLocalResourcePluginFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassPoolToClassPoolDomainAdaptorFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassPoolToClassPoolDomainAdaptorFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassPoolToClassPoolDomainAdaptorFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,59 @@
+/*
+* 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.classpool.base;
+
+import javassist.ClassPool;
+
+import org.jboss.classpool.domain.ClassPoolToClassPoolDomainAdapter;
+import org.jboss.classpool.domain.ClassPoolToClassPoolDomainAdaptorFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+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();
+   }
+   
+   public ClassPoolToClassPoolDomainAdapter createAdaptor(ClassPool classPool)
+   {
+      return new ClassPoolToClassPoolDomainAdapter(classPool);
+   }
+
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultClassPoolToClassPoolDomainAdaptorFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultParentDelegationStrategy.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultParentDelegationStrategy.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultParentDelegationStrategy.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,54 @@
+/*
+* 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.classpool.base;
+
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.domain.ClassPoolToClassPoolDomainAdaptorFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+class DefaultParentDelegationStrategy extends AbstractParentDelegationStrategy
+{
+   boolean parentFirst;
+   DefaultParentDelegationStrategy(ClassPoolDomain parent, boolean parentFirst, ClassPoolToClassPoolDomainAdaptorFactory adaptorFactory)
+   {
+      super(parent, adaptorFactory);
+      this.parentFirst = parentFirst;
+   }
+   
+   public boolean isParentBefore(String classname)
+   {
+      boolean isParentBefore = hasParent() && parentFirst == true;
+      if (logger.isTraceEnabled()) logger.trace(this + " " + getDomain() + " isParentBefore " + isParentBefore);
+      return isParentBefore;
+   }
+   
+   public boolean isParentAfter(String classname)
+   {
+      boolean isParentAfter = hasParent() && parentFirst == false;
+      if (logger.isTraceEnabled()) logger.trace(this + " " + getDomain() + " isParentAfter " + isParentAfter);
+      return isParentAfter;
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/DefaultParentDelegationStrategy.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePlugin.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePlugin.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePlugin.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -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.classpool.base;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public interface IsLocalResourcePlugin
+{
+   boolean isMyResource(String resourceName);
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePlugin.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePluginFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePluginFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePluginFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,34 @@
+/*
+* 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.classpool.base;
+
+
+/**
+ * Creates IsLocalResourcePlugins for a specific instance of {@link BaseClassPool}
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public interface IsLocalResourcePluginFactory
+{
+   IsLocalResourcePlugin create(BaseClassPool pool);
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePluginFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePluginFactoryRegistry.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePluginFactoryRegistry.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePluginFactoryRegistry.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,117 @@
+/*
+* 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.classpool.base;
+
+import java.net.URLClassLoader;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.jboss.util.loading.Translatable;
+
+/**
+ * A global registry for IsLocalResourcePluginFactories.
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class IsLocalResourcePluginFactoryRegistry
+{
+   private static Map<Class<?>, IsLocalResourcePluginFactory> plugins = new WeakHashMap<Class<?>, IsLocalResourcePluginFactory>();
+   
+   static
+   {
+      addPluginFactory(ClassLoader.class, new DefaultClassLoaderIsLocalResourcePluginFactory());
+      addPluginFactory(URLClassLoader.class, new URLClassLoaderIsLocalResourcePluginFactory());
+      addPluginFactory(Translatable.class, new TranslatableClassLoaderIsLocalResourcePluginFactory());
+   }
+   
+   /**
+    * Registers {@code plugin} as the factory associated with the {@code classLoaderClass}.
+    * 
+    * @param classLoaderClass the class of a specific ClassLoader
+    * @param plugin           a plugin factory that will be used for classes loaded by
+    *                         a class loader of type {@code classLoaderClass}
+    */
+   public static synchronized void addPluginFactory(Class<?> classLoaderClass, IsLocalResourcePluginFactory plugin)
+   {
+      plugins.put(classLoaderClass, plugin);
+   }
+   
+   /**
+    * Unregisters {@code plugin} as the factory associated with the {@code classLoaderClass}.
+    * 
+    * @param classLoaderClass the class of a specific ClassLoader
+    * @param plugin           a plugin factory that should no longer be used for classes loaded by
+    *                         a class loader of type {@code classLoaderClass}
+    */
+   public static synchronized void removePluginFactory(Class<?> classLoaderClass, IsLocalResourcePluginFactory plugin)
+   {
+      plugins.remove(classLoaderClass);
+   }
+
+   /**
+    * Returns the plugin factory associated with the {@code classLoader}.
+    * 
+    * @return a plugin factory that should be used for classes loaded by
+    *         {@code classLoader}
+    */
+   public static synchronized IsLocalResourcePluginFactory getPluginFactory(ClassLoader classLoader)
+   {
+      if (classLoader != null)
+      {
+         return getPluginFactory(classLoader.getClass());
+      }
+      return getPluginFactory(ClassLoader.class);
+   }
+   
+   /**
+    * Returns the plugin factory associated with the {@code classLoaderClass}.
+    * 
+    * @return a plugin factory that should be used for classes loaded by
+    *         a class loader of type {@code classLoaderClass}
+    */
+   public static synchronized IsLocalResourcePluginFactory getPluginFactory(Class<?> classLoaderClass)
+   {
+      IsLocalResourcePluginFactory plugin = plugins.get(classLoaderClass);
+      if (plugin == null)
+      {
+         Class<?>[] interfaces = classLoaderClass.getInterfaces();
+         if (interfaces.length > 0)
+         {
+            for (Class<?> iface : interfaces)
+            {
+               plugin = getPluginFactory(iface);
+               if (plugin != null)
+               {
+                  return plugin;
+               }
+            }
+         }
+         Class<?> superClass = classLoaderClass.getSuperclass();
+         if (superClass != null && superClass != Object.class)
+         {
+            return getPluginFactory(superClass);
+         }
+      }
+      return plugin;
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/IsLocalResourcePluginFactoryRegistry.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/ParentDelegationStrategy.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/ParentDelegationStrategy.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/ParentDelegationStrategy.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,44 @@
+/*
+* 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.classpool.base;
+
+
+import javassist.CtClass;
+
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.plugins.DelegatingClassPool;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+interface ParentDelegationStrategy
+{
+   void setDomain(ClassPoolDomain domain);
+   
+   CtClass getCachedOrCreateFromParent(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create, boolean trace);
+   
+   boolean isParentBefore(String classname);
+
+   boolean isParentAfter(String classname);
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/ParentDelegationStrategy.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/TranslatableClassLoaderIsLocalResourcePlugin.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/TranslatableClassLoaderIsLocalResourcePlugin.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/TranslatableClassLoaderIsLocalResourcePlugin.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,59 @@
+/*
+* 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.classpool.base;
+
+import java.net.URL;
+
+import org.jboss.util.loading.Translatable;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class TranslatableClassLoaderIsLocalResourcePlugin extends AbstractIsLocalResourcePlugin
+{
+   public TranslatableClassLoaderIsLocalResourcePlugin(BaseClassPool pool)
+   {
+      super(pool);
+   }
+
+   public boolean isMyResource(String resourceName)
+   {
+      ClassLoader loader = getPool().getClassLoader();
+      if (loader instanceof Translatable == false)
+      {
+         throw new IllegalStateException("ClassLoader of pool " + getPool() +  " is not instance of Translatable " + loader);
+      }
+      URL url = ((Translatable)getPool().getClassLoader()).getResourceLocally(resourceName);
+      if (url == null)
+      {
+         return false;
+      }
+      if (isSameInParent(resourceName, url))
+      {
+         return false;
+      }
+      return true;
+   }
+
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/TranslatableClassLoaderIsLocalResourcePlugin.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/TranslatableClassLoaderIsLocalResourcePluginFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/TranslatableClassLoaderIsLocalResourcePluginFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/TranslatableClassLoaderIsLocalResourcePluginFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,37 @@
+/*
+* 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.classpool.base;
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class TranslatableClassLoaderIsLocalResourcePluginFactory implements IsLocalResourcePluginFactory
+{
+   public IsLocalResourcePlugin create(BaseClassPool pool)
+   {
+      return new TranslatableClassLoaderIsLocalResourcePlugin(pool);
+   }
+
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/TranslatableClassLoaderIsLocalResourcePluginFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/URLClassLoaderIsLocalResourcePlugin.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/URLClassLoaderIsLocalResourcePlugin.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/URLClassLoaderIsLocalResourcePlugin.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,55 @@
+/*
+* 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.classpool.base;
+
+import java.net.URL;
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class URLClassLoaderIsLocalResourcePlugin extends AbstractIsLocalResourcePlugin 
+{
+   public URLClassLoaderIsLocalResourcePlugin(BaseClassPool pool)
+   {
+      super(pool);
+   }
+   
+   public boolean isMyResource(String classResourceName)
+   {
+      //TODO This should be moved into URLClassLoaderIsLocalResourcePlugin, and the -core tests should be updated to
+      //not use the same urls
+      ClassLoader myLoader = getPool().getClassLoader();
+      URL myURL = myLoader.getResource(classResourceName); 
+      if (myURL == null)
+      {
+         return false;
+      }
+      if (isSameInParent(classResourceName, myURL))
+      {
+         return false;
+      }
+      return true;
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/URLClassLoaderIsLocalResourcePlugin.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/URLClassLoaderIsLocalResourcePluginFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/URLClassLoaderIsLocalResourcePluginFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/URLClassLoaderIsLocalResourcePluginFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,38 @@
+/*
+* 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.classpool.base;
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class URLClassLoaderIsLocalResourcePluginFactory implements IsLocalResourcePluginFactory
+{
+
+   public IsLocalResourcePlugin create(BaseClassPool pool)
+   {
+      return new URLClassLoaderIsLocalResourcePlugin(pool);
+   }
+
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/base/URLClassLoaderIsLocalResourcePluginFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/AbstractClassPoolDomain.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/AbstractClassPoolDomain.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/AbstractClassPoolDomain.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,117 @@
+/*
+* 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.classpool.domain;
+
+import org.jboss.classpool.base.BaseClassPool;
+import org.jboss.classpool.plugins.DelegatingClassPool;
+import org.jboss.logging.Logger;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public abstract class AbstractClassPoolDomain implements ClassPoolDomain
+{
+   protected final Logger logger = Logger.getLogger(this.getClass());
+   
+   protected abstract CtClass getCachedOrCreateFromParent(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create, boolean trace);
+   
+   protected CtClass getCachedOrCreateFromPoolParent(BaseClassPool initiatingPool, String classname, boolean create, boolean trace)
+   {
+      if (initiatingPool == null)
+      {
+         if (trace) logger.trace(this + " get cached or create " + classname + " from pool parent - no initiating pool");
+         return null;
+      }
+      ClassPool parentPool = initiatingPool.getParent();
+      if (parentPool == null)
+      {
+         if (trace) logger.trace(this + " get cached or create " + classname + " from pool parent - no parent pool");
+         return null;
+      }
+       
+      return getCachedOrCreateFromPool(parentPool, classname, create, trace);
+   }
+
+   
+   protected CtClass getCachedOrCreateFromPool(ClassPool pool, String classname, boolean create, boolean trace)
+   {
+      if (pool instanceof BaseClassPool)
+      {
+         return getCachedOrCreateFromPool((BaseClassPool)pool, classname, create, trace);
+      }
+      try
+      {
+         //This will check the parents
+         if (trace) logger.trace(this + " get cached or create " + classname + " from non-BaseClassPool pool " + pool);
+         CtClass clazz = pool.get(classname);
+         if (trace) logger.trace(this + " got cached or create " + classname + " from non-BaseClassPool pool " + clazz.getClassPool());
+         return clazz;
+      }
+      catch(NotFoundException e)
+      {
+         return null;
+      }
+   }
+
+   protected CtClass getCachedOrCreateFromPool(BaseClassPool pool, String classname, boolean create, boolean trace)
+   {
+      if (pool == null)
+      {
+         if (trace) logger.trace(this + " get cached or create " + classname + " from BaseClassPool - no pool");
+         return null;
+      }
+      
+      CtClass clazz = null;
+      if (!pool.childFirstLookup)
+      {
+         if (trace) logger.trace(this + " get cached or create " + classname + " from BaseClassPool - checking parent (parentFirst)");
+         clazz = getCachedOrCreateFromPoolParent(pool, classname, create, trace); 
+      }
+      
+      if (clazz == null)
+      {
+         //We can use the exposed methods directly to avoid the overhead of NotFoundException
+         if (trace) logger.trace(this + " get cached or create " + classname + " from BaseClassPool - checking cache");
+         clazz = pool.getCached(classname);
+         if (clazz == null && create)
+         {
+            if (trace) logger.trace(this + " get cached or create " + classname + " from BaseClassPool - creating");
+            clazz = pool.createCtClass(classname, true);
+         }
+      }
+      
+      if (clazz == null && pool.childFirstLookup)
+      {
+         if (trace) logger.trace(this + " get cached or create " + classname + " from BaseClassPool - checking parent (parentLast)");
+         clazz = getCachedOrCreateFromPoolParent(pool, classname, create, trace); 
+      }
+      return clazz;
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/AbstractClassPoolDomain.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolDomain.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolDomain.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolDomain.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,40 @@
+/*
+ * 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.classpool.domain;
+
+import javassist.CtClass;
+
+import org.jboss.classpool.plugins.DelegatingClassPool;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public interface ClassPoolDomain
+{
+   public void addClassPool(DelegatingClassPool pool);
+   public void removeClassPool(DelegatingClassPool pool);
+   public CtClass getCachedOrCreate(DelegatingClassPool initiatingPool, String classname, boolean create);
+   public CtClass getCachedOrCreate(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create, boolean trace);
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolDomain.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolDomainRegistry.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolDomainRegistry.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolDomainRegistry.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,59 @@
+/*
+* 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.classpool.domain;
+
+import java.lang.ref.WeakReference;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ClassPoolDomainRegistry
+{
+   final static ClassPoolDomainRegistry INSTANCE = new ClassPoolDomainRegistry();
+   
+   final Map<Object, WeakReference<ClassPoolDomain>> domains = new WeakHashMap<Object, WeakReference<ClassPoolDomain>>();
+   
+   public static ClassPoolDomainRegistry getInstance()
+   {
+      return INSTANCE;
+   }
+   
+   public synchronized ClassPoolDomain getDomain(Object key)
+   {
+      WeakReference<ClassPoolDomain> ref = domains.get(key);
+      if (ref == null)
+      {
+         return null;
+      }
+      return ref.get();
+   }
+   
+   public synchronized void addClassPoolDomain(Object key, ClassPoolDomain domain)
+   {
+      domains.put(key, new WeakReference<ClassPoolDomain>(domain));
+   }
+   
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolDomainRegistry.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolToClassPoolDomainAdapter.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolToClassPoolDomainAdapter.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolToClassPoolDomainAdapter.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,100 @@
+/*
+* 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.classpool.domain;
+
+
+import org.jboss.classpool.plugins.DelegatingClassPool;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+
+/**
+ * Adapts a ClassPool to a ClassPoolDomain, i.e., this class represents an
+ * unitary ClassPoolDomain.
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ClassPoolToClassPoolDomainAdapter extends AbstractClassPoolDomain
+{
+   protected ClassPool pool;
+   
+   public ClassPoolToClassPoolDomainAdapter()
+   {
+      this.pool = initialiseParentClassLoader();
+      if (logger.isTraceEnabled()) logger.trace("Created " + this);
+      validate();
+   }
+   
+   public ClassPoolToClassPoolDomainAdapter(ClassPool pool)
+   {
+      this.pool = pool;
+      if (logger.isTraceEnabled()) logger.trace("Created " + this);
+      validate();
+   }
+
+   private void validate()
+   {
+      if (pool == null)
+      {
+         throw new IllegalStateException("Null parent classpool");
+      }
+   }
+   
+   // TODO JBREFLECT-65 FIXME this shouldn't be return the default classpool always
+   protected ClassPool initialiseParentClassLoader()
+   {
+      return ClassPool.getDefault();
+   }
+   
+   public void addClassPool(DelegatingClassPool pool)
+   {
+      throw new IllegalStateException("Cannot add pools to the domain adaptor");
+   }
+
+   
+   public synchronized CtClass getCachedOrCreate(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create, boolean trace)
+   {
+      return getCachedOrCreateFromPool(pool, classname, create, trace);
+   }
+
+   @Override
+   protected CtClass getCachedOrCreateFromParent(DelegatingClassPool initiatingPool, String classname, String resourceName, boolean create, boolean trace)
+   {
+      return null;
+   }
+
+   public void removeClassPool(DelegatingClassPool pool)
+   {
+      throw new IllegalStateException("Cannot remove pools from the domain adaptor");
+   }
+
+   public CtClass getCachedOrCreate(DelegatingClassPool initiatingPool, String classname, boolean create)
+   {
+      throw new IllegalStateException("Should never be called");
+   }
+
+   public String toString()
+   {
+      return "ClassPoolToDomainAdapter[" + System.identityHashCode(this) + " " + pool.toString() + "]";
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolToClassPoolDomainAdapter.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolToClassPoolDomainAdaptorFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolToClassPoolDomainAdaptorFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolToClassPoolDomainAdaptorFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -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.classpool.domain;
+
+import javassist.ClassPool;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public interface ClassPoolToClassPoolDomainAdaptorFactory
+{
+   ClassPoolToClassPoolDomainAdapter createAdaptor();
+   ClassPoolToClassPoolDomainAdapter createAdaptor(ClassPool classPool);
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/domain/ClassPoolToClassPoolDomainAdaptorFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/helpers/ClassLoaderUtils.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/helpers/ClassLoaderUtils.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/helpers/ClassLoaderUtils.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.classpool.helpers;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javassist.CtClass;
+import javassist.bytecode.Descriptor;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ClassLoaderUtils
+{
+   private static final Set<String> primitiveNames;
+   static
+   {
+      Set<String> temp = new HashSet<String>();
+      temp.add(CtClass.booleanType.getName());
+      temp.add(CtClass.byteType.getName());
+      temp.add(CtClass.charType.getName());
+      temp.add(CtClass.doubleType.getName());
+      temp.add(CtClass.floatType.getName());
+      temp.add(CtClass.intType.getName());
+      temp.add(CtClass.longType.getName());
+      temp.add(CtClass.shortType.getName());
+      temp.add(CtClass.voidType.getName());
+      primitiveNames = Collections.unmodifiableSet(temp); 
+   }
+   
+   public static String getResourceName(String classname)
+   {
+      final String name = stripArrayFromClassName(classname);
+      final int lastIndex = name.lastIndexOf('$');
+      if (lastIndex < 0)
+      {
+         return name.replaceAll("[\\.]", "/") + ".class";
+      }
+      else
+      {
+         return name.substring(0, lastIndex).replaceAll("[\\.]", "/") + name.substring(lastIndex) + ".class";
+      }
+   }
+
+   public static String getPackageName(String classname)
+   {
+      final int last = classname.lastIndexOf('.');
+      if (last < 0)
+      {
+         return "";
+      }
+      else
+      {
+         return classname.substring(0, last);
+      }
+   }
+   
+   public static String stripArrayFromClassName(String classname)
+   {
+      if (classname.charAt(0) == '[')
+      {
+         return Descriptor.toClassName(classname);
+      }
+      if (classname.endsWith("[]"))
+      {
+         return classname.substring(0, classname.indexOf("[]"));
+      }
+      return classname;
+   }
+   
+   public static boolean isPrimitiveType(String classname)
+   {
+      final String name = stripArrayFromClassName(classname);
+      return primitiveNames.contains(name);
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/helpers/ClassLoaderUtils.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/AbstractJBossClassPoolFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/AbstractJBossClassPoolFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/AbstractJBossClassPoolFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -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.classpool.plugins;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.classpool.plugins.temp.TempJBossClassPool;
+import org.jboss.classpool.spi.AbstractClassPool;
+import org.jboss.classpool.spi.AbstractClassPoolFactory;
+import org.jboss.logging.Logger;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public abstract class AbstractJBossClassPoolFactory extends AbstractClassPoolFactory
+{
+   protected final Logger log = Logger.getLogger(this.getClass().getName());
+   
+   protected ClassPool getCreateParentClassPools(final ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      //Make sure that we get classpools for all the parent classloaders
+      // TODO remove this?
+      if (cl == null)
+      {
+         return defaultClassPool;
+      }
+      ClassLoader parent = SecurityActions.getParent(cl);
+
+      if (parent != null)
+      {
+         return repository.registerClassLoader(parent);
+      }
+      else
+      {
+         return defaultClassPool;
+      }
+   }
+   
+   public AbstractClassPool create(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      return new TempJBossClassPool(src, repository);
+   }
+
+
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/AbstractJBossClassPoolFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/DelegatingClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/DelegatingClassPool.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/DelegatingClassPool.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,135 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.classpool.plugins;
+
+
+import org.jboss.classpool.base.BaseClassPool;
+import org.jboss.classpool.domain.AbstractClassPoolDomain;
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.helpers.ClassLoaderUtils;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+/**
+ * Base class for classpools backed by a domain
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class DelegatingClassPool extends BaseClassPool
+{
+   private final ClassPoolDomain domain;
+   
+   private boolean closed;
+   
+   public DelegatingClassPool(ClassPoolDomain domain, ClassLoader cl, ClassPool parent, ScopedClassPoolRepository repository)
+   {
+      super(cl, parent, repository);
+      if (domain == null)
+      {
+         throw new IllegalArgumentException("Domain was null");
+      }
+      if (domain instanceof AbstractClassPoolDomain == false)
+      {
+         throw new IllegalArgumentException("Domain must implement AbstractClassPoolDomain");
+      }
+      if (logger.isTraceEnabled()) logger.trace(this + " domain:" + this);
+      this.domain = domain;
+      this.domain.addClassPool(this);
+   }
+
+   public CtClass loadLocally(String classname, String resourceName, boolean create)
+   {
+      boolean trace = logger.isTraceEnabled();
+      if (trace) logger.trace(this + " attempt to load locally " + classname);
+         
+      CtClass clazz = null;
+      if (isLocalResource(resourceName, trace))
+      {
+         clazz = getCachedLocally(classname);
+         if (clazz == null && create)
+         {
+            clazz = createCtClass(classname, true);
+         }
+      }
+      if (trace) logger.trace(this + " loaded locally " + classname + " " + getClassPoolLogStringForClass(clazz));
+      return clazz;
+   }
+   
+   /**
+    * Overrides ClassPool.get0() so that we can look up classes without caching them in the initiating pool.
+    * The DelgatingClassPool + DomainClassPool handle the caching in the correct pool + handles the 
+    * parentFirst functionality
+    */
+   @Override
+   public synchronized CtClass get0(String classname, boolean useCache) throws NotFoundException
+   {
+      if (isGeneratedClass(classname))
+      {
+         return null;
+      }
+      CtClass clazz = domain.getCachedOrCreate(this, classname, true);
+      if (clazz == null)
+      {
+         //It is probably a generated proxy. The package name can be different (for example if it is
+         //a proxy for a java system class) than the package names exported by the loaders.
+         //TODO It should be possible to remove this once these have been done:
+         //https://jira.jboss.org/jira/browse/JBCL-25
+         //https://jira.jboss.org/jira/browse/JBCL-92
+         clazz = loadLocally(classname, ClassLoaderUtils.getResourceName(classname), true);
+      }
+      return clazz;
+   }
+   
+   @Override
+   public boolean isUnloadedClassLoader()
+   {
+      return closed;
+   }
+
+   @Override
+   public void close()
+   {
+      closed = true;
+      super.close();
+      domain.removeClassPool(this);
+   }
+
+   @Override
+   public CtClass getCached(String classname)
+   {
+      if (isGeneratedClass(classname))
+      {
+         return null;
+      }
+      return domain.getCachedOrCreate(this, classname, false);
+   }
+   
+   @Override
+   public String toString()
+   {
+      return "[" + super.toString() + " domain: " + domain + "]";
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/DelegatingClassPool.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/NonDelegatingClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/NonDelegatingClassPool.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/NonDelegatingClassPool.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,69 @@
+/*
+* 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.classpool.plugins;
+
+import org.jboss.classpool.base.BaseClassPool;
+import org.jboss.classpool.spi.AbstractClassPool;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+
+/**
+ * ClassPool for class loaders not backed by a repository/classloading domain
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class NonDelegatingClassPool extends BaseClassPool
+{
+   public NonDelegatingClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, boolean parentFirst)
+   {
+      super(cl, src, repository, AbstractClassPool.SEARCH_LOCAL_ONLY_STRATEGY);
+      super.childFirstLookup = !parentFirst;
+   }
+
+   @Override
+   public CtClass createCtClass(String classname, boolean useCache)
+   {
+      boolean trace = logger.isTraceEnabled();
+      CtClass clazz = null;
+      if (!childFirstLookup)
+      {
+         if (trace)logger.trace(this + " attempting to create " + classname + " in parent pool (parentFirst)");
+         clazz = createParentCtClass(classname, useCache, trace);
+      }
+      if (clazz == null && isLocalResource(getResourceName(classname), trace))
+      {
+         clazz = super.createCtClass(classname, useCache);
+      }
+      if (childFirstLookup && clazz == null)
+      {
+         if (trace)logger.trace(this + " attempting to create " + classname + " in parent pool (parentLast)");
+         clazz = createParentCtClass(classname, useCache, trace);
+      }
+      
+      if (trace)logger.trace(this + " created " + classname + " " + getClassPoolLogStringForClass(clazz));
+      return clazz;
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/NonDelegatingClassPool.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/SecurityActions.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/SecurityActions.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/SecurityActions.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,80 @@
+/*
+* 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.classpool.plugins;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+class SecurityActions
+{
+   interface GetParentAction
+   {
+      ClassLoader getParent(ClassLoader loader);
+      
+      GetParentAction NON_PRIVILEGED = new GetParentAction()
+      {
+         public ClassLoader getParent(ClassLoader loader)
+         {
+            return loader.getParent();
+         }
+      };
+      
+      GetParentAction PRIVILEGED = new GetParentAction()
+      {
+         public ClassLoader getParent(final ClassLoader loader)
+         {
+            try
+            {
+               return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>()
+               {
+                  public ClassLoader run() throws Exception
+                  {
+                     return loader.getParent();
+                  }
+               });
+            }
+            catch (PrivilegedActionException e)
+            {
+               throw new RuntimeException(e.getException());
+            }
+         }
+      };
+   }
+
+   public static ClassLoader getParent(ClassLoader loader)
+   {
+      if (System.getSecurityManager() == null)
+      {
+         return GetParentAction.NON_PRIVILEGED.getParent(loader);
+      }
+      else
+      {
+         return GetParentAction.PRIVILEGED.getParent(loader);
+      }
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempClassPoolFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempClassPoolFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempClassPoolFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,58 @@
+/*
+* 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.classpool.plugins.temp;
+
+import org.jboss.classpool.plugins.AbstractJBossClassPoolFactory;
+import org.jboss.classpool.spi.AbstractClassPool;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public abstract class TempClassPoolFactory extends AbstractJBossClassPoolFactory
+{
+   // TODO: check if this is needed
+   /*protected ClassPool getCreateParentClassPools(final ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      //Make sure that we get classpools for all the parent classloaders
+      if (cl == null)
+      {
+         return ClassPool.getDefault();
+      }
+      ClassLoader parent = SecurityActions.getParent(cl);
+
+      if (parent != null)
+      {
+         return repository.registerClassLoader(parent);
+      }
+      return src;
+   }*/
+   
+   public AbstractClassPool create(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      return new TempJBossDelegatingClassPool(src, repository);
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempClassPoolFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempJBossClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempJBossClassPool.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempJBossClassPool.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,71 @@
+/*
+* 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.classpool.plugins.temp;
+
+import org.jboss.classpool.spi.AbstractClassPool;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+
+/**
+ * The temporary classpool used by the instrumentor. It's main job is to delegate to the parent classpool
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class TempJBossClassPool extends AbstractClassPool
+{
+   boolean isParentAbstractPool;
+   public TempJBossClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      super(cl, src, repository);
+      if (src instanceof AbstractClassPool)
+      {
+         isParentAbstractPool = true;
+      }
+   }
+
+   public TempJBossClassPool(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      super(src, repository);
+      if (src instanceof AbstractClassPool)
+      {
+         isParentAbstractPool = true;
+      }
+   }
+
+   public CtClass getCached(String classname)
+   {
+      CtClass clazz = null;
+      if (isParentAbstractPool)
+      {
+         clazz = ((AbstractClassPool)parent).getCached(classname);
+      }
+      if (clazz == null)
+      {
+         clazz = super.getCached(classname);
+      }
+      return clazz;
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempJBossClassPool.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempJBossDelegatingClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempJBossDelegatingClassPool.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempJBossDelegatingClassPool.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,72 @@
+/*
+* 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.classpool.plugins.temp;
+
+import org.jboss.classpool.base.BaseClassPool;
+import org.jboss.classpool.spi.AbstractClassPool;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class TempJBossDelegatingClassPool extends AbstractClassPool
+{
+   boolean isParentPoolDelegating;
+   public TempJBossDelegatingClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      super(cl, src, repository);
+      if (src instanceof BaseClassPool)
+      {
+         isParentPoolDelegating = true;
+      }
+   }
+
+   public TempJBossDelegatingClassPool(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      super(src, repository);
+      if (src instanceof BaseClassPool)
+      {
+         isParentPoolDelegating = true;
+      }
+   }
+   @Override
+   public CtClass get0(String classname, boolean useCache) throws NotFoundException
+   {
+      CtClass clazz = null;
+      if (isParentPoolDelegating)
+      {
+         clazz = ((BaseClassPool)parent).get0(classname, useCache);
+      }
+      if (clazz == null)
+      {
+         clazz = super.get0(classname, useCache);
+      }
+      return clazz;
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/plugins/temp/TempJBossDelegatingClassPool.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/AbstractClassPool.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/AbstractClassPool.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/AbstractClassPool.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,339 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.classpool.spi;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.scopedpool.ScopedClassPool;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.classpool.helpers.ClassLoaderUtils;
+import org.jboss.logging.Logger;
+
+/**
+ * A ClassPool tailored for usage with JBoss AS.
+ * 
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class AbstractClassPool extends ScopedClassPool
+{
+   protected final Logger logger = Logger.getLogger(this.getClass());
+   
+   /** Classnames of classes that will be created - we do not want to look for these in other pools.
+    * The main use for this is when a class is created in a parent pool, and we then want to 
+    * create a class with the same name in a parent-last child pool. As part of the create process
+    * javassist.ClassPool will check if that class is frozen (which in turn will call getCached()
+    * and get0()). If the classname exists in this map, get0() and getCached() should return null;   
+    */
+   protected final ConcurrentHashMap<String, String> generatedClasses = new ConcurrentHashMap<String, String>();
+
+   protected final ConcurrentHashMap<String, Boolean> localResources = new ConcurrentHashMap<String, Boolean>();
+
+   /** Classnames of classes that have been loaded, but were not woven */
+   protected final ConcurrentHashMap<String, Boolean> loadedButNotWovenClasses = new ConcurrentHashMap<String, Boolean>();
+
+   /** Causes the AbstractClassPool.getCached() method to search all ClassPools registered in the repository */
+   public static final Class<SearchAllRegisteredLoadersSearchStrategy> SEARCH_ALL_STRATEGY = SearchAllRegisteredLoadersSearchStrategy.class;
+
+   /** Causes the AbstractClassPool.getCached() method to search only itself */
+   public static final Class<SearchLocalLoaderLoaderSearchStrategy> SEARCH_LOCAL_ONLY_STRATEGY = SearchLocalLoaderLoaderSearchStrategy.class;
+   
+   private final ClassPoolSearchStrategy searchStrategy;
+   
+   private final Map<AbstractClassPool, Boolean> children = new WeakHashMap<AbstractClassPool, Boolean>();
+   
+   static
+   {
+      ClassPool.doPruning = false;
+      ClassPool.releaseUnmodifiedClassFile = false;
+   }
+
+   public AbstractClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      this(cl, src, repository, false);
+   }
+
+   protected AbstractClassPool(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      this(null, src, repository, true);
+   }
+
+   private AbstractClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, boolean isTemp)
+   {
+      this(cl, src, repository, SEARCH_ALL_STRATEGY, isTemp);
+   }
+
+   public AbstractClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, Class<? extends ClassPoolSearchStrategy> searchStrategy)
+   {
+      this(cl, src, repository, searchStrategy, false);
+   }
+   
+   public AbstractClassPool(ClassPool src, ScopedClassPoolRepository repository, Class<? extends ClassPoolSearchStrategy> searchStrategy)
+   {
+      this(null, src, repository, searchStrategy, true);
+   }
+   
+   private AbstractClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, Class<? extends ClassPoolSearchStrategy> searchStrategy, boolean isTemp)
+   {
+      super(cl, src, repository, isTemp);
+      if (searchStrategy == SEARCH_ALL_STRATEGY)
+      {
+         this.searchStrategy = new SearchAllRegisteredLoadersSearchStrategy();
+      }
+      else if (searchStrategy == SEARCH_LOCAL_ONLY_STRATEGY)
+      {
+         this.searchStrategy = new SearchLocalLoaderLoaderSearchStrategy();
+      }
+      else
+      {
+         try
+         {
+            this.searchStrategy = searchStrategy.newInstance();
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Error instantiating search strategy class " + searchStrategy, e);
+         }
+      }
+      if (logger.isTraceEnabled()) logger.trace(this + " creating pool for loader " + cl + " searchStrategy:" + this.searchStrategy + " isTemp:" + isTemp);
+
+      registerWithParent();
+   }
+   
+   private void registerWithParent()
+   {
+      if (parent != null && parent instanceof AbstractClassPool)
+      {
+         ((AbstractClassPool)parent).children.put(this, Boolean.TRUE);
+      }
+   }
+   
+   private void unregisterWithParent()
+   {
+      if (parent != null && parent instanceof AbstractClassPool)
+      {
+         ((AbstractClassPool)parent).children.remove(this);
+      }
+   }
+   
+   public void registerGeneratedClass(String className)
+   {
+      generatedClasses.put(className, className);
+   }
+
+   public boolean isGeneratedClass(String className)
+   {
+      return generatedClasses.containsKey(className);
+   }
+   
+   public void doneGeneratingClass(String className)
+   {
+      generatedClasses.remove(className);
+   }
+
+   public void close()
+   {
+      super.close();
+      unregisterWithParent();
+      
+      for (Iterator<AbstractClassPool> childIterator = children.keySet().iterator(); childIterator.hasNext();)
+      {
+         AbstractClassPool child = childIterator.next();
+         childIterator.remove();
+         if (child.getClassLoader() != null)
+         {
+            child.close();
+         }
+      }
+   }
+
+   public CtClass getCached(String classname)
+   {
+      return searchStrategy.getCached(classname);
+   }
+
+   @Override
+   public void cacheCtClass(String classname, CtClass c, boolean dynamic)
+   {
+      boolean trace = logger.isTraceEnabled();
+      if (trace) logger.trace(this + " caching " + classname);
+      // TODO remove this true when ready
+      super.cacheCtClass(classname, c, true);
+      if (dynamic)
+      {
+         if (trace) logger.trace(this + " registering dynamic class " + classname);
+         doneGeneratingClass(classname);
+         String resourcename = getResourceName(classname);
+         localResources.put(resourcename, Boolean.TRUE);
+      }
+   }
+
+   protected boolean includeInGlobalSearch()
+   {
+      return true;
+   }
+
+   protected String getResourceName(String classname)
+   {
+      return ClassLoaderUtils.getResourceName(classname);
+   }
+
+   protected final boolean isLocalResource(String resourceName, boolean trace)
+   {
+      String classResourceName = resourceName;
+      Boolean isLocal = localResources.get(classResourceName);
+      if (isLocal != null)
+      {
+         if (trace) logger.trace(this + " " + resourceName + " is local " + isLocal);
+      
+         return isLocal.booleanValue();
+      }
+      boolean localResource = isLocalClassLoaderResource(classResourceName);
+      localResources.put(classResourceName, localResource ? Boolean.TRUE : Boolean.FALSE);
+      
+      if (trace) logger.trace(this + " " + resourceName + " is local " + localResource);
+      
+      return localResource;
+   }
+
+   protected boolean isLocalClassLoaderResource(String classResourceName)
+   {
+      return getClassLoader().getResource(classResourceName) != null;
+   }
+
+   public String toString()
+   {
+      ClassLoader cl = null;
+      try
+      {
+         cl = getClassLoader();
+      }
+      catch(IllegalStateException ignore)
+      {
+      }
+      return this.getClass().getName() + "@" + System.identityHashCode(this) + " " + super.toString() + " - dcl:" + cl;
+   }
+   
+   protected String getClassPoolLogStringForClass(CtClass clazz)
+   {
+      if (clazz == null)
+      {
+         return null;
+      }
+      if (clazz.getClassPool() == null)
+      {
+         return null;
+      }
+      return clazz.getClassPool().toString();
+   }
+   
+   /**
+    * 
+    * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+    * @version $Revision$
+    */
+   public interface ClassPoolSearchStrategy
+   {
+      CtClass getCached(String classname);
+   }
+
+   /**
+    * Contains the original AbstractClassPool.getCached()
+    * 
+    */
+   // NOTE: identical to ScopedClassPoolRepository, with two differences:
+   // 1. This method uses the shortcuts isLocalResource and getResourceName
+   // 2. This method uses the Repository.includeInGlobalSearch method
+   @SuppressWarnings("unchecked")
+   private class SearchAllRegisteredLoadersSearchStrategy implements ClassPoolSearchStrategy
+   {
+      Logger logger = Logger.getLogger(this.getClass());
+      public CtClass getCached(String classname)
+      {
+         boolean trace = logger.isTraceEnabled();
+         
+         if (trace) logger.trace(this + " " + AbstractClassPool.this + " searching all pools for " + classname);
+         
+         CtClass clazz = getCachedLocally(classname);
+         if (clazz == null && getClassLoader0() != null &&
+               !isLocalResource(getResourceName(classname), trace) &&
+               !generatedClasses.containsKey(classname))
+         {
+            Map<ClassLoader, ClassPool> registeredCLs = repository.getRegisteredCLs();
+            synchronized (registeredCLs)
+            {
+               for(ClassPool pl : registeredCLs.values())
+               {
+                  AbstractClassPool pool = (AbstractClassPool) pl;
+                  if (pool.isUnloadedClassLoader())
+                  {
+                     if (trace) logger.trace(this + " pool is unloaded " + pool);
+                     repository.unregisterClassLoader(pool.getClassLoader());
+                     continue;
+                  }
+
+                  //Do not check classpools for scoped classloaders
+                  if (!pool.includeInGlobalSearch())
+                  {
+                     if (trace) logger.trace(this + " pool is scoped " + pool);
+                     continue;
+                  }
+
+                  if (trace) logger.trace(this + " " + AbstractClassPool.this + " searching for " + classname + " in " + pool);
+                  clazz = pool.getCachedLocally(classname);
+                  if (clazz != null)
+                  {
+                     break;
+                  }
+               }
+            }
+         }
+         if (trace) logger.trace(this + " " + AbstractClassPool.this + " found " + classname + " in pool" + getClassPoolLogStringForClass(clazz));
+         return clazz;
+      }
+   }
+   
+   /**
+    * Checks only the ClassPool's cache 
+    */
+   private class SearchLocalLoaderLoaderSearchStrategy implements ClassPoolSearchStrategy
+   {
+      Logger logger = Logger.getLogger(this.getClass());
+
+      public CtClass getCached(String classname)
+      {
+         boolean trace = logger.isTraceEnabled();
+         
+         if (trace) logger.trace(this + " " + AbstractClassPool.this + " searching just this pool for " + classname);
+         CtClass clazz = getCachedLocally(classname);
+         if (trace) logger.trace(this + " " + AbstractClassPool.this + " found " + classname + " in pool" + getClassPoolLogStringForClass(clazz));
+         return clazz;
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/AbstractClassPool.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/AbstractClassPoolFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/AbstractClassPoolFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/AbstractClassPoolFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.classpool.spi;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPoolFactory;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+/**
+ * A factory that creates ClassPool instances based on a corresponding ClassLoader.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+public class AbstractClassPoolFactory implements ScopedClassPoolFactory
+{
+   protected static ClassPool defaultClassPool = ClassPool.getDefault();
+   
+   /**
+    * Determines the ClassPool that will be used to map null class loaders
+    * 
+    * @param defaultCP maps null class loaders
+    */
+   public static void setDefaultClassPool(ClassPool defaultCP)
+   {
+      defaultClassPool = defaultCP;
+   }
+   
+   public AbstractClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      return new AbstractClassPool(cl, src, repository);
+   }
+
+   public AbstractClassPool create(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      return new AbstractClassPool(src, repository);
+   }
+
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/AbstractClassPoolFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/ClassPoolRepository.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/ClassPoolRepository.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/ClassPoolRepository.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,200 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.classpool.spi;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPool;
+import javassist.scopedpool.ScopedClassPoolFactory;
+import javassist.scopedpool.ScopedClassPoolRepository;
+import javassist.scopedpool.ScopedClassPoolRepositoryImpl;
+
+
+/**
+ * Singleton classpool repository.
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ClassPoolRepository implements ScopedClassPoolRepository
+{
+   private final static ClassPoolRepository instance = new ClassPoolRepository();
+   
+   protected ScopedClassPoolRepository delegate;
+   private ClassPoolRepositoryCallback callback;
+   private Collection<ClassLoader> currentClassLoaders = new HashSet<ClassLoader>();
+   
+   /**
+    * Returns the singleton instance.
+    * 
+    * @return the singleton repository instance
+    */
+   public static ClassPoolRepository getInstance()
+   {
+      return instance;
+   }
+   
+   /**
+    * Constructor.
+    */
+   protected ClassPoolRepository()
+   {
+      this.delegate = ScopedClassPoolRepositoryImpl.getInstance();
+      //TODO: This was needed when jboss-aop.jar was deployed in the jboss/lib directory since the AspectManager bean had no chance to initialise it
+      delegate.setClassPoolFactory(new AbstractClassPoolFactory());
+   }
+   
+   /**
+    * Sets the classpool factory that should be used. This method should always
+    * be called before the repository is used.
+    */
+   public void setClassPoolFactory(ScopedClassPoolFactory factory)
+   {
+      delegate.setClassPoolFactory(factory);
+   }
+   
+   /**
+    * Returns the classpool factory.
+    */
+   public ScopedClassPoolFactory getClassPoolFactory()
+   {
+      return delegate.getClassPoolFactory();
+   }
+   
+   /**
+    * Sets a callback object for notifications on classloader registration.
+    *  
+    * @param callback the callback object
+    * @see ClassPoolRepositoryCallback
+    */
+   public void setClassPoolRepositoryCallback(ClassPoolRepositoryCallback callback)
+   {
+      this.callback = callback;
+   }
+   
+   /**
+    * Returns the callback object.
+    * @return the callback object. May be {@code null}
+    */
+   public ClassPoolRepositoryCallback getClassPoolRepositoryCallback()
+   {
+      return this.callback;
+   }
+
+   public boolean isPrune()
+   {
+      return delegate.isPrune();
+   }
+
+   public void setPrune(boolean prune)
+   {
+      delegate.setPrune(prune);
+   }
+
+   /**
+    * Creates a ClassPool corresponding to {@code classLoader}.
+    * 
+    * @param classLoader the classLoader corresponding to the created ClassPool
+    * @param parent the parent of the class pool to be created.
+    * @return the created ClassPool.
+    */
+   public ScopedClassPool createScopedClassPool(ClassLoader classLoader, ClassPool parent)
+   {
+      return delegate.createScopedClassPool(classLoader, parent);
+   }
+
+   /**
+    * Finds the ClassPool corresponding to {@code classLoader}
+    * 
+    * @param classLoader the classLoader
+    * @return the ClassPoool that corresponds to {@classLoader}
+    */
+   public ClassPool findClassPool(ClassLoader classLoader)
+   {
+      return delegate.findClassPool(classLoader);
+   }
+   
+   /**
+    * Get the registered classloaders
+    * 
+    * @return the registered classloaders
+    */
+   @SuppressWarnings("unchecked")
+   public Map<ClassLoader, ClassPool> getRegisteredCLs()
+   {
+      return delegate.getRegisteredCLs();
+   }
+
+   /**
+    * This method will check to see if a register classloader has been undeployed (as in JBoss)
+    */
+   public void clearUnregisteredClassLoaders()
+   {
+      delegate.clearUnregisteredClassLoaders();
+   }
+   
+   /**
+    * Registers {@code classLoader} and returns the corresponding {@code ClassPool}.
+    * 
+    * @param classLoader the ClassLoader to be added to this repository
+    * @return the ClassPool corresponding to {@code classLoader}
+    */
+   public synchronized ClassPool registerClassLoader(ClassLoader classLoader)
+   {
+      if (classLoader == null)
+      {
+         classLoader = SecurityActions.getContextClassLoader();
+      }
+      if (currentClassLoaders.contains(classLoader))
+      {
+         return null;
+      }
+      // TODO JBREFLECT-63 review this
+      currentClassLoaders.add(classLoader);
+      ScopedClassPool classPool = (ScopedClassPool) delegate.registerClassLoader(classLoader);
+      currentClassLoaders.remove(classLoader);
+      
+      // TODO review classPool != null check for AOP tests
+      if (classPool != null && callback != null)
+      {
+         callback.classLoaderRegistered(classLoader);
+      }
+      return classPool;
+   }
+
+   /**
+    * Unregisters {@code classLoader}.
+    * 
+    * @param classLoader the ClassLoader to be removed from this repository
+    */
+   public synchronized void unregisterClassLoader(ClassLoader classLoader)
+   {
+      delegate.unregisterClassLoader(classLoader);
+      if (callback != null)
+      {
+         callback.classLoaderUnregistered(classLoader);
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/ClassPoolRepository.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/ClassPoolRepositoryCallback.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/ClassPoolRepositoryCallback.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/ClassPoolRepositoryCallback.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.classpool.spi;
+
+
+/**
+ * ClassPoolRepository callback.
+ * 
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ * @see ClassPoolRepository#setClassPoolRepositoryCallback(ClassPoolRepositoryCallback)
+ */
+public interface ClassPoolRepositoryCallback {
+   
+   /**
+    * Notifies that {@code classLoader} has been registered to the
+    * {@code ClassPoolRepository}.
+    * 
+    * @param classLoader a newly registered ClassLoader.
+    * @see ClassPoolRepository#registerClassLoader(ClassLoader)
+    */
+   public void classLoaderRegistered(ClassLoader classLoader);
+   
+   /**
+    * Notifies that {@code classLoader} has been unregistered to the
+    * {@code ClassPoolRepository}.
+    * 
+    * @param classLoader a newly unregistered ClassLoader.
+    * @see ClassPoolRepository#unregisterClassLoader(ClassLoader)
+    */
+   public void classLoaderUnregistered(ClassLoader classLoader);
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/ClassPoolRepositoryCallback.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/SecurityActions.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/SecurityActions.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/SecurityActions.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,52 @@
+/*
+* 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.classpool.spi;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Package-protected class for performing security actions.
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+class SecurityActions
+{
+   public static class GetContextClassLoaderAction implements PrivilegedAction<ClassLoader>
+   {
+      public static GetContextClassLoaderAction INSTANCE = new GetContextClassLoaderAction();
+      
+      public ClassLoader run()
+      {
+         return Thread.currentThread().getContextClassLoader();
+      }
+   }
+
+   static ClassLoader getContextClassLoader()
+   {
+      if (System.getSecurityManager() == null)
+         return Thread.currentThread().getContextClassLoader();
+      else
+         return AccessController.doPrivileged(GetContextClassLoaderAction.INSTANCE);
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/classpool/spi/SecurityActions.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.support;
+
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import junit.framework.Assert;
+
+import org.jboss.classpool.spi.AbstractClassPool;
+import org.jboss.classpool.spi.ClassPoolRepository;
+
+/**
+ * Creates classes using ClassPools.
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ClassFactory
+{
+   public static final String PACKAGE = "org.test.classpool.proxy";
+   private static final String CLASS = "Proxy";
+   private static int counter = 0;
+   
+   public static Object create(Class<?> parent, ClassLoader loader) throws Exception
+   {
+      String packageName = parent.getPackage().getName();
+      if (!packageName.startsWith("java.") && !packageName.startsWith("sun."))
+      {
+         packageName += ".";
+      }
+      else
+      {
+         packageName = PACKAGE + ".";
+      }
+      String className = packageName + CLASS + counter++;
+      ClassPool pool = ClassPoolRepository.getInstance().getRegisteredCLs().get(loader);
+      try
+      {
+         registerGeneratedClass(pool, className);
+         CtClass ctClazz = pool.makeClass(packageName + CLASS + counter++);
+         ctClazz.setSuperclass(pool.get(parent.getName()));
+         Class<?> clazz = pool.toClass(ctClazz);
+         Assert.assertSame(loader, clazz.getClassLoader());
+         return clazz.newInstance();
+      }
+      catch(RuntimeException re)
+      {
+         unregisterGeneratedClass(pool, className);
+         throw re;
+      }
+   }
+   
+   /**
+    * Utility method to make a new class in a pool. It makes sure that the class is registered with the pool, so others can find it.
+    */
+   public static CtClass create(ClassPool pool, String name)
+   {
+      registerGeneratedClass(pool, name);
+      return pool.makeClass(name);
+   }
+   
+   /**
+    * Utility method to make a new class in a pool. It makes sure that the class is registered with the pool, so others can find it.
+    */
+   public static CtClass createNested(CtClass outer, String name, boolean isStatic) throws CannotCompileException
+   {
+      final String classname = outer.getName() + "$" + name;
+      try
+      {
+         registerGeneratedClass(outer.getClassPool(), classname);
+         CtClass inner = outer.makeNestedClass(name, true);
+         return inner;
+      }
+      catch (RuntimeException e)
+      {
+         unregisterGeneratedClass(outer.getClassPool(), classname);
+         throw e;
+      }
+   }
+   
+   private static void registerGeneratedClass(ClassPool pool, String name)
+   {
+      if (pool != null && pool instanceof AbstractClassPool)
+      {
+         ((AbstractClassPool) pool).registerGeneratedClass(name);
+      }
+   }
+   
+   private static void unregisterGeneratedClass(ClassPool pool, String name)
+   {
+      if (pool != null && pool instanceof AbstractClassPool)
+      {
+         ((AbstractClassPool) pool).doneGeneratingClass(name);
+      }
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassLoaderFactory.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassLoaderFactory.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassLoaderFactory.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.support;
+
+import java.util.Collection;
+
+
+/**
+ * Creates class loaders for {@link TestScenario}.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ * @version $Revision$
+ */
+
+public interface ClassLoaderFactory<I extends ClassLoaderInfo>
+{
+   /**
+    * Creates a class loader.
+    * 
+    * @param classLoaderInfo information necessary for the creation of the class loader
+    * @return                the created class loader
+    * @throws Exception      if an unexpected error occurs
+    */
+   public ClassLoader create(I classLoaderInfo) throws Exception;
+   
+   /**
+    * Destroys the created class loader.
+    * 
+    * @param classLoaderInfo identifies the class loader to be destroyed
+    * @throws Exception      if an unexpected error occurs
+    */
+   public void destroy(I classLoaderInfo) throws Exception;
+   
+   /**
+    * Destroys all class loaders that have been created by this factory so far.
+    */
+   public void destroyAll();
+   
+   /**
+    * Retrieves a class loader that has been previously created.
+    * 
+    * @param classLoaderInfo identifies the class loader to be retrieved
+    * @return                the class loader corresponding to {@code classLoaderInfo}
+    * @throws Exception      if an unexpected error occurs
+    */
+   public ClassLoader retrieve(I classLoaderInfo) throws Exception;
+   
+   /**
+    * Retrieves all class loaders that have been created so far.
+    * 
+    * @return  a collection with all class loaders that have been created (excluding the ones
+    *          that have been destroyed)
+    */
+   public Collection<ClassLoader> retrieveAll();
+   
+   /**
+    * Checks whether the class loader corresponding to {@code classLoaderInfo} is available
+    * (i.e. whether is has been created but is not destroyed yet).
+    * 
+    * @param classLoaderBuilder identifies the loader whose availability is going to be checked
+    * @return {@code true} only if a class loader has been created for {@code classLoaderInfo}
+    *                      and has not been destroyed
+    * @throws Exception    if an unexpected error occurs
+    */
+   public boolean isAvailable(I classLoaderInfo) throws Exception;
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassLoaderFactory.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassLoaderInfo.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassLoaderInfo.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassLoaderInfo.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.support;
+
+/**
+ * Contains information necessary for the ClassLoaderFactory that will be used to
+ * create the ClassLoaders.
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public interface ClassLoaderInfo {}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassLoaderInfo.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassPoolTestScenario.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassPoolTestScenario.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassPoolTestScenario.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,204 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.support;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+import junit.framework.Assert;
+
+import org.jboss.classpool.spi.ClassPoolRepository;
+
+/**
+ * This scenario is used by class pool test cases. All the operations performed using this
+ * scenario are executed over CtClasses and ClassPools.
+ * 
+ * @param <I> the ClassLoaderInfo that will be used to create class loaders for this scenario 
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ClassPoolTestScenario<I extends ClassLoaderInfo> extends TestScenario<CtClass, ClassPool, I>
+{
+   /** The ClassPool repository */
+   protected ClassPoolRepository repository;
+   
+   /**
+    * Constructor.
+    * 
+    * @param classLoaderFactory creates class loaders for the loader scenario.
+    * @param <I> the info that {@code classLoaderFactory} uses to create a class loader
+    */
+   public ClassPoolTestScenario(ClassLoaderFactory<I> classLoaderFactory)
+   {
+      super(classLoaderFactory);
+      repository = ClassPoolRepository.getInstance();
+   }
+   
+   @Override
+   public ClassPool getLoader(CtClass clazz)
+   {
+      return assertRegisterClassLoader(clazz.getClassPool().getClassLoader());
+   }
+   
+   @Override
+   public ClassPool getLoader(ClassLoader classLoader)
+   {
+      return assertRegisterClassLoader(classLoader);
+   }
+   
+   @Override
+   public ClassLoader getClassLoader(ClassPool classPool)
+   {
+      return classPool.getClassLoader();
+   }
+   
+   @Override
+   public CtClass loadClass(ClassPool classPool, ClassPool expectedClassPool, String className)
+      throws Exception
+   {
+      Class<?> clazz = assertLoadClass(classPool.getClassLoader(), expectedClassPool.getClassLoader(), className);
+      CtClass ctClass = assertLoadCtClass(className, classPool, expectedClassPool);
+      Assert.assertEquals(className, ctClass.getName());
+      Assert.assertEquals("Class has been loaded by the wrong class loader: " + className,
+            clazz.getClassLoader(), ctClass.getClassPool().getClassLoader());
+      return ctClass;
+   }
+   
+   @Override
+   public void cannotLoadClass(ClassPool classPool, String className)
+   {
+      try
+      {
+         classPool.getCtClass(className);
+         Assert.fail("Should not have been able to load " + className);
+      }
+      catch(NotFoundException expected){}
+   }
+   
+   @Override
+   public CtClass getMethodReturnType(CtClass clazz, String methodName) throws Exception
+   {
+      return clazz.getDeclaredMethod(methodName).getReturnType();
+   }
+   
+   /********* HELPER METHODS ***************************************************************/
+   
+   private ClassPool assertRegisterClassLoader(ClassLoader loader)
+   {
+      ClassPool classPool = repository.registerClassLoader(loader);
+      Assert.assertNotNull(classPool);
+      assertBootstrap(classPool, String.class, Class.class, ClassLoader.class, Object.class,
+            Collection.class, List.class, Map.class, URL.class);
+      return classPool;
+   }
+   
+   private void assertBootstrap(ClassPool classPool, Class<?>... classes)
+   {
+      assertSameClassPool(null, classPool, int.class, boolean.class, byte.class, short.class,
+            long.class, float.class, double.class, char.class, void.class);
+      assertSameClassPool(ClassPool.getDefault(), classPool, classes);
+      
+   }
+   
+   private void assertSameClassPool(ClassPool expectedClassPool, ClassPool classPool,
+         Class<?>... classes)
+   {
+      for (Class<?> clazz: classes)
+      {
+         CtClass ctClass = null;
+         try
+         {
+            ctClass = classPool.getCtClass(clazz.getName());
+         } catch (NotFoundException e)
+         {
+            e.printStackTrace();
+            Assert.fail(e.getMessage());
+         }
+         Assert.assertSame("Class " + clazz.getName() + " loaded by unexpected class pool ",
+               expectedClassPool, ctClass.getClassPool());
+      }
+   }
+   
+   protected CtClass assertLoadCtClass(String name, ClassPool initiating, ClassPool expected) throws Exception
+   {
+      CtClass clazz = initiating.get(name);
+      if (expected != null)
+      {
+         Assert.assertSame(expected, clazz.getClassPool());
+      }
+      //Load twice to test both create and cache
+      clazz = initiating.get(name);
+      if (expected != null)
+      {
+         Assert.assertSame(expected, clazz.getClassPool());
+      }
+      
+      assertLoadCtClassArray(name, clazz, initiating, expected);
+      
+      return clazz;
+   }
+   
+   private void assertLoadCtClassArray(String name, CtClass clazz, ClassPool initiating, ClassPool expected) throws Exception
+   {
+      assertLoadCtClassArray(name, clazz, 1, initiating, expected);
+      assertLoadCtClassArray(name, clazz, 2, initiating, expected);
+   }
+   
+   private void assertLoadCtClassArray(String name, CtClass clazz, int dimensions, ClassPool initiating, ClassPool expected) throws Exception
+   {
+      String arrayName = name;
+      for (int i = 0 ; i < dimensions ; i++)
+      {
+         arrayName = arrayName + "[]";
+      }
+      CtClass array = initiating.get(arrayName);
+      
+      if (expected != null)
+      {
+         Assert.assertSame(expected, array.getClassPool());
+      }
+      
+      Assert.assertSame(clazz.getClassPool(), array.getClassPool());
+      
+      CtClass type = array;
+      for (int i = 0 ; i < dimensions ; i++)
+      {
+         type = type.getComponentType();
+      }
+      Assert.assertSame(type, clazz);
+   }
+   
+   @Override
+   protected void preDestroy(Collection<ClassLoader> classLoaders)
+   {
+      for (ClassLoader classLoader: classLoaders)
+      {
+         repository.unregisterClassLoader(classLoader);
+      }
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/ClassPoolTestScenario.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/MicrocontainerFacade.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/MicrocontainerFacade.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/MicrocontainerFacade.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.support;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+
+/**
+ * @author <a href="mailto:flavia.rainone at jboss.org">Flavia Rainone</a>
+ *
+ * @version $Revision$
+ */
+
+public interface MicrocontainerFacade
+{
+   public void deploy(KernelDeployment deployment) throws Exception;
+   
+   public Object getBean(Object name, ControllerState state);
+   public Object getBean(Object name);
+   public <T> T assertBean(Object name, Class<T> expected);
+
+   /**
+    * @param undeploy
+    */
+   public void undeploy(KernelDeployment undeploy);
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/MicrocontainerFacade.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/SanityTestScenario.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/SanityTestScenario.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/SanityTestScenario.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.support;
+
+
+import junit.framework.Assert;
+
+/**
+ * This scenario is used by sanity tests, i.e., tests that check whether the class loaders
+ * represented by class pools actually behave as expected.
+ * 
+ * @param <I> the ClassLoaderInfo that will be used to create class loaders for this scenario
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class SanityTestScenario<I extends ClassLoaderInfo> extends TestScenario<Class<?>, ClassLoader, I>
+{
+   /**
+    * Constructor.
+    * 
+    * @param classLoaderFactory creates class loaders for the loader scenario.
+    * @param <I> the info that {@code classLoaderFactory} uses to create a class loader
+    */
+   public SanityTestScenario(ClassLoaderFactory<I> classLoaderFactory)
+   {
+      super(classLoaderFactory);
+   }
+   
+   @Override
+   public ClassLoader getLoader(Class<?> clazz)
+   {
+      return clazz.getClassLoader();
+   }
+   
+   @Override
+   public ClassLoader getLoader(ClassLoader classLoader)
+   {
+      return classLoader;
+   }
+   
+   @Override
+   public ClassLoader getClassLoader(ClassLoader loader)
+   {
+      return loader;
+   }
+   
+   @Override
+   public Class<?> loadClass(ClassLoader loader, ClassLoader expected, String className) throws Exception
+   {
+      return assertLoadClass(loader, expected, className);
+   }
+   
+   @Override
+   public void cannotLoadClass(ClassLoader classLoader, String className)
+   {
+      try
+      {
+         classLoader.loadClass(className);
+         Assert.fail("Should not have been able to load " + className);
+      }
+      catch(ClassNotFoundException expected){}
+   }
+
+   @Override
+   public Class<?> getMethodReturnType(Class<?> clazz, String methodName) throws Exception
+   {
+      return clazz.getDeclaredMethod(methodName).getReturnType();
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/SanityTestScenario.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/TestScenario.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/TestScenario.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/TestScenario.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,219 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.support;
+
+import java.util.Collection;
+
+import junit.framework.Assert;
+
+
+/**
+ * Abstracts the concept of loader (L) and classes (C).
+ * This class allows the implementation of tests that don't rely on the actual type of
+ * L and C.
+ * @param <C> represents a class
+ * @param <L> responsbile for loading a class
+ * @param <I> the ClassLoaderInfo that will be used to create class loaders for this scenario
+ * 
+ * @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ * @see SanityTestScenario
+ * @see ClassPoolTestScenario
+ */
+public abstract class TestScenario<C,L,I extends ClassLoaderInfo>
+{
+   /** The classloader factory */
+   private ClassLoaderFactory<I> classLoaderFactory;
+   
+   /**
+    * Constructor.
+    * 
+    * @param classLoaderFactory creates class loaders for the loader scenario.
+    * @param <I> the info that {@code classLoaderFactory} uses to create a class loader
+    */
+   public TestScenario(ClassLoaderFactory<I> classLoaderFactory)
+   {
+      this.classLoaderFactory = classLoaderFactory;
+   }
+   
+   /**
+    * Creates a loader.
+    * 
+    * @param classLoaderBuilder contains all the info necessary for the creation of a loader
+    * @return                   the created loader
+    * @throws Exception if an unexpected error occurs
+    */
+   public L createLoader(I classLoaderInfo) throws Exception
+   {
+      ClassLoader classLoader = classLoaderFactory.create(classLoaderInfo);
+      return getLoader(classLoader);
+   }
+   
+   /**
+    * Destroys the loader corresponding to classLoaderBuilder.
+    * This method can be invoked only after the loader has been
+    * {@link #createLoader(I) created}.
+    * 
+    * @param classLoaderInfo contains information regarding the loader to be destroyed.
+    * @throws Exception if an unexpected error occurs
+    * @see #createLoader(I)
+    */
+   public void destroyLoader(I classLoaderInfo) throws Exception
+   {
+      classLoaderFactory.destroy(classLoaderInfo);
+   }
+   
+   /**
+    * Destroy all loaders that have been created so far (except for loaders that have already
+    * been {@link #destroyLoader(I) destroyed}).
+    */
+   public void destroyLoaders()
+   {
+      preDestroy(classLoaderFactory.retrieveAll());
+      classLoaderFactory.destroyAll();
+   }
+
+   /**
+    * Returns the loader corresponding to {@code classLoaderBuilder}. This method can be
+    * invoked only after {@code #createLoader(I)}.
+    * 
+    * @param classLoaderInfo   contains all the info related to the loader to be retrieved
+    * @return                  the loader equivalent to {@code classLoaderBuilder}
+    * @throws Exception if an unexpected error occurs
+    * @see {@link #createLoader(I)}
+    */
+   public L getLoader(I classLoaderInfo) throws Exception
+   {
+      ClassLoader classLoader = classLoaderFactory.retrieve(classLoaderInfo);
+      return getLoader(classLoader);
+   }
+   
+   /**
+    * Checks that the loader corresponding to {@code classLoaderBuilder} is no longer
+    * available on the test scenario.
+    * 
+    * @param classLoaderInfo identifies the loader that is going to be verified
+    * @throws Exception if an unexpected error occurs
+    */
+   public void cannotGetLoader(I classLoaderInfo) throws Exception
+   {
+      Assert.assertFalse("Class loader should not be available",
+            classLoaderFactory.isAvailable(classLoaderInfo));
+   }
+   
+   /**
+    * Returns the loader that loaded {@code clazz}.
+    * 
+    * @param clazz a class that has been previously loaded
+    * @return the loader that loaded {@code clazz}
+    */
+   public abstract L getLoader(C clazz);
+   
+   /**
+    * Returns the loader corresponding to {@code classLoader}.
+    * 
+    * @param classLoader a class loader
+    * @return the loader that represents {code classLoader}
+    */
+   public abstract L getLoader(ClassLoader classLoader);
+   
+   /**
+    * Returns the class loader corresponding to {@code loader}.
+    * 
+    * @param loader a loader
+    * @return  the class loader that is represented by loader
+    */
+   public abstract ClassLoader getClassLoader(L loader);
+   
+   /**
+    * Checks that {@code loader} can load {@code className} and returns the loaded class.
+    * Also verifies that the loader associated with the loaded class is {@code loader}.
+    * 
+    * @param loader     a loader
+    * @param className  the name of the class to be loaded
+    * @return           the class loaded by {@code loader}
+    * @throws Exception if an unexpected error occurs
+    */
+   public C loadClass(L loader, String className) throws Exception
+   {
+      return loadClass(loader, loader, className);
+   }
+   
+   /**
+    * Checks that {@code loader} can load {@code className} and returns the loaded class.
+    * Also verifies that the loader associated with the loaded class is {@code expected}.
+    * 
+    * @param initiating    the loader that will be used for loading {@code className}
+    * @param expected      the actual loader that is associated with the loaded class
+    * @param className  the name of the class to be loaded
+    * @return           the loaded class
+    * @throws Exception if an unexpected error occurs
+    */
+   public abstract C loadClass(L initiating, L expected, String className) throws Exception;
+   
+   /**
+    * Checks that {@code loader} cannot load class {@code className}.
+    * 
+    * @param loader    a loader
+    * @param className the name of the class that can't be loaded by {@code loader}
+    */
+   public abstract void cannotLoadClass(L loader, String className);
+   
+   /**
+    * Returns the return type of a method declared in {@code clazz}.
+    * 
+    * @param clazz      the class that contains the method
+    * @param methodName the name of the method
+    * @return           the return type of the method
+    * @throws Exception if an unexpected error occurs
+    */
+   public abstract C getMethodReturnType(C clazz, String methodName) throws Exception;
+   
+   /**
+    * Asserts that {@code initiating} class loader can load {@code classname}.
+    * Also verifies that the class loader associated with the loaded class is {@code expected}
+    * 
+    * @param initiating  the class loader that will be used for loading {@code className}
+    * @param expected    the actual class loader that is associated with the loaded class
+    * @param className   the name of the class to be loaded
+    * @return            the loaded class
+    * @throws Exception if an unexpected error occurs
+    */
+   protected Class<?> assertLoadClass(ClassLoader initiating, ClassLoader expected, String className) throws Exception
+   {
+      Class<?> clazz = initiating.loadClass(className);
+      if (expected != null)
+      {
+         Assert.assertSame(expected, clazz.getClassLoader());
+      }
+      return clazz;
+   }
+   
+   /**
+    * Is called prior to destroy the class loaders in {@code classLoaders} collection.
+    * 
+    * @param classLoaders the class loaders that will be destroyed
+    */
+   protected void preDestroy(Collection<ClassLoader> classLoaders)
+   {
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/java/org/jboss/test/classpool/support/TestScenario.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/main/resources/jbossorg-eula.txt
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/main/resources/jbossorg-eula.txt	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/main/resources/jbossorg-eula.txt	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,107 @@
+LICENSE AGREEMENT
+JBOSS(r)
+
+This License Agreement governs the use of the Software Packages and any updates to the Software 
+Packages, regardless of the delivery mechanism.  Each Software Package is a collective work 
+under U.S. Copyright Law.  Subject to the following terms, Red Hat, Inc. ("Red Hat") grants to 
+the user ("Client") a license to the applicable collective work(s) pursuant to the 
+GNU Lesser General Public License v. 2.1 except for the following Software Packages: 
+(a) JBoss Portal Forums and JBoss Transactions JTS, each of which is licensed pursuant to the 
+GNU General Public License v.2; 
+
+(b) JBoss Rules, which is licensed pursuant to the Apache  License v.2.0;
+
+(c) an optional download for JBoss Cache for the Berkeley DB for Java database, which is licensed under the 
+(open source) Sleepycat License (if Client does not wish to use the open source version of this database, 
+it may purchase a license from Sleepycat Software); 
+
+and (d) the BPEL extension for JBoss jBPM, which is licensed under the Common Public License v.1, 
+and, pursuant to the OASIS BPEL4WS standard, requires parties wishing to redistribute to enter various 
+royalty-free patent licenses.  
+
+Each of the foregoing licenses is available at http://www.opensource.org/licenses/index.php.
+
+1.  The Software.  "Software Packages" refer to the various software modules that are created and made available 
+for distribution by the JBoss.org open source community at http://www.jboss.org.   Each of the Software Packages 
+may be comprised of hundreds of software components.  The end user license agreement for each component is located in 
+the component's source code.  With the exception of certain image files identified in Section 2 below, 
+the license terms for the components permit Client to copy, modify, and redistribute the component, 
+in both source code and binary code forms.  This agreement does not limit Client's rights under, 
+or grant Client rights that supersede, the license terms of any particular component.
+
+2.  Intellectual Property Rights.  The Software Packages are owned by Red Hat and others and are protected under copyright 
+and other laws.  Title to the Software Packages and any component, or to any copy, modification, or merged portion shall 
+remain with the aforementioned, subject to the applicable license.  The "JBoss" trademark, "Red Hat" trademark, the 
+individual Software Package trademarks, and the "Shadowman" logo are registered trademarks of Red Hat and its affiliates 
+in the U.S. and other countries.  This agreement permits Client to distribute unmodified copies of the Software Packages 
+using the Red Hat trademarks that Red Hat has inserted in the Software Packages on the condition that Client follows Red Hat's 
+trademark guidelines for those trademarks located at http://www.redhat.com/about/corporate/trademark/.  Client must abide by 
+these trademark guidelines when distributing the Software Packages, regardless of whether the Software Packages have been modified. 
+If Client modifies the Software Packages, then Client must replace all Red Hat trademarks and logos identified at 
+http://www.jboss.com/company/logos, unless a separate agreement with Red Hat is executed or other permission granted.  
+Merely deleting the files containing the Red Hat trademarks may corrupt the Software Packages.  
+
+3.  Limited Warranty.  Except as specifically stated in this Paragraph 3 or a license for a particular 
+component, to the maximum extent permitted under applicable law, the Software Packages and the 
+components are provided and licensed "as is" without warranty of any kind, expressed or implied, 
+including the implied warranties of merchantability, non-infringement or fitness for a particular purpose.  
+Red Hat warrants that the media on which Software Packages may be furnished will be free from defects in 
+materials and manufacture under normal use for a period of 30 days from the date of delivery to Client.  
+Red Hat does not warrant that the functions contained in the Software Packages will meet Client's requirements 
+or that the operation of the Software Packages will be entirely error free or appear precisely as described 
+in the accompanying documentation. This warranty extends only to the party that purchases the Services 
+pertaining to the Software Packages from Red Hat or a Red Hat authorized distributor. 
+
+4.  Limitation of Remedies and Liability. To the maximum extent permitted by applicable law, the remedies 
+described below are accepted by Client as its only remedies.  Red Hat's entire liability, and Client's 
+exclusive remedies, shall be: If the Software media is defective, Client may return it within 30 days of 
+delivery along with a copy of Client's payment receipt and Red Hat, at its option, will replace it or 
+refund the money paid by Client for the Software.  To the maximum extent permitted by applicable law, 
+Red Hat or any Red Hat authorized dealer will not be liable to Client for any incidental or consequential 
+damages, including lost profits or lost savings arising out of the use or inability to use the Software, 
+even if Red Hat or such dealer has been advised of the possibility of such damages.  In no event shall 
+Red Hat's liability under this agreement exceed the amount that Client paid to Red Hat under this 
+Agreement during the twelve months preceding the action.
+
+5.  Export Control.  As required by U.S. law, Client represents and warrants that it: 
+(a) understands that the Software Packages are subject to export controls under the 
+U.S. Commerce Department's Export Administration Regulations ("EAR"); 
+
+(b) is not located in a prohibited destination country under the EAR or U.S. sanctions regulations 
+(currently Cuba, Iran, Iraq, Libya, North Korea, Sudan and Syria); 
+
+(c) will not export, re-export, or transfer the Software Packages to any prohibited destination, entity, 
+or individual without the necessary export license(s) or authorizations(s) from the U.S. Government; 
+
+(d) will not use or transfer the Software Packages for use in any sensitive nuclear, chemical or 
+biological weapons, or missile technology end-uses unless authorized by the U.S. Government by 
+regulation or specific license; 
+
+(e) understands and agrees that if it is in the United States and exports or transfers the Software 
+Packages to eligible end users, it will, as required by EAR Section 740.17(e), submit semi-annual 
+reports to the Commerce Department's Bureau of Industry & Security (BIS), which include the name and 
+address (including country) of each transferee; 
+
+and (f) understands that countries other than the United States may restrict the import, use, or 
+export of encryption products and that it shall be solely responsible for compliance with any such 
+import, use, or export restrictions.
+
+6.  Third Party Programs. Red Hat may distribute third party software programs with the Software Packages 
+that are not part of the Software Packages and which Client must install separately.  These third party 
+programs are subject to their own license terms.  The license terms either accompany the programs or 
+can be viewed at http://www.redhat.com/licenses/.  If Client does not agree to abide by the applicable 
+license terms for such programs, then Client may not install them.  If Client wishes to install the programs 
+on more than one system or transfer the programs to another party, then Client must contact the licensor 
+of the programs.
+
+7.  General.  If any provision of this agreement is held to be unenforceable, that shall not affect the 
+enforceability of the remaining provisions.  This License Agreement shall be governed by the laws of the 
+State of North Carolina and of the United States, without regard to any conflict of laws provisions, 
+except that the United Nations Convention on the International Sale of Goods shall not apply.
+
+Copyright 2006 Red Hat, Inc.  All rights reserved.  
+"JBoss" and the JBoss logo are registered trademarks of Red Hat, Inc.  
+All other trademarks are the property of their respective owners. 
+
+	Page 1 of 1	18 October 2006
+


Property changes on: projects/jboss-classpool/trunk/classpool/src/main/resources/jbossorg-eula.txt
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/DelegatingClassPoolTestSuite.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/DelegatingClassPoolTestSuite.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/DelegatingClassPoolTestSuite.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.classpool;
+
+import org.jboss.test.classpool.test.IsLocalResourcePluginFactoryTestCase;
+import org.jboss.test.classpool.test.ParentFirstDelegatingClassPoolTestCase;
+import org.jboss.test.classpool.test.ParentLastDelegatingClassPoolTestCase;
+import org.jboss.test.classpool.test.ScopedSiblingDelegatingClassPoolTestCase;
+import org.jboss.test.classpool.test.SimpleDelegatingClassPoolTestCase;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Test Suite for DelegatingClassPool test cases.
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class DelegatingClassPoolTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("DelegatingClassPool All Tests");
+      
+      suite.addTestSuite(IsLocalResourcePluginFactoryTestCase.class);
+      suite.addTestSuite(ParentFirstDelegatingClassPoolTestCase.class);
+      suite.addTestSuite(ParentLastDelegatingClassPoolTestCase.class);
+      suite.addTestSuite(ScopedSiblingDelegatingClassPoolTestCase.class);
+      suite.addTestSuite(SimpleDelegatingClassPoolTestCase.class);
+ 
+      return suite;
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/DelegatingClassPoolTestSuite.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/SupportArchives.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/SupportArchives.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/SupportArchives.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.support;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+
+/**
+ * Contains the name of the support archives.
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class SupportArchives
+{
+   public final static URL JAR_A_URL = getURL("a.jar");
+   public final static URL JAR_B_URL = getURL("b.jar");
+   
+   /** Returns the relative URL to the project root */
+   private static URL getURL(String relativePath)
+   {
+      try
+      {
+         URL url = SupportArchives.class.getProtectionDomain().getCodeSource().getLocation();
+         String location = url.toString();
+         int index = location.lastIndexOf("/target/") + "/target/".length();
+         location = location.substring(0, index) + "archives/";
+         
+         location = location + relativePath;
+         return new URL(location);
+      }
+      catch (MalformedURLException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/SupportArchives.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/SupportClasses.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/SupportClasses.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/SupportClasses.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.support;
+
+
+
+/**
+ * Contains the name of the support classes.
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class SupportClasses
+{
+   private static final String PACKAGE_ROOT = SupportClasses.class.getPackage().getName() + ".excluded";
+   
+   public final static String CLASS_A = PACKAGE_ROOT + ".a.A";
+   public final static String CLASS_B = PACKAGE_ROOT + ".b.B";
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/SupportClasses.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/a/A.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/a/A.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/a/A.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -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.test.classpool.support.excluded.a;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class A
+{
+
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/a/A.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/b/B.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/b/B.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/b/B.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -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.test.classpool.support.excluded.b;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class B
+{
+
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/support/excluded/b/B.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ClassPoolTest.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ClassPoolTest.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ClassPoolTest.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,123 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.classpool.test;
+
+import static org.jboss.test.classpool.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.support.SupportArchives.JAR_B_URL;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+import javassist.ClassPool;
+
+import org.jboss.classpool.base.BaseClassPoolDomain;
+import org.jboss.classpool.domain.AbstractClassPoolDomain;
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.plugins.DelegatingClassPool;
+import org.jboss.classpool.spi.ClassPoolRepository;
+import org.jboss.test.AbstractTestCaseWithSetup;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.classpool.support.SupportClasses;
+
+/**
+ * Super class of all ClassPool Tests. The tests in this package don't test any repositories or
+ * class pool factories. They have their own rules for ClassPool creation and are tailored for
+ * testing the DelegatingClassPool functionalities exclusively. In other words, these tests
+ * don't emulate real scenarios and can't be used for Sanity Test cases).
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ClassPoolTest extends AbstractTestCaseWithSetup
+{
+   //Hard references to classloaders used for pools to avoid them being garbage collected before the test finished
+   private final static List<ClassLoader> loaders = new ArrayList<ClassLoader>(); 
+   
+   public ClassPoolTest(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
+   {
+      return new ClassPoolTestDelegate(clazz);
+   }
+
+   protected static AbstractClassPoolDomain createClassPoolDomain(String name, ClassPoolDomain parent, boolean parentFirst)
+   {
+      AbstractClassPoolDomain domain = new BaseClassPoolDomain(name, parent, parentFirst);
+      return domain;
+   }
+   
+   protected static DelegatingClassPool createDelegatingClassPool(ClassPoolDomain domain, URL...urls) throws ClassNotFoundException
+   {
+      ClassLoader loader = new URLClassLoader(urls);
+      for (URL url : urls)
+      {
+         if (url == JAR_A_URL)
+         {
+            loader.loadClass(SupportClasses.CLASS_A);
+         }
+         else if (url == JAR_B_URL)
+         {
+            loader.loadClass(SupportClasses.CLASS_B);
+         }
+            
+      }
+      //Once all the classes in the loader have been loaded, it seems to clear the URLs. Work around this 
+      //by recreating the loader since we need the urls in the URLClassLoaderIsLocalResourcePlugin
+      loader = new URLClassLoader(urls);
+      //Add hard reference to loader
+      loaders.add(loader);
+      return new DelegatingClassPool(domain, loader, ClassPool.getDefault(), ClassPoolRepository.getInstance());
+   }
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      // enableTrace("org.jboss.aop.classpool");
+   }
+
+   protected void assertCannotLoadClass(ClassLoader loader, String classname)
+   {
+      try
+      {
+         loader.loadClass(classname);
+         fail("Should not have been able to load " + classname);
+      }
+      catch(ClassNotFoundException expected)
+      {
+      }
+   }
+   
+   /**
+    * The test classes should not be on the launcher classpath
+    */
+   public void testClassesNotOnClasspath()
+   {
+      assertCannotLoadClass(this.getClass().getClassLoader(), SupportClasses.CLASS_A);
+      assertCannotLoadClass(this.getClass().getClassLoader(), SupportClasses.CLASS_B);
+   }
+}


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ClassPoolTest.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ClassPoolTestDelegate.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ClassPoolTestDelegate.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ClassPoolTestDelegate.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.classpool.test;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ClassPoolTestDelegate extends AbstractTestDelegate
+{
+   public ClassPoolTestDelegate(Class<?> clazz)
+   {
+      super(clazz);
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ClassPoolTestDelegate.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/IsLocalResourcePluginFactoryTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/IsLocalResourcePluginFactoryTestCase.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/IsLocalResourcePluginFactoryTestCase.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,202 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */ 
+package org.jboss.test.classpool.test;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Collection;
+import java.util.HashSet;
+
+import javassist.ClassPool;
+import junit.framework.TestCase;
+
+import org.jboss.classpool.base.BaseClassPoolDomain;
+import org.jboss.classpool.base.DefaultClassLoaderIsLocalResourcePlugin;
+import org.jboss.classpool.base.DefaultClassLoaderIsLocalResourcePluginFactory;
+import org.jboss.classpool.base.IsLocalResourcePlugin;
+import org.jboss.classpool.base.IsLocalResourcePluginFactory;
+import org.jboss.classpool.base.IsLocalResourcePluginFactoryRegistry;
+import org.jboss.classpool.base.TranslatableClassLoaderIsLocalResourcePlugin;
+import org.jboss.classpool.base.TranslatableClassLoaderIsLocalResourcePluginFactory;
+import org.jboss.classpool.base.URLClassLoaderIsLocalResourcePlugin;
+import org.jboss.classpool.base.URLClassLoaderIsLocalResourcePluginFactory;
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.classpool.plugins.DelegatingClassPool;
+import org.jboss.classpool.spi.ClassPoolRepository;
+import org.jboss.util.loading.Translatable;
+
+/**
+ * Tests for IsLocalResourcePluginFactory implementations.
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class IsLocalResourcePluginFactoryTestCase extends TestCase
+{
+   final static ClassPoolDomain DOMAIN = new BaseClassPoolDomain("Test", null, true);
+   final static URL[] URLS;
+   static 
+   {
+      try
+      {
+         URLS = new URL[] {new URL("http://www.blah.com")};
+      }
+      catch (MalformedURLException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   private Collection<ClassLoader> createdClassLoaders = new HashSet<ClassLoader>();
+   
+   public IsLocalResourcePluginFactoryTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void tearDown() throws Exception
+   {
+      try
+      {
+         super.tearDown();
+      }
+      finally
+      {
+         createdClassLoaders.clear();
+      }
+   }
+
+   public void testDefaultClassLoader() 
+   {
+      ClassLoader classLoader = new DefaultClassLoader();
+      assertFactoryAndPlugin(classLoader, DefaultClassLoaderIsLocalResourcePluginFactory.class,
+            DefaultClassLoaderIsLocalResourcePlugin.class);
+   }
+   
+   public void testURLClassLoaderDirect()
+   {
+      ClassLoader classLoader = new URLClassLoader(URLS);
+      assertFactoryAndPlugin(classLoader, URLClassLoaderIsLocalResourcePluginFactory.class,
+            URLClassLoaderIsLocalResourcePlugin.class);
+   }
+
+   public void testURLClassLoaderSubClass()
+   {
+      ClassLoader classLoader = new URLCLassLoaderSubClass(URLS);
+      assertFactoryAndPlugin(classLoader, URLClassLoaderIsLocalResourcePluginFactory.class,
+            URLClassLoaderIsLocalResourcePlugin.class);
+   }
+
+   public void testTranslatableClassLoaderImplementation()
+   {
+      ClassLoader classLoader = new TranslatableImplementation();
+      assertFactoryAndPlugin(classLoader,
+            TranslatableClassLoaderIsLocalResourcePluginFactory.class,
+            TranslatableClassLoaderIsLocalResourcePlugin.class);
+   }
+   
+   public void testTranslatableClassLoaderImplementationAndURLClassLoaderSubClass()
+   {
+      ClassLoader classLoader = new TranslatableImplementationAndURLClassLoaderSubClass(URLS);
+      assertFactoryAndPlugin(classLoader,
+            TranslatableClassLoaderIsLocalResourcePluginFactory.class,
+            TranslatableClassLoaderIsLocalResourcePlugin.class);
+   }
+   
+   public void testTranslatable2ClassLoaderImplementationAndURLClassLoaderSubClass()
+   {
+      ClassLoader classLoader = new Translatable2ImplementationAndURLClassLoaderSubClass(URLS);
+      assertFactoryAndPlugin(classLoader,
+            TranslatableClassLoaderIsLocalResourcePluginFactory.class,
+            TranslatableClassLoaderIsLocalResourcePlugin.class);
+   }
+   
+   
+   private void assertFactoryAndPlugin(ClassLoader classLoader, Class<?> factoryClass, Class<?> pluginClass)
+   {
+      createdClassLoaders.add(classLoader);
+      DelegatingClassPool pool = new DelegatingClassPool(DOMAIN, classLoader, ClassPool.getDefault(), ClassPoolRepository.getInstance()); 
+      IsLocalResourcePluginFactory factory = IsLocalResourcePluginFactoryRegistry.getPluginFactory(pool.getClassLoader());
+      assertNotNull(factory);
+      assertEquals(factoryClass, factory.getClass());
+      IsLocalResourcePlugin plugin = factory.create(pool);
+      assertEquals(pluginClass, plugin.getClass());
+   }
+
+   static class DefaultClassLoader extends ClassLoader
+   {
+   }
+   
+   static class URLCLassLoaderSubClass extends URLClassLoader
+   {
+      public URLCLassLoaderSubClass(URL[] urls)
+      {
+         super(urls);
+      }
+      
+   }
+   
+   static class TranslatableImplementation extends ClassLoader implements Translatable
+   {
+      public URL getResourceLocally(String name)
+      {
+         return null;
+      }
+      
+   }
+   
+   static class TranslatableImplementationAndURLClassLoaderSubClass extends URLClassLoader implements Translatable
+   {
+
+      public TranslatableImplementationAndURLClassLoaderSubClass(URL[] urls)
+      {
+         super(urls);
+      }
+
+      public URL getResourceLocally(String name)
+      {
+         return null;
+      }
+      
+   }
+   
+   interface Translatable2 extends Translatable
+   {
+      
+   }
+   
+   static class Translatable2ImplementationAndURLClassLoaderSubClass extends URLClassLoader implements Translatable2
+   {
+
+      public Translatable2ImplementationAndURLClassLoaderSubClass(URL[] urls)
+      {
+         super(urls);
+      }
+
+      public URL getResourceLocally(String name)
+      {
+         return null;
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/IsLocalResourcePluginFactoryTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ParentFirstDelegatingClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ParentFirstDelegatingClassPoolTestCase.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ParentFirstDelegatingClassPoolTestCase.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,290 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.test;
+
+import static org.jboss.test.classpool.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.support.SupportClasses.CLASS_B;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+
+import org.jboss.classpool.domain.ClassPoolDomain;
+import org.jboss.test.classpool.support.ClassFactory;
+
+/**
+ * Tests ClassPools with parent first delegation.
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ParentFirstDelegatingClassPoolTestCase extends ClassPoolTest
+{
+   public ParentFirstDelegatingClassPoolTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testClassInParentOnly() throws Exception
+   {
+      ClassPoolDomain parent = createClassPoolDomain("PARENT", null, true);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_A_URL);
+      ClassPoolDomain child = createClassPoolDomain("CHILD", parent, true);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_B_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessClassInParentOnly(parentPool, childPool);
+      accessClassInParentOnly(parentPool, childPool);
+   }
+   
+   private void accessClassInParentOnly(ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = childPool.get(CLASS_A);
+      assertEquals(parentPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(parentPool, a2.getClassPool());
+      assertEquals(a1, a2);
+      
+      CtClass b = childPool.get(CLASS_B);
+      assertEquals(childPool, b.getClassPool());
+      try
+      {
+         parentPool.get(CLASS_B);
+         fail("Should not have been found");
+      }
+      catch(NotFoundException e)
+      {
+      }
+      
+      CtClass string = childPool.get(String.class.getName());
+      assertNotSame("java.lang.String should be loaded by the parent pool", childPool, string.getClassPool());
+      assertEquals(ClassPool.getDefault(), string.getClassPool());
+   }
+   
+   public void testClassInGrandParentOnly() throws Exception
+   {
+      ClassPoolDomain grandParent = createClassPoolDomain("GRANDPARENT", null, true);
+      ClassPool grandParentPool = createDelegatingClassPool(grandParent, JAR_A_URL);
+      ClassPoolDomain parent = createClassPoolDomain("PARENT", grandParent, true);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_B_URL);
+      ClassPoolDomain child = createClassPoolDomain("CHILD", parent, true);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_B_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessClassInGrandParentOnly(grandParentPool, parentPool, childPool);
+      accessClassInGrandParentOnly(grandParentPool, parentPool, childPool);
+   }
+   
+   private void accessClassInGrandParentOnly(ClassPool grandParentPool, ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = childPool.get(CLASS_A);
+      assertEquals(grandParentPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a2.getClassPool());
+      assertEquals(a1, a2);
+      
+      CtClass a3 = parentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a3.getClassPool());
+
+      assertEquals(a2, a3);
+      
+      
+      CtClass b1 = childPool.get(CLASS_B);
+      assertEquals(parentPool, b1.getClassPool());
+      CtClass b2 = childPool.get(CLASS_B);
+      assertEquals(parentPool, b2.getClassPool());
+      assertEquals(b1, b2);
+      
+      try
+      {
+         grandParentPool.get(CLASS_B);
+         fail("Should not have been found");
+      }
+      catch(NotFoundException e)
+      {
+      }
+   }
+   
+   public void testChildNotInParent() throws Exception
+   {
+      ClassPoolDomain parent = createClassPoolDomain("PARENT", null, true);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_B_URL);
+      ClassPoolDomain child = createClassPoolDomain("CHILD", parent, true);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_A_URL);
+
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildNotInParent(parentPool, childPool);
+      accessChildNotInParent(parentPool, childPool);
+   }
+   
+   private void accessChildNotInParent(ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      try
+      {
+         parentPool.get(CLASS_A);
+         fail("Should not have been found");
+      }
+      catch(NotFoundException e)
+      {
+      }
+      CtClass a = childPool.get(CLASS_A);
+      assertEquals(childPool, a.getClassPool());
+      
+   }
+   
+   public void testChildInParent() throws Exception
+   {
+      ClassPoolDomain parent = createClassPoolDomain("PARENT", null, true);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_A_URL);
+      ClassPoolDomain child = createClassPoolDomain("CHILD", parent, true);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_A_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildInParent(parentPool, childPool);
+      accessChildInParent(parentPool, childPool);
+   }
+   
+   private void accessChildInParent(ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = childPool.get(CLASS_A);
+      assertEquals(parentPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(parentPool, a2.getClassPool());
+      
+      assertSame(a1, a2);
+   }
+   
+   public void testChildInParentAndGrandParent() throws Exception
+   {
+      ClassPoolDomain grandParent = createClassPoolDomain("GRANDPARENT", null, true);
+      ClassPool grandParentPool = createDelegatingClassPool(grandParent, JAR_A_URL);
+      ClassPoolDomain parent = createClassPoolDomain("PARENT", grandParent, true);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_A_URL);
+      ClassPoolDomain child = createClassPoolDomain("CHILD", parent, true);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_B_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildInParentAndGrandParent(grandParentPool, parentPool, childPool);
+      accessChildInParentAndGrandParent(grandParentPool, parentPool, childPool);
+   }
+   
+   private void accessChildInParentAndGrandParent(ClassPool grandParentPool, ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = childPool.get(CLASS_A);
+      assertEquals(grandParentPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a2.getClassPool());
+      assertSame(a1, a2);
+
+      CtClass a3 = grandParentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a3.getClassPool());
+      assertSame(a2, a3);
+   }
+
+   public void testChildInParentAndGrandParentFromTop() throws Exception
+   {
+      ClassPoolDomain grandParent = createClassPoolDomain("GRANDPARENT", null, true);
+      ClassPool grandParentPool = createDelegatingClassPool(grandParent, JAR_A_URL);
+      ClassPoolDomain parent = createClassPoolDomain("PARENT", grandParent, true);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_A_URL);
+      ClassPoolDomain child = createClassPoolDomain("CHILD", parent, true);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_B_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildInParentAndGrandParentFromTop(grandParentPool, parentPool, childPool);
+      accessChildInParentAndGrandParentFromTop(grandParentPool, parentPool, childPool);
+   }
+   
+   private void accessChildInParentAndGrandParentFromTop(ClassPool grandParentPool, ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = grandParentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a2.getClassPool());
+      assertSame(a1, a2);
+
+      CtClass a3 = childPool.get(CLASS_A);
+      assertEquals(grandParentPool, a3.getClassPool());
+      assertSame(a2, a3);
+   }
+
+   public void testChildInGrandParent() throws Exception
+   {
+      ClassPoolDomain grandParent = createClassPoolDomain("GRANDPARENT", null, true);
+      ClassPool grandParentPool = createDelegatingClassPool(grandParent, JAR_A_URL);
+      ClassPoolDomain parent = createClassPoolDomain("PARENT", grandParent, true);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_B_URL);
+      ClassPoolDomain child = createClassPoolDomain("CHILD", parent, true);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_A_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildInGrandParent(grandParentPool, parentPool, childPool);
+      accessChildInGrandParent(grandParentPool, parentPool, childPool);
+   }
+   
+   private void accessChildInGrandParent(ClassPool grandParentPool, ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = childPool.get(CLASS_A);
+      assertEquals(grandParentPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a2.getClassPool());
+      assertSame(a1, a2);
+
+      CtClass a3 = grandParentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a3.getClassPool());
+      assertSame(a2, a3);
+   }
+   
+   public void testGenerateSameNestedClassInChildAndParent() throws Exception
+   {
+      ClassPoolDomain parent = createClassPoolDomain("PARENT", null, false);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_A_URL);
+      ClassPoolDomain child = createClassPoolDomain("CHILD", parent, true);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_A_URL);
+      CtClass parentA = parentPool.get(CLASS_A);
+      CtClass parentClazz = ClassFactory.createNested(parentA, "Test", true);
+      assertSame(parentPool, parentClazz.getClassPool());
+      Class<?> parentClass = parentClazz.toClass();
+      assertSame(parentPool.getClassLoader(), parentClass.getClassLoader());
+      Class<?> parentAClass = parentA.toClass();
+      assertSame(parentPool.getClassLoader(), parentAClass.getClassLoader());
+      
+      CtClass childA = childPool.get(CLASS_A);
+      try
+      {
+         ClassFactory.createNested(childA, "Test", true);
+      }
+      catch(Exception e)
+      {
+         
+      }
+      assertSame(parentA, childA);
+      assertSame(parentClazz, childPool.get(CLASS_A + "$Test"));
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ParentFirstDelegatingClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ParentLastDelegatingClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ParentLastDelegatingClassPoolTestCase.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ParentLastDelegatingClassPoolTestCase.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,261 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.test;
+
+
+import static org.jboss.test.classpool.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.support.SupportClasses.CLASS_A;
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.classpool.domain.AbstractClassPoolDomain;
+import org.jboss.test.classpool.support.ClassFactory;
+
+
+/**
+ * Tests ClassPools with parent first delegation.
+ *  
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ParentLastDelegatingClassPoolTestCase extends ClassPoolTest
+{
+   public ParentLastDelegatingClassPoolTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testChildInParent() throws Exception
+   {
+      AbstractClassPoolDomain parent = createClassPoolDomain("PARENT", null, false);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_A_URL);
+      AbstractClassPoolDomain child = createClassPoolDomain("CHILD", parent, false);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_A_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildInParent(parentPool, childPool);
+      accessChildInParent(parentPool, childPool);
+   }
+
+   private void accessChildInParent(ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = childPool.get(CLASS_A);
+      assertEquals(childPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(parentPool, a2.getClassPool());
+   }
+
+   public void testChildInGrandParent() throws Exception
+   {
+      AbstractClassPoolDomain grandParent = createClassPoolDomain("GRANDPARENT", null, false);
+      ClassPool grandParentPool = createDelegatingClassPool(grandParent, JAR_A_URL);
+      AbstractClassPoolDomain parent = createClassPoolDomain("PARENT", grandParent, false);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_B_URL);
+      AbstractClassPoolDomain child = createClassPoolDomain("CHILD", parent, false);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_A_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildInGrandParent(grandParentPool, parentPool, childPool);
+      accessChildInGrandParent(grandParentPool, parentPool, childPool);
+   }
+   
+   private void accessChildInGrandParent(ClassPool grandParentPool, ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = childPool.get(CLASS_A);
+      assertEquals(childPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a2.getClassPool());
+      
+      CtClass a3 = grandParentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a3.getClassPool());
+   }
+   
+   public void testChildInGrandParentFromTop() throws Exception
+   {
+      AbstractClassPoolDomain grandParent = createClassPoolDomain("GRANDPARENT", null, false);
+      ClassPool grandParentPool = createDelegatingClassPool(grandParent, JAR_A_URL);
+      AbstractClassPoolDomain parent = createClassPoolDomain("PARENT", grandParent, false);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_B_URL);
+      AbstractClassPoolDomain child = createClassPoolDomain("CHILD", parent, false);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_A_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildInGrandParentFromTop(grandParentPool, parentPool, childPool);
+      accessChildInGrandParentFromTop(grandParentPool, parentPool, childPool);
+   }
+   
+   private void accessChildInGrandParentFromTop(ClassPool grandParentPool, ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = grandParentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a1.getClassPool());
+
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a2.getClassPool());
+      
+      CtClass a3 = childPool.get(CLASS_A);
+      assertEquals(childPool, a3.getClassPool());      
+   }
+   
+   public void testChildInSibling() throws Exception
+   {
+      AbstractClassPoolDomain parent = createClassPoolDomain("PARENT", null, false);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_A_URL);
+      AbstractClassPoolDomain childA = createClassPoolDomain("CHILDA", parent, false);
+      ClassPool childPoolA = createDelegatingClassPool(childA, JAR_A_URL);
+      AbstractClassPoolDomain childB = createClassPoolDomain("CHILDB", parent, false);
+      ClassPool childPoolB = createDelegatingClassPool(childB, JAR_A_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildInSibling(parentPool, childPoolA, childPoolB);
+      accessChildInSibling(parentPool, childPoolA, childPoolB);
+   }
+   
+   private void accessChildInSibling(ClassPool parentPool, ClassPool childPoolA, ClassPool childPoolB) throws Exception
+   {
+      CtClass a1 = childPoolA.get(CLASS_A);
+      assertEquals(childPoolA, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(parentPool, a2.getClassPool());
+
+      CtClass a3 = childPoolB.get(CLASS_A);
+      assertEquals(childPoolB, a3.getClassPool());
+   }
+
+   public void testClassInParentOnly() throws Exception
+   {
+      AbstractClassPoolDomain parent = createClassPoolDomain("PARENT", null, false);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_A_URL);
+      AbstractClassPoolDomain child = createClassPoolDomain("CHILD", parent, false);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_B_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessClassInParentOnly(parentPool, childPool);
+      accessClassInParentOnly(parentPool, childPool);
+   }
+
+   private void accessClassInParentOnly(ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = childPool.get(CLASS_A);
+      assertEquals(parentPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(parentPool, a2.getClassPool());
+   }
+
+   public void testClassInGrandParentOnly() throws Exception
+   {
+      AbstractClassPoolDomain grandParent = createClassPoolDomain("GRANDPARENT", null, false);
+      ClassPool grandParentPool = createDelegatingClassPool(grandParent, JAR_A_URL);
+      AbstractClassPoolDomain parent = createClassPoolDomain("PARENT", grandParent, false);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_B_URL);
+      AbstractClassPoolDomain child = createClassPoolDomain("CHILD", parent, false);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_B_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildInGrandParentOnly(grandParentPool, parentPool, childPool);
+      accessChildInGrandParentOnly(grandParentPool, parentPool, childPool);
+   }
+   
+   private void accessChildInGrandParentOnly(ClassPool grandParentPool, ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = childPool.get(CLASS_A);
+      assertEquals(grandParentPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a2.getClassPool());
+      
+      CtClass a3 = grandParentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a3.getClassPool());
+   }
+
+   public void testClassInGrandParentOnlyFromTop() throws Exception
+   {
+      AbstractClassPoolDomain grandParent = createClassPoolDomain("GRANDPARENT", null, false);
+      ClassPool grandParentPool = createDelegatingClassPool(grandParent, JAR_A_URL);
+      AbstractClassPoolDomain parent = createClassPoolDomain("PARENT", grandParent, false);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_B_URL);
+      AbstractClassPoolDomain child = createClassPoolDomain("CHILD", parent, false);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_B_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessChildInGrandParentOnlyFromTop(grandParentPool, parentPool, childPool);
+      accessChildInGrandParentOnlyFromTop(grandParentPool, parentPool, childPool);
+   }
+   
+   private void accessChildInGrandParentOnlyFromTop(ClassPool grandParentPool, ClassPool parentPool, ClassPool childPool) throws Exception
+   {
+      CtClass a1 = grandParentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a1.getClassPool());
+      
+      CtClass a2 = parentPool.get(CLASS_A);
+      assertEquals(grandParentPool, a2.getClassPool());
+      
+      CtClass a3 = childPool.get(CLASS_A);
+      assertEquals(grandParentPool, a3.getClassPool());
+   }
+   
+   public void testGenerateSameClassInChildAndParent() throws Exception
+   {
+      AbstractClassPoolDomain parent = createClassPoolDomain("PARENT", null, false);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_A_URL);
+      AbstractClassPoolDomain child = createClassPoolDomain("CHILD", parent, false);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_A_URL);
+      CtClass parentClazz = ClassFactory.create(parentPool, "test.Test");
+      assertSame(parentClazz, parentPool.get("test.Test"));
+      assertSame(parentPool, parentClazz.getClassPool());
+      Class<?> parentClass = parentClazz.toClass();
+      assertSame(parentPool.getClassLoader(), parentClass.getClassLoader());
+      
+      CtClass childClazz = ClassFactory.create(childPool, "test.Test"); 
+      assertSame(childClazz, childPool.get("test.Test"));
+      assertSame(childPool, childClazz.getClassPool());
+      Class<?> childClass = childClazz.toClass();
+      assertSame(childPool.getClassLoader(), childClass.getClassLoader());
+   }
+
+   public void testGenerateSameNestedClassInChildAndParent() throws Exception
+   {
+      AbstractClassPoolDomain parent = createClassPoolDomain("PARENT", null, false);
+      ClassPool parentPool = createDelegatingClassPool(parent, JAR_A_URL);
+      AbstractClassPoolDomain child = createClassPoolDomain("CHILD", parent, false);
+      ClassPool childPool = createDelegatingClassPool(child, JAR_A_URL);
+      CtClass parentA = parentPool.get(CLASS_A);
+      CtClass parentClazz = ClassFactory.createNested(parentA, "Test", true);
+      assertSame(parentPool, parentClazz.getClassPool());
+      Class<?> parentClass = parentClazz.toClass();
+      assertSame(parentPool.getClassLoader(), parentClass.getClassLoader());
+      Class<?> parentAClass = parentA.toClass();
+      assertSame(parentPool.getClassLoader(), parentAClass.getClassLoader());
+      
+      CtClass childA = childPool.get(CLASS_A);
+      CtClass childClazz = ClassFactory.createNested(childA, "Test", true); 
+      assertSame(childPool, childClazz.getClassPool());
+      Class<?> childClass = childClazz.toClass();
+      assertSame(childPool.getClassLoader(), childClass.getClassLoader());
+      Class<?> childAClass = childA.toClass();
+      assertSame(childPool.getClassLoader(), childAClass.getClassLoader());
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ParentLastDelegatingClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ScopedSiblingDelegatingClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ScopedSiblingDelegatingClassPoolTestCase.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ScopedSiblingDelegatingClassPoolTestCase.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.test;
+
+import static org.jboss.test.classpool.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.support.SupportClasses.CLASS_B;
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.classpool.domain.ClassPoolDomain;
+
+/**
+ * Tests DelegatingClassPools belonging to sibling domains.
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ScopedSiblingDelegatingClassPoolTestCase extends ClassPoolTest
+{
+   public ScopedSiblingDelegatingClassPoolTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testNoVisibilityBetweenSiblings() throws Exception
+   {
+      ClassPoolDomain root = createClassPoolDomain("ROOT", null, false);
+      ClassPoolDomain domainA = createClassPoolDomain("A", root, false);
+      ClassPool poolA = createDelegatingClassPool(domainA, JAR_A_URL);
+      ClassPoolDomain domainB = createClassPoolDomain("B", root, false);
+      ClassPool poolB = createDelegatingClassPool(domainB, JAR_B_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessNoVisibilityBetweenSiblings(poolA, poolB);
+      accessNoVisibilityBetweenSiblings(poolA, poolB);
+   }
+   
+   public void accessNoVisibilityBetweenSiblings(ClassPool poolA, ClassPool poolB) throws Exception
+   {
+      CtClass a = poolA.get(CLASS_A);
+      assertEquals(poolA, a.getClassPool());
+      CtClass b = poolB.get(CLASS_B);
+      assertEquals(poolB, b.getClassPool());
+      
+      try
+      {
+         poolA.get(CLASS_B);
+         fail("Should not have found B in poolA");
+      }
+      catch (Exception e)
+      {
+      }
+      try
+      {
+         poolB.get(CLASS_A);
+         fail("Should not have found A in poolB");
+      }
+      catch (Exception e)
+      {
+      }
+   }
+   
+   public void testUsesOwnCopy() throws Exception
+   {
+      ClassPoolDomain root = createClassPoolDomain("ROOT", null, false);
+      ClassPoolDomain domainA = createClassPoolDomain("A", root, false);
+      ClassPool poolA = createDelegatingClassPool(domainA, JAR_A_URL, JAR_B_URL);
+      ClassPoolDomain domainB = createClassPoolDomain("B", root, false);
+      ClassPool poolB = createDelegatingClassPool(domainB, JAR_B_URL, JAR_A_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessUsesOwnCopy(poolA, poolB);
+      accessUsesOwnCopy(poolA, poolB);
+   }
+   
+   public void accessUsesOwnCopy(ClassPool poolA, ClassPool poolB) throws Exception
+   {
+      CtClass aa = poolA.get(CLASS_A);
+      assertEquals(poolA, aa.getClassPool());
+      CtClass ab = poolA.get(CLASS_A);
+      assertEquals(poolA, ab.getClassPool());
+      
+      CtClass ba = poolB.get(CLASS_A);
+      assertEquals(poolB, ba.getClassPool());
+      CtClass bb = poolB.get(CLASS_B);
+      assertEquals(poolB, bb.getClassPool());
+   }   
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/ScopedSiblingDelegatingClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/SimpleDelegatingClassPoolTestCase.java
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/SimpleDelegatingClassPoolTestCase.java	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/SimpleDelegatingClassPoolTestCase.java	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,148 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.classpool.test;
+
+import static org.jboss.test.classpool.support.SupportArchives.JAR_A_URL;
+import static org.jboss.test.classpool.support.SupportArchives.JAR_B_URL;
+import static org.jboss.test.classpool.support.SupportClasses.CLASS_A;
+import static org.jboss.test.classpool.support.SupportClasses.CLASS_B;
+import javassist.ClassPool;
+import javassist.CtClass;
+
+import org.jboss.classpool.domain.ClassPoolDomain;
+
+/**
+ * Basic tests for DelegatingClassPool
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class SimpleDelegatingClassPoolTestCase extends ClassPoolTest
+{
+   public SimpleDelegatingClassPoolTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testAllClassesOnePool() throws Exception
+   {
+      ClassPoolDomain domain = createClassPoolDomain("SIMPLE", null, false);
+      ClassPool pool = createDelegatingClassPool(domain, JAR_A_URL, JAR_B_URL);
+
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessAllClassesOnePool(pool);
+      accessAllClassesOnePool(pool);
+   }
+   
+   private void accessAllClassesOnePool(ClassPool pool) throws Exception
+   {
+      CtClass a = pool.get(CLASS_A);
+      CtClass b = pool.get(CLASS_B);
+      assertEquals(pool, a.getClassPool());
+      assertEquals(pool, b.getClassPool());
+      
+      CtClass string = pool.get(String.class.getName());
+      assertNotSame("java.lang.String should be loaded by the parent pool", pool, string.getClassPool());
+      assertEquals(ClassPool.getDefault(), string.getClassPool());
+   }
+   
+   public void testOnePoolPerClassLoadedByA() throws Exception
+   {
+      ClassPoolDomain domain = createClassPoolDomain("SIMPLE", null, false);
+      ClassPool poolA = createDelegatingClassPool(domain, JAR_A_URL);
+      ClassPool poolB = createDelegatingClassPool(domain, JAR_B_URL);
+      
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessOnePoolPerClassLoadedByA(poolA, poolB);
+      accessOnePoolPerClassLoadedByA(poolA, poolB);
+   }
+   
+   private  void accessOnePoolPerClassLoadedByA(ClassPool poolA, ClassPool poolB) throws Exception
+   {
+      CtClass a = poolA.get(CLASS_A);
+      CtClass b = poolA.get(CLASS_B);
+
+      assertNotSame(a.getClassPool(), b.getClassPool());
+      assertEquals(poolA, a.getClassPool());
+      assertEquals(poolB, b.getClassPool());
+   }
+   
+   public void testOnePoolPerClassLoadedByB() throws Exception
+   {
+      ClassPoolDomain domain = createClassPoolDomain("SIMPLE", null, false);
+      ClassPool poolA = createDelegatingClassPool(domain, JAR_A_URL);
+      ClassPool poolB = createDelegatingClassPool(domain, JAR_B_URL);
+
+      //The first time we access the pool it will create the classes, second time will use the cache
+      accessOnePoolPerClassLoadedByB(poolA, poolB);
+      accessOnePoolPerClassLoadedByB(poolA, poolB);
+}
+   
+   public void accessOnePoolPerClassLoadedByB(ClassPool poolA, ClassPool poolB) throws Exception
+   {
+      CtClass a = poolB.get(CLASS_A);
+      CtClass b = poolB.get(CLASS_B);
+      
+      assertNotSame(a.getClassPool(), b.getClassPool());
+      assertEquals(poolA, a.getClassPool());
+      assertEquals(poolB, b.getClassPool());
+   }
+   
+   public void testCanLoadArrrayCtClass() throws Exception
+   {
+      ClassPoolDomain domain = createClassPoolDomain("SIMPLE", null, false);
+      ClassPool poolA = createDelegatingClassPool(domain, JAR_A_URL);
+      ClassPool poolB = createDelegatingClassPool(domain, JAR_B_URL);
+      accessCanLoadCtArray(poolA, poolB);
+      accessCanLoadCtArray(poolA, poolB);
+   }
+   
+   private void accessCanLoadCtArray(ClassPool poolA, ClassPool poolB) throws Exception
+   {
+      poolA.get(String.class.getName() + "[][]");
+      CtClass a = poolA.get(CLASS_A);
+      CtClass aArray = poolA.get(CLASS_A + "[]");
+      CtClass bArray = poolA.get(CLASS_B + "[][]");
+      CtClass b = poolA.get(CLASS_B);
+      
+      CtClass byteClassA = poolA.get("byte");
+      CtClass byteClassB = poolB.get("byte");
+      assertSame(byteClassA, byteClassB);
+      assertNotSame(poolA, byteClassA.getClassPool());
+      assertNotSame(poolB, byteClassA.getClassPool());
+      CtClass intArrayClass = poolA.get("int[]");
+      CtClass intClass = poolB.get("int");
+      assertSame(intClass, intArrayClass.getComponentType());
+      assertSame(byteClassA.getClassPool(), intClass.getClassPool());
+      
+      assertTrue(aArray.isArray());
+      assertSame(a, aArray.getComponentType());
+      assertTrue(bArray.isArray());
+      assertTrue(bArray.getComponentType().isArray());
+      assertSame(b, bArray.getComponentType().getComponentType());
+      assertNotSame(aArray.getClassPool(), bArray.getClassPool());
+      assertSame(poolA, aArray.getClassPool());
+      assertSame(poolB, bArray.getClassPool());
+      assertSame(a.getClassPool(), aArray.getClassPool());
+      assertSame(b.getClassPool(), bArray.getClassPool());
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/java/org/jboss/test/classpool/test/SimpleDelegatingClassPoolTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/jboss-classpool/trunk/classpool/src/test/resources/log4j.xml
===================================================================
--- projects/jboss-classpool/trunk/classpool/src/test/resources/log4j.xml	                        (rev 0)
+++ projects/jboss-classpool/trunk/classpool/src/test/resources/log4j.xml	2009-12-11 13:36:20 UTC (rev 97733)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+        
+  <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
+    <layout class="org.apache.log4j.SimpleLayout"/>
+  </appender>
+
+  <root>
+    <priority value ="debug" />
+    <appender-ref ref="ConsoleAppender"/>
+  </root>
+
+</log4j:configuration> 


Property changes on: projects/jboss-classpool/trunk/classpool/src/test/resources/log4j.xml
___________________________________________________________________
Name: svn:executable
   + *




More information about the jboss-cvs-commits mailing list