[jboss-cvs] JBossAS SVN: r66289 - in projects/aop/trunk/asintegration/src/main/org/jboss: aop/classpool and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 19 11:34:42 EDT 2007


Author: kabir.khan at jboss.com
Date: 2007-10-19 11:34:41 -0400 (Fri, 19 Oct 2007)
New Revision: 66289

Added:
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/ExtraClassPoolFactoryParameters.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/SecurityActions.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/TempJBossClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/JBossIntegration.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBoss4Integration.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBossClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBossClassPoolFactory.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/LoaderRepositoryUrlUtil.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/RepositoryClassLoaderScopingPolicy.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/ScopedJBossClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/ScopedRepositoryClassLoaderHelper.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/SecurityActions.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/DefaultTranslator.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPoolFactory.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5Integration.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderDomainRegistry.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderScopingPolicy.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedJBoss5ClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedNewClassLoaderDomain.java
Removed:
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/DefaultTranslator.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ExtraClassPoolFactoryParameters.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPoolFactory.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5Integration.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/MetaDataClassLoaderScopingPolicy.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderDomainRegistry.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderScopingPolicy.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/RepositoryClassLoaderScopingPolicy.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedJBoss5ClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedNewClassLoaderDomain.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBoss4Integration.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassLoaderValidator.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassPoolFactory.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossIntegration.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/LoaderRepositoryUrlUtil.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/ScopedJBossClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/ScopedRepositoryClassLoaderHelper.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/SecurityActions.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/TempJBossClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ExtraClassPoolFactoryParameters.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPoolFactory.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5Integration.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderDomainInitializer.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderDomainRegistry.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderScopingPolicy.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/RepositoryClassLoaderDomainIntializer.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/RepositoryClassLoaderScopingPolicy.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedJBoss5ClassPool.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedNewClassLoaderDomain.java
Modified:
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/AbstractJBossClassPoolFactory.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AbstractAspectManager.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectDeployer.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectManagerService.java
   projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/MetaDataClassLoaderScopingPolicy.java
Log:
[JBAOP-409] Move things around towards separating into spi, jboss4 and jboss5 implementations


Modified: projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/AbstractJBossClassPoolFactory.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/AbstractJBossClassPoolFactory.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/AbstractJBossClassPoolFactory.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -25,9 +25,6 @@
 import javassist.scopedpool.ScopedClassPool;
 import javassist.scopedpool.ScopedClassPoolRepository;
 
-import org.jboss.aop.deployment.SecurityActions;
-import org.jboss.aop.deployment.TempJBossClassPool;
-
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/ExtraClassPoolFactoryParameters.java (from rev 66081, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ExtraClassPoolFactoryParameters.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/ExtraClassPoolFactoryParameters.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/ExtraClassPoolFactoryParameters.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.aop.classpool;
+
+import java.util.Map;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ExtraClassPoolFactoryParameters
+{
+   /** A map of properties that can be used to configure the classpool factories further */
+   private static ThreadLocal<Map> properties = new ThreadLocal<Map>();
+   
+   public static void pushThreadProperties(Map props)
+   {
+      properties.set(props);
+   }
+   
+   public static Map peekThreadProperties()
+   {
+      return properties.get();
+   }
+   
+   public static Map popThreadProperties()
+   {
+      Map props = properties.get();
+      properties.remove();
+      return props;
+   }
+
+}

Added: projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/SecurityActions.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/SecurityActions.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/SecurityActions.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -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.aop.classpool;
+
+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: 1.1 $
+ */
+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);
+      }
+   }
+}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/TempJBossClassPool.java (from rev 66081, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/TempJBossClassPool.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/TempJBossClassPool.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/classpool/TempJBossClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -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.aop.classpool;
+
+import org.jboss.aop.classpool.AOPClassPool;
+
+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: 1.1 $
+ */
+public class TempJBossClassPool extends AOPClassPool
+{
+   boolean isParentPoolAOP;
+   public TempJBossClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      super(cl, src, repository);
+      if (src instanceof AOPClassPool)
+      {
+         isParentPoolAOP = true;
+      }
+   }
+
+   public TempJBossClassPool(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      super(src, repository);
+      if (src instanceof AOPClassPool)
+      {
+         isParentPoolAOP = true;
+      }
+   }
+
+   public CtClass getCached(String classname)
+   {
+      CtClass clazz = null;
+      if (isParentPoolAOP)
+      {
+         clazz = ((AOPClassPool)parent).getCached(classname);
+      }
+      if (clazz == null)
+      {
+         clazz = super.getCached(classname);
+      }
+      return clazz;
+   }
+
+}

Modified: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AbstractAspectManager.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AbstractAspectManager.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AbstractAspectManager.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -38,7 +38,7 @@
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.AspectXmlLoader;
 import org.jboss.aop.deployment.AspectManagerService;
-import org.jboss.aop.deployment.JBossIntegration;
+import org.jboss.asintegration.JBossIntegration;
 import org.jboss.deployment.DeploymentInfo;
 import org.jboss.logging.Logger;
 import org.w3c.dom.Document;
@@ -654,7 +654,7 @@
 
    /**
     * @param integration
-    * @see org.jboss.aop.deployment.AspectManagerService#setJBossIntegration(org.jboss.aop.deployment.JBossIntegration)
+    * @see org.jboss.aop.deployment.AspectManagerService#setJBossIntegration(org.jboss.asintegration.JBossIntegration)
     */
    public void setJbossIntegration(JBossIntegration integration)
    {

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/DefaultTranslator.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/DefaultTranslator.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/DefaultTranslator.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,68 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.security.ProtectionDomain;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.util.loading.Translator;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class DefaultTranslator implements Translator
-{
-   AspectManager manager;
-   boolean translate;
-   
-   public DefaultTranslator(AspectManager manager)
-   {
-      this.manager = manager;
-   }
-
-   public void setTranslate(boolean translate)
-   {
-      this.translate = translate;
-   }
-   
-   public boolean getTranslate()
-   {
-      return translate;
-   }
-   
-   public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined,
-         ProtectionDomain protectionDomain, byte[] classfileBuffer) throws Exception
-   {
-      if (translate)
-      {
-         return manager.transform(loader, className, classBeingRedefined, protectionDomain, classfileBuffer);
-      }
-      return classfileBuffer;   
-   }
-
-   public void unregisterClassLoader(ClassLoader loader)
-   {
-      manager.unregisterClassLoader(loader);
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ExtraClassPoolFactoryParameters.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ExtraClassPoolFactoryParameters.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ExtraClassPoolFactoryParameters.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,53 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.util.Map;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ExtraClassPoolFactoryParameters
-{
-   /** A map of properties that can be used to configure the classpool factories further */
-   private static ThreadLocal<Map> properties = new ThreadLocal<Map>();
-   
-   public static void pushThreadProperties(Map props)
-   {
-      properties.set(props);
-   }
-   
-   public static Map peekThreadProperties()
-   {
-      return properties.get();
-   }
-   
-   public static Map popThreadProperties()
-   {
-      Map props = properties.get();
-      properties.remove();
-      return props;
-   }
-
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPool.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPool.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,246 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.security.ProtectionDomain;
-import java.util.Set;
-
-import javassist.CannotCompileException;
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.classloader.spi.base.BaseClassLoader;
-import org.jboss.mx.loading.RepositoryClassLoader;
-import org.jboss.virtual.plugins.context.memory.MemoryContextFactory;
-import org.jboss.virtual.spi.VFSContext;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class JBoss5ClassPool extends AOPClassPool
-{
-   protected URL tempURL = null;
-   // For loadClass tmpdir creation for UCL
-   protected final Object tmplock = new Object();
-   
-   protected JBoss5ClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, URL tmpURL)
-   {
-      super(cl, src, repository);
-      tempURL = tmpURL;
-   }
-
-   protected JBoss5ClassPool(ClassPool src, ScopedClassPoolRepository repository)
-   {
-      super(src, repository);
-   }
-
-   public boolean isUnloadedClassLoader()
-   {
-      if (getClassLoader() instanceof RepositoryClassLoader)
-      {
-         RepositoryClassLoader rcl = (RepositoryClassLoader) getClassLoader();
-         return rcl.getLoaderRepository() == null;
-      }
-      return false;
-   }
-
-   
-   public Class toClass(CtClass cc, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
-   {
-      lockInCache(cc);
-      final ClassLoader myloader = getClassLoader();
-      if (myloader == null || tempURL == null)
-      {
-         return super.toClass(cc, loader, domain);
-      }
-      
-      try
-      {
-         String classFileName = getResourceName(cc.getName());
-         URL outputURL = new URL(tempURL.toString() + "/" + classFileName);
-         //Write the classfile to the temporary url
-         synchronized (tmplock)
-         {
-            ByteArrayOutputStream byteout = new ByteArrayOutputStream();
-            BufferedOutputStream out = new BufferedOutputStream(byteout);
-            out.write(cc.toBytecode());
-            out.flush();
-            out.close();
-            
-            byte[] classBytes = byteout.toByteArray();
-            MemoryContextFactory factory = MemoryContextFactory.getInstance();
-            factory.putFile(outputURL, classBytes);
-
-            clearCacheOnLoaderHack(myloader);
-            
-            Class clazz = myloader.loadClass(cc.getName());
-//System.out.println("====> created " + clazz.getName() + " on " + myloader + " loaded with " + clazz.getClassLoader());
-            return clazz;
-         }
-      }
-      catch(Exception e)
-      {
-       ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName());
-       cfe.initCause(e);
-       throw cfe;
-      }
-   }
-   
-   
-   private void clearCacheOnLoaderHack(final ClassLoader loader)
-   {
-      if (loader instanceof BaseClassLoader)
-      {
-         try
-         {
-            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
-
-               public Object run() throws Exception
-               {
-                  Class clazz = loader.getClass();
-                  while (clazz != null && clazz != BaseClassLoader.class)
-                  {
-                     clazz = clazz.getSuperclass();
-                  }
-                  Field field = clazz.getDeclaredField("blackList");
-                  field.setAccessible(true);
-                  Set<String> set = (Set<String>)field.get(loader);
-                  set.clear();
-                  return null;
-               }});
-         }
-         catch (PrivilegedActionException e)
-         {
-            // AutoGenerated
-            throw new RuntimeException(e.getCause());
-         }
-      }
-   }
-   
-   public Class toClassOld(CtClass cc, ClassLoader loader, ProtectionDomain domain)
-   throws CannotCompileException
-   {
-      ClassLoader useLoader = getClassLoader() == null ? loader : getClassLoader();
-      localResources.put(getResourceName(cc.getName()), Boolean.TRUE);
-      System.out.println("===> Creating class " + cc.getName() + " on loader " + useLoader);
-      
-      if ("org.jboss.test.aop.scopedextender.Child_A2$Child_A2Advisor".equals(cc.getName()))
-      {
-         try
-         {
-            useLoader.loadClass("org.jboss.test.aop.scopedextender.Base_A1$Base_A1Advisor");
-            System.out.println("Got BaseAdvisor");
-         }
-         catch (ClassNotFoundException e)
-         {
-            System.out.println("Could not get BaseAdvisor");
-         }
-      }
-      
-      Class clazz = super.toClass(cc, useLoader, domain);
-      try
-      {
-         if ("org.jboss.test.aop.scopedextender.Base_A1$Base_A1Advisor".equals(cc.getName()))
-         {
-            Class clazz2 = useLoader.loadClass(cc.getName());
-            System.out.println("Found recently created class");
-         }
-      }
-      catch (ClassNotFoundException e)
-      {
-         System.out.println("Not found recently created class");
-      }
-      return clazz;
-//      lockInCache(cc);
-//      if (getClassLoader() == null || tempdir == null)
-//      {
-//         return super.toClass(cc, loader, domain);
-//      }
-//      Class dynClass = null;
-//      try
-//      {
-//         File classFile = null;
-//         String classFileName = getResourceName(cc.getName());
-//         // Write the clas file to the tmpdir
-//         synchronized (tmplock)
-//         {
-//            classFile = new File(tempdir, classFileName);
-//            File pkgDirs = classFile.getParentFile();
-//            pkgDirs.mkdirs();
-//            FileOutputStream stream = new FileOutputStream(classFile);
-//            stream.write(cc.toBytecode());
-//            stream.flush();
-//            stream.close();
-//            classFile.deleteOnExit();
-//         }
-//         // We have to clear Blacklist caches or the class will never
-//         // be found
-//         //((UnifiedClassLoader)dcl).clearBlacklists();
-//         // To be backward compatible
-//         RepositoryClassLoader rcl = (RepositoryClassLoader) getClassLoader();
-//         rcl.clearClassBlackList();
-//         rcl.clearResourceBlackList();
-//
-//         // Now load the class through the cl
-//         dynClass = getClassLoader().loadClass(cc.getName());
-//      }
-//      catch (Exception ex)
-//      {
-//         ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName());
-//         cfe.initCause(ex);
-//         throw cfe;
-//      }
-//
-//      return dynClass;
-   }
-
-//   protected boolean isLocalResource(String resourceName)
-//   {
-//      if (super.isLocalResource(resourceName))
-//      {
-//         return true;
-//      }
-//      
-//      File file = new File(tempdir, resourceName);
-//      if (file.exists())
-//      {
-//         return true;
-//      }
-//      
-//      return false;
-//   }
-
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPoolFactory.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPoolFactory.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPoolFactory.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,94 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.aop.deployers.temp;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.aop.classpool.AbstractJBossClassPoolFactory;
-import org.jboss.aop.deployment.JBossClassPool;
-import org.jboss.aop.deployment.JBossClassPoolFactory;
-import org.jboss.aop.deployment.ScopedJBossClassPool;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.base.BaseClassLoader;
-import org.jboss.deployers.plugins.classloading.Module;
-import org.jboss.mx.loading.RepositoryClassLoader;
-import javassist.ClassPool;
-import javassist.scopedpool.ScopedClassPool;
-import javassist.scopedpool.ScopedClassPoolFactory;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-/**
- * Comment
- *
- * @deprecated TODO JBAOP-107 Need a different version for the JBoss5 classloader 
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision: 64815 $
- **/
- at Deprecated
-public class JBoss5ClassPoolFactory extends AbstractJBossClassPoolFactory implements ScopedClassPoolFactory
-{
-   static ThreadLocal<Boolean> reentry = new ThreadLocal<Boolean>();    
-   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
-   {
-      
-      ClassPool parent = getCreateParentClassPools(cl, src, repository);
-      if (cl instanceof BaseClassLoader)
-      {
-         Map props = ExtraClassPoolFactoryParameters.peekThreadProperties();
-         Module module = (Module)props.get(Module.class);
-            
-         if (module != null && module.getParentDomain() != null)
-         {
-            //It is scoped
-            ClassLoaderSystem sys = ClassLoaderSystem.getInstance();
-            ClassLoaderDomain domain = sys.getDomain(module.getDomainName());
-            boolean parentFirst = module.getMetadata().isJ2seClassLoadingCompliance();
-            
-            return new ScopedJBoss5ClassPool(cl, parent, repository, getTempURL(module), parentFirst, domain);
-         }
-         return new JBoss5ClassPool(cl, parent, repository, getTempURL(module));
-      }
-      return new AOPClassPool(cl, parent, repository);
-   }
-   
-   private URL getTempURL(Module module)
-   {
-      try
-      {
-         URL tempUrl = module.getDynamicClassRoot();
-         return new URL(tempUrl,  "/classes");
-      }
-      catch (MalformedURLException e)
-      {
-         throw new RuntimeException(e);
-      } 
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5Integration.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5Integration.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5Integration.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,118 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.io.File;
-
-import javassist.ClassPool;
-import javassist.scopedpool.ScopedClassPool;
-import javassist.scopedpool.ScopedClassPoolFactory;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.aop.deployment.JBossIntegration;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class JBoss5Integration implements JBossIntegration, ScopedClassPoolFactory
-{
-   /** The delegate classpool factory */
-   private ScopedClassPoolFactory delegateClassPoolFactory;
-   private AOPClassLoaderScopingPolicy policy;
-   private AspectManager manager = AspectManager.getTopLevelAspectManager();
-   DefaultTranslator translator = new DefaultTranslator(manager);
-
-   NewClassLoaderDomainRegistry registry;
-   
-   public NewClassLoaderDomainRegistry getRegistry()
-   {
-      return registry;
-   }
-
-   public void setRegistry(NewClassLoaderDomainRegistry registry)
-   {
-      this.registry = registry;
-   }
-   
-   public void start()
-   {
-      ClassLoaderSystem.getInstance().setTranslator(translator);
-   }
-
-   public void stop()
-   {
-      ClassLoaderSystem.getInstance().setTranslator(null);
-   }
-   
-   public boolean isValidClassLoader(ClassLoader loader)
-   {
-      if (!(loader instanceof RepositoryClassLoader)) return false;
-      return ((RepositoryClassLoader) loader).getLoaderRepository() != null;
-   }
-
-   public void setScopingPolicy(AOPClassLoaderScopingPolicy policy)
-   {
-      this.policy = policy;
-   }
-   
-   public AOPClassLoaderScopingPolicy getScopingPolicy()
-   {
-      return policy;
-   }
-   
-   public AOPClassLoaderScopingPolicy createAOPClassLoaderScopingPolicy()
-   {
-      return policy;
-   }
-
-   public ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception
-   {
-      delegateClassPoolFactory = new JBoss5ClassPoolFactory();
-      return this;
-   }
-   
-   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
-   {
-      return delegateClassPoolFactory.create(cl, src, repository);
-   }
-
-   public ScopedClassPool create(ClassPool src, ScopedClassPoolRepository repository)
-   {
-      return delegateClassPoolFactory.create(src, repository);
-   }
-   
-   public void attachDeprecatedTranslator()
-   {
-      translator.setTranslate(true);
-   }
-
-   public void detachDeprecatedTranslator()
-   {
-      translator.setTranslate(false);
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/MetaDataClassLoaderScopingPolicy.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/MetaDataClassLoaderScopingPolicy.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/MetaDataClassLoaderScopingPolicy.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,101 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.Domain;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.metadata.spi.stack.MetaDataStack;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class MetaDataClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy
-{
-   static Logger log = Logger.getLogger(MetaDataClassLoaderScopingPolicy.class);
-   
-   //Several loaders may share the same domain
-   private Map<ClassLoader, Domain> domainsByLoader = new WeakHashMap<ClassLoader, Domain>();
-   
-   public Domain getDomain(ClassLoader classLoader, AspectManager parent)
-   {
-      //Check metadata stack for domain to use
-      MetaData metaData = MetaDataStack.peek();
-      if (metaData != null)
-      {
-         //There is metadata on the stack, so check there. No domain in this case means use the main AM
-         Domain domain = metaData.getMetaData(Domain.class);
-         if (domain != null)
-         {
-            registerDomain(classLoader, domain);
-            return domain;
-         }
-      }      
-      
-      //Check the stored domains
-      Domain domain = getRegisteredDomain(classLoader);
-      if (domain != null)
-      {
-         return domain;
-      }
-      
-      return null;
-   }
-
-   public Domain getTopLevelDomain(AspectManager parent)
-   {
-      Thread.currentThread().getContextClassLoader();
-      return null;
-   }
-
-   public boolean isScoped(ClassLoader classLoader)
-   {
-      //TODO come up with something here?
-      return false;
-   }
-
-   private synchronized void registerDomain(ClassLoader cl, Domain domain)
-   {
-      Domain found = domainsByLoader.get(cl);
-      if (found == null)
-      {
-         domainsByLoader.put(cl, domain);
-      }
-      
-      if (found != domain)
-      {
-         log.warn("Several domains being used for a particular classloader");
-      }
-   }
-   
-   private synchronized Domain getRegisteredDomain(ClassLoader cl)
-   {
-      return domainsByLoader.get(cl);
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderDomainRegistry.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderDomainRegistry.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderDomainRegistry.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,92 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.lang.ref.WeakReference;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.jboss.aop.Domain;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.deployers.plugins.classloading.Module;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class NewClassLoaderDomainRegistry
-{
-   final static ClassLoaderDomain domain = new ClassLoaderDomain("NOT_USED_PLACEHOLDER");
-   
-   /** classloader domains by their classloaders */
-   private Map<ClassLoader, WeakReference<ClassLoaderDomain>> classLoaderDomainsByLoader = new WeakHashMap<ClassLoader, WeakReference<ClassLoaderDomain>>();
-
-   /** aopDomains by classloader domain */
-   private Map<ClassLoaderDomain, ScopedNewClassLoaderDomain> aopDomainsByClassLoaderDomain = new WeakHashMap<ClassLoaderDomain, ScopedNewClassLoaderDomain>();
-
-   synchronized void initMapsForLoader(ClassLoader loader, Module module, ScopedNewClassLoaderDomain domain)
-   {
-      ClassLoaderSystem system = ClassLoaderSystem.getInstance();
-      
-      String domainName = module.getDomainName();
-      ClassLoaderDomain clDomain = system.getDomain(domainName);
-      classLoaderDomainsByLoader.put(loader, new WeakReference<ClassLoaderDomain>(clDomain));
-      
-      if (domain != null)
-      {
-         aopDomainsByClassLoaderDomain.put(clDomain, domain);
-      }
-   }
-
-   synchronized Domain getRegisteredDomain(ClassLoader cl)
-   {
-      ClassLoaderDomain clDomain = getClassLoaderDomainForLoader(cl);
-      if (clDomain != null)
-      {
-         return aopDomainsByClassLoaderDomain.get(clDomain);
-      }
-      return null;
-   }
-   
-   synchronized ClassLoaderDomain getClassLoaderDomainForLoader(ClassLoader cl)
-   {
-      WeakReference<ClassLoaderDomain> clDomainRef = classLoaderDomainsByLoader.get(cl);
-      if (clDomainRef != null)
-      {
-         return clDomainRef.get();
-      }
-      
-      ClassLoader parent = cl.getParent();
-      if (parent != null)
-      {
-         ClassLoaderDomain domain = getClassLoaderDomainForLoader(parent);
-         if (domain != null)
-         {
-            classLoaderDomainsByLoader.put(parent, new WeakReference<ClassLoaderDomain>(domain));
-            return domain;
-         }
-      }
-      return null;
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderScopingPolicy.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderScopingPolicy.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderScopingPolicy.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,133 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.Domain;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.aop.domain.NewClassLoaderDomainInitializer;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.deployers.plugins.classloading.Module;
-import org.jboss.deployers.structure.spi.classloading.ClassLoaderMetaData;
-import org.jboss.logging.Logger;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class NewClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy, NewClassLoaderDomainInitializer
-{
-   static Logger log = Logger.getLogger(NewClassLoaderScopingPolicy.class);
-   NewClassLoaderDomainRegistry registry;
-   
-   public NewClassLoaderDomainRegistry getRegistry()
-   {
-      return registry;
-   }
-
-   public void setRegistry(NewClassLoaderDomainRegistry registry)
-   {
-      this.registry = registry;
-   }
-
-   public Domain initScopedDomain(ClassLoader loader, Module module)
-   {
-      ScopedNewClassLoaderDomain scopedDomain = (ScopedNewClassLoaderDomain)registry.getRegisteredDomain(loader);
-      if (scopedDomain == null)
-      {
-         if (module.getParentDomain() != null/* && module.getParentDomain().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME)*/)
-         {
-            ClassLoaderSystem system = ClassLoaderSystem.getInstance();
-            String domainName = module.getDomainName();
-            ClassLoaderDomain domain = system.getDomain(domainName);
-   
-            ClassLoaderMetaData cmd = module.getMetadata();
-            boolean parentDelegation = cmd.isJ2seClassLoadingCompliance();
-            String name = String.valueOf(System.identityHashCode(loader));
-            
-            scopedDomain = new ScopedNewClassLoaderDomain(loader, name, parentDelegation, AspectManager.getTopLevelAspectManager(), false, domain, registry);
-         }
-   
-         registry.initMapsForLoader(loader, module, scopedDomain);
-         
-         //Need to pass some data through to the classpoolfactory here
-         Map properties = new HashMap();
-         //The module is needed by the JBoss5ClassPoolFactory, the legacy JBossClassPoolFactory will ignore this
-         properties.put(Module.class, module);
-         ExtraClassPoolFactoryParameters.pushThreadProperties(properties);
-         try
-         {
-            AspectManager.instance().registerClassLoader(loader); //Ends up in classpool factory create method
-         }
-         finally
-         {
-            ExtraClassPoolFactoryParameters.popThreadProperties();
-         }
-      }      
-      return scopedDomain;
-   }
-   
-   public Domain getDomain(ClassLoader classLoader, AspectManager parent)
-   {
-      //Check the stored domains
-      Domain domain = registry.getRegisteredDomain(classLoader);
-      if (domain != null)
-      {
-         return domain;
-      }
-      
-      return null;
-   }
-
-   public Domain getTopLevelDomain(AspectManager parent)
-   {
-      Thread.currentThread().getContextClassLoader();
-      return null;
-   }
-
-//   public boolean isScoped(Module module)
-//   {
-//      String domainName = module.getDomainName();
-//      ClassLoaderMetaData cmd = module.getMetadata();
-////      boolean parentDelegation = cmd.isJ2seClassLoadingCompliance();
-//      
-//      System.out.println("****** DomainName: " + domainName + " parentDomain: " + module.getParentDomain());
-//      
-//      
-//      //FIXME There seems to be no way to navigate the tree of domains
-//      
-//      if (module.getParentDomain() != null && module.getParentDomain().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME))
-//      {
-//         //Should probably check for more levels?
-//         return true;
-//      }
-//      return false;
-//   }
-
-
-}
-   
\ No newline at end of file

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/RepositoryClassLoaderScopingPolicy.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/RepositoryClassLoaderScopingPolicy.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/RepositoryClassLoaderScopingPolicy.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,159 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.Domain;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.aop.classpool.AOPClassPoolRepository;
-import org.jboss.aop.deployment.ScopedRepositoryClassLoaderHelper;
-import org.jboss.aop.domain.RepositoryClassLoaderDomainIntializer;
-import org.jboss.aop.domain.ScopedRepositoryClassLoaderDomain;
-import org.jboss.logging.Logger;
-import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
-import org.jboss.mx.loading.LoaderRepository;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class RepositoryClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy, RepositoryClassLoaderDomainIntializer
-{
-   Logger log = Logger.getLogger(RepositoryClassLoaderScopingPolicy.class);
-   
-   /** A map of domains by loader repository, maintaned by the top level AspectManager */
-   private Map<Object, Domain> scopedClassLoaderDomains = new WeakHashMap<Object, Domain>();
-
-
-   public Domain initScopedDomain(ClassLoader loader)
-   {
-      Domain domain = getDomain(loader, AspectManager.getTopLevelAspectManager());
-      
-      AspectManager.instance().registerClassLoader(loader); //Ends up in classpool factory create method
-
-      return domain;
-   }
-
-   public synchronized Domain getDomain(ClassLoader classLoader, AspectManager parent)
-   {
-      ClassLoader scopedClassLoader = ifScopedDeploymentGetScopedParentUclForCL(classLoader);
-      if (scopedClassLoader != null)
-      {
-         Domain scopedManager = null;
-         synchronized (AOPClassPoolRepository.getInstance().getRegisteredCLs())
-         {
-            Object loaderRepository = getLoaderRepository(classLoader);
-            scopedManager = scopedClassLoaderDomains.get(loaderRepository);
-            
-            // FIXME: JBAOP-107 REMOVE THIS HACK
-            if (scopedManager != null && scopedManager.isValid() == false)
-            {
-               scopedClassLoaderDomains.remove(loaderRepository);
-               scopedManager = null;
-            }
-            
-            if (scopedManager == null)
-            {
-               scopedManager = getScopedClassLoaderDomain(scopedClassLoader, parent);
-               log.debug("Created domain " + scopedManager + " for scoped deployment on: " +
-                        classLoader + "; identifying scoped ucl: " + scopedClassLoader);
-               scopedManager.setInheritsBindings(true);
-               scopedManager.setInheritsDeclarations(true);
-               
-               scopedClassLoaderDomains.put(loaderRepository, scopedManager);
-            }
-            return scopedManager;
-         }
-      }
-      return null;
-   }
-
-   public Domain getTopLevelDomain(AspectManager parent)
-   {
-      ClassLoader classLoader = getTopLevelJBossClassLoader();
-      return getDomain(classLoader, parent);
-   }
-   
-//////////
-   
-   private ClassLoader ifScopedDeploymentGetScopedParentUclForCL(ClassLoader loader)
-   {
-      ClassLoader parent = loader;
-      //The web classloader will be a child of the unified classloader - find out if that is scoped
-      while (parent != null)
-      {
-         if (ScopedRepositoryClassLoaderHelper.isScopedClassLoader(parent))
-         {
-            return parent;
-         }
-         if (parent instanceof RepositoryClassLoader)
-         {
-            //We were a repository classloader, but not scoped - ignore the parents like a sulky teenager
-            return null;
-         }
-         parent = parent.getParent();
-      }
-      return null;
-   }
-   
-   private ClassLoader getTopLevelJBossClassLoader()
-   {
-      ClassLoader loader = Thread.currentThread().getContextClassLoader();
-      RepositoryClassLoader topRcl = null;
-      while (loader != null)
-      {
-         if (loader instanceof RepositoryClassLoader)
-         {
-            topRcl = (RepositoryClassLoader)loader;
-         }
-         loader = loader.getParent();
-      }
-      return topRcl;
-   }
-
-   private Domain getScopedClassLoaderDomain(ClassLoader cl, AspectManager parent)
-   {
-      boolean parentDelegation = true;
-      if (cl instanceof RepositoryClassLoader)
-      {
-         HeirarchicalLoaderRepository3 repository = (HeirarchicalLoaderRepository3)((RepositoryClassLoader)cl).getLoaderRepository();
-         parentDelegation = repository.getUseParentFirst();
-      }
-      String name = String.valueOf(System.identityHashCode(cl));
-      return new ScopedRepositoryClassLoaderDomain(cl, name, parentDelegation, parent, false);
-   }
-
-   private Object getLoaderRepository(ClassLoader loader)
-   {
-      ClassLoader cl = ifScopedDeploymentGetScopedParentUclForCL(loader);
-      if (cl != null)
-      {
-         return ((RepositoryClassLoader)cl).getLoaderRepository();
-      }
-      return null;
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedJBoss5ClassPool.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedJBoss5ClassPool.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedJBoss5ClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,282 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.NotFoundException;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.aop.classpool.AOPClassPoolRepository;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.Loader;
-import org.jboss.classloader.spi.base.BaseClassLoader;
-import org.jboss.logging.Logger;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ScopedJBoss5ClassPool extends JBoss5ClassPool
-{
-   Logger log = Logger.getLogger(ScopedJBoss5ClassPool.class);
-   
-   ThreadLocal<ClassPool> lastPool = new ThreadLocal<ClassPool>();
-   WeakReference<ClassLoaderDomain> domainRef;
-
-   public ScopedJBoss5ClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, 
-         URL tmpURL, boolean parentFirst, ClassLoaderDomain domain)
-   {
-      super(cl, src, repository, tmpURL);
-      super.childFirstLookup = !parentFirst;
-      this.domainRef = new WeakReference<ClassLoaderDomain>(domain);
-   }
-
-   private URL getResourceUrlForClass(String resourcename)
-   {
-      ClassLoaderDomain domain = domainRef.get();
-      return domain.getResource(resourcename);
-   }
-
-   private boolean isMine(URL myURL, String resourceName)
-   {
-      if (myURL == null)
-      {
-         return false;
-      }
-      
-      ClassLoaderDomain domain = domainRef.get();
-      Loader parent = domain.getParent();
-      URL parentURL = parent.getResource(resourceName);
-      
-      if (parentURL == null)
-      {
-         return true;
-      }
-      
-      if (!myURL.equals(parentURL))
-      {
-         return true;
-      }
-      
-      return false;
-   }
-   
-   public CtClass getCached(String classname)
-   {
-      if (classname == null)
-      {
-         return null;
-      }
-      if (isUnloadedClassLoader())
-      {
-         return null;
-      }
-
-      if (generatedClasses.get(classname) != null)
-      {
-         //It is a new class, and this callback is probably coming from the frozen check when creating a new nested class
-         return super.getCached(classname);
-      }
-      
-      //Is this from the scoped classloader itself of from the parent?
-      String resourcename = getResourceName(classname);
-      URL url = getResourceUrlForClass(resourcename);
-      
-      if (isMine(url, resourcename))
-      {
-         if (super.childFirstLookup)
-         {
-            //Parent delegation is false, attempt to get this class out of ourselves
-            CtClass clazz = super.getCachedLocally(classname);
-            if (clazz == null)
-            {
-               clazz = createCtClass(classname, false);
-               if (clazz != null)
-               {
-                  lockInCache(clazz);
-               }
-            }
-            if (clazz != null)
-            {
-               return clazz;
-            }
-         }
-         return super.getCached(classname);
-      }
-      else if (url == null)
-      {
-         return super.getCached(classname);
-      }
-      
-
-      try
-      {
-         ClassPool pool = getCorrectPoolForResource(classname, resourcename, url);
-         if (pool != lastPool.get())
-         {
-            lastPool.set(pool);
-            return pool.get(classname);
-         }
-      }
-      catch (NotFoundException e)
-      {
-      }
-      catch(StackOverflowError e)
-      {
-         throw e;
-      }
-      finally
-      {
-         lastPool.set(null);
-      }
-
-      return null;
-   }
-   
-   private ClassPool getCorrectPoolForResource(String classname, String resourceName, URL url)
-   {
-      boolean trace = log.isTraceEnabled();
-      synchronized(AspectManager.getRegisteredCLs())
-      {
-         //JBoss 5 has an extra NoAnnotationURLCLassLoader that is not on the default path, make sure that that is checked at the end
-         //FIXME This needs revisiting/removing once the 
-         ArrayList<ClassPool> noAnnotationURLClassLoaderPools = null;
-         
-//         //EXTRA DEBUG STUFF
-//         if (classname.equals("org.jboss.test.aop.scopedextender.Base_A1"))
-//         {
-//            System.out.println("********** Looking for proper pool for Base_A1 - this pool " + this);
-//            boolean found = false;
-//            for(Iterator it = AspectManager.getRegisteredCLs().values().iterator() ; it.hasNext() ; )
-//            {
-//               AOPClassPool candidate = (AOPClassPool)it.next();
-//               if (candidate.isUnloadedClassLoader())
-//               {
-//                  System.out.println("Found something unloaded " + candidate);
-//                  continue;
-//               }
-//
-//               if (candidate.getClassLoader() instanceof BaseClassLoader)
-//               {
-//                  BaseClassLoader bcl = (BaseClassLoader)candidate.getClassLoader();
-//                  URL foundUrl = bcl.getResourceLocally(resourceName);
-//                  if (foundUrl != null)
-//                  {
-//                     System.out.println("=============> Found in " + bcl);
-//                     if (url.equals(foundUrl))
-//                     {
-//                        if (!found)
-//                        {
-//                           System.out.println("^^^ The one returned ^^^");
-//                           found = true;
-//                        }
-//                     }
-//                  }
-//               }
-//            }
-//         }         
-         
-         for(Iterator it = AspectManager.getRegisteredCLs().values().iterator() ; it.hasNext() ; )
-         {
-            AOPClassPool candidate = (AOPClassPool)it.next();
-            if (candidate.isUnloadedClassLoader())
-            {
-               AspectManager.instance().unregisterClassLoader(candidate.getClassLoader());
-               continue;
-            }
-            
-            if (candidate.getClassLoader() instanceof BaseClassLoader)
-            {
-               //Sometimes the ClassLoader is a proxy for MBeanProxyExt?!
-               BaseClassLoader bcl = (BaseClassLoader)candidate.getClassLoader();
-               URL foundUrl = bcl.getResourceLocally(resourceName);
-               if (trace)
-               {
-                  log.trace("Candidate classloader " + bcl + " has local resource " + foundUrl);
-               }
-               if (foundUrl != null)
-               {
-                  if (url.equals(foundUrl))
-                  {
-                     return candidate;
-                  }
-               }
-            }
-            //FIXME Remove once we have the JBoss 5 version of pool
-            else if (isInstanceOfNoAnnotationURLClassLoader(candidate.getClassLoader()))
-            {
-               if (noAnnotationURLClassLoaderPools == null)
-               {
-                  noAnnotationURLClassLoaderPools = new ArrayList<ClassPool>(); 
-               }
-               noAnnotationURLClassLoaderPools.add(candidate);
-            }
-         }
-         
-         //FIXME Remove once we have the JBoss 5 version of pool
-         if (noAnnotationURLClassLoaderPools != null)
-         {
-            for (ClassPool pool : noAnnotationURLClassLoaderPools)
-            {
-               try
-               {
-                  pool.get(classname);
-                  return pool;
-               }
-               catch(NotFoundException ignoreTryNext)
-               {
-               }
-            }
-         }
-      }
-
-      return AOPClassPool.createAOPClassPool(ClassPool.getDefault(), AOPClassPoolRepository.getInstance());
-   }
-   
-   /**
-    * NoAnnotationURLCLassLoader lives in different packages in JBoss 4 and 5
-    */
-   private boolean isInstanceOfNoAnnotationURLClassLoader(ClassLoader loader)
-   {
-      Class parent = loader.getClass();
-      while (parent != null)
-      {
-         if ("NoAnnotationURLClassLoader".equals(parent.getSimpleName()))
-         {
-            return true;
-         }
-         parent = parent.getSuperclass();
-      }
-      return false;
-   }
-   
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedNewClassLoaderDomain.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedNewClassLoaderDomain.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedNewClassLoaderDomain.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,154 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-
-import java.lang.ref.WeakReference;
-import java.net.URL;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.advice.AspectDefinition;
-import org.jboss.aop.domain.ScopedClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
-import org.jboss.mx.loading.LoaderRepository;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-
-/**
- * A domain that is used for scoped classloaders with the new JBoss 5 classloaders 
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @author adrian at jboss.org
- * @version $Revision: 1.1 $
- */
-public class ScopedNewClassLoaderDomain extends ScopedClassLoaderDomain
-{
-   WeakReference<ClassLoaderDomain> classLoaderDomainRef;
-   NewClassLoaderDomainRegistry registry;
-   
-   public ScopedNewClassLoaderDomain(ClassLoader loader, String name, boolean parentDelegation, AspectManager manager, boolean parentFirst, 
-         ClassLoaderDomain classLoaderDomain, NewClassLoaderDomainRegistry registry)
-   {
-      super(loader, name, parentDelegation, manager, parentFirst);
-      classLoaderDomainRef = new WeakReference<ClassLoaderDomain>(classLoaderDomain);
-      this.registry = registry;
-   }
-
-   private ClassLoaderDomain getClassLoaderDomain()
-   {
-      if (classLoaderDomainRef != null)
-      {
-         return classLoaderDomainRef.get();
-      }
-      return null;
-   }
-   
-   // FIXME: JBAOP-107 REMOVE THIS HACK
-   public boolean isValid()
-   {
-      ClassLoader cl = getClassLoader();
-      if (cl == null)
-         return false;
-    
-      ClassLoaderDomain domain = getClassLoaderDomain();
-      if (domain == null)
-         return false;
-      
-      if (domain.hasClassLoaders())
-      {
-         return true;
-      }
-      
-      return false;
-//      return cl.getLoaderRepository() != null;
-   }
-
-   protected Object getPerVmAspectWithNoParentDelegation(String def)
-   {
-      Object aspect = myPerVMAspects.get(def);
-      if (aspect != null)
-      {
-         return aspect;
-      }
-
-      aspect = super.getSuperPerVmAspect(def);
-      if (aspect != null)
-      {
-         Class superAspectClass = aspect.getClass();
-         ClassLoaderDomain loadingDomain = getAspectRepository(superAspectClass);
-
-         ClassLoaderDomain myDomain = getClassLoaderDomain();
-         
-         if (loadingDomain == myDomain)
-         {
-            //The parent does not load this class
-            myPerVMAspects.put(def, aspect);
-         }
-         else
-         {
-            //The class has been loaded by a parent domain, find out if we also have a copy
-            Class myAspectClazz = myDomain.loadClass(aspect.getClass().getName());
-            
-            if (myAspectClazz == superAspectClass)
-            {
-               notMyPerVMAspects.put(def, Boolean.TRUE);
-            }
-            else
-            {
-               //We have a different version of the class deployed
-               AspectDefinition aspectDefinition = getAspectDefinition(def);
-               //Override the classloader to create the aspect instance
-               aspect = createPerVmAspect(def, aspectDefinition, getClassLoader());
-               myPerVMAspects.put(def, aspect);
-            }
-         }
-      }
-      
-      return aspect;
-   }
-   
-   
-   
-   private ClassLoaderDomain getAspectRepository(Class clazz)
-   {
-      ClassLoader cl = clazz.getClassLoader();
-      ClassLoaderDomain domain = registry.getClassLoaderDomainForLoader(cl);
-      return domain;
-   }
-   
-//   private HeirarchicalLoaderRepository3 getScopedRepository()
-//   {
-//      ClassLoader classloader = getClassLoader();
-//      if (classloader == null)
-//         throw new IllegalStateException("ClassLoader no longer exists: " + classLoaderString);
-//      if (classloader instanceof RepositoryClassLoader == false)
-//         throw new IllegalStateException("ClassLoader is not an instanceof RepositoryClassLoader " + classLoaderString);
-//      RepositoryClassLoader repositoryClassLoader = (RepositoryClassLoader) classloader;
-//      LoaderRepository loaderRepository = repositoryClassLoader.getLoaderRepository();
-//      if (loaderRepository == null)
-//         throw new IllegalStateException("ClassLoader has been undeployed: " + classLoaderString);
-//      if (loaderRepository instanceof HeirarchicalLoaderRepository3 == false)
-//         throw new IllegalStateException("Repository " + loaderRepository + " for classlaoder " + classLoaderString + " is not an HeirarchicalLoaderRepository3");
-//      return (HeirarchicalLoaderRepository3) loaderRepository;
-//   }
-}

Modified: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectDeployer.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectDeployer.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectDeployer.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -35,6 +35,7 @@
 import org.jboss.aop.AspectAnnotationLoader;
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.AspectXmlLoader;
+import org.jboss.asintegration.jboss4.ScopedRepositoryClassLoaderHelper;
 import org.jboss.deployment.DeploymentException;
 import org.jboss.deployment.DeploymentInfo;
 import org.jboss.deployment.DeploymentState;

Modified: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectManagerService.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectManagerService.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectManagerService.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -45,6 +45,8 @@
 import org.jboss.aop.hook.JDK14TransformerManager;
 import org.jboss.aop.instrument.InstrumentorFactory;
 import org.jboss.aop.instrument.TransformerCommon;
+import org.jboss.asintegration.JBossIntegration;
+import org.jboss.asintegration.jboss4.JBoss4Integration;
 import org.jboss.logging.Logger;
 import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
 import org.jboss.mx.server.ServerConstants;

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBoss4Integration.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBoss4Integration.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBoss4Integration.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,157 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.aop.deployment;
-
-import java.io.File;
-
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.ReflectionException;
-
-import javassist.ClassPool;
-import javassist.scopedpool.ScopedClassPool;
-import javassist.scopedpool.ScopedClassPoolFactory;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.aop.deployers.temp.RepositoryClassLoaderScopingPolicy;
-import org.jboss.mx.loading.RepositoryClassLoader;
-import org.jboss.mx.util.MBeanServerLocator;
-
-/**
- * JBoss4Integration.<p>
- * 
- * This class and its associated classes are
- * for the old JBoss4 integration with the LoaderRepository<p>
- * 
- * <ul>Related Classes:
- * <li> {@link JBossClassPool}
- * <li> {@link JBossClassPoolFactory}
- * <li> {@link ScopedRepositoryClassLoaderHelper}
- * <li> {@link LoaderRepositoryUrlUtil}
- * <li> {@link ScopedRepositoryClassLoaderDomain}
- * <li> {@link ScopedJBossClassPool}
- * </ul>
- * 
- * @deprecated TODO JBAOP-107 need to write a JBoss5 version 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
- at Deprecated
-public class JBoss4Integration implements JBossIntegration, ScopedClassPoolFactory
-{
-   /** The delegate classpool factory */
-   private ScopedClassPoolFactory delegateClassPoolFactory;
-   
-   public boolean isValidClassLoader(ClassLoader loader)
-   {
-      if (!(loader instanceof RepositoryClassLoader)) return false;
-      return ((RepositoryClassLoader) loader).getLoaderRepository() != null;
-   }
-
-   public AOPClassLoaderScopingPolicy createAOPClassLoaderScopingPolicy()
-   {
-      return new RepositoryClassLoaderScopingPolicy();
-   }
-
-   public ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception
-   {
-      delegateClassPoolFactory = new JBossClassPoolFactory(tmpDir);
-      return this;
-   }
-   
-   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
-   {
-      return delegateClassPoolFactory.create(cl, src, repository);
-   }
-
-   public ScopedClassPool create(ClassPool src, ScopedClassPoolRepository repository)
-   {
-      return delegateClassPoolFactory.create(src, repository);
-   }
-   
-   public void attachDeprecatedTranslator()
-   {
-      AspectManager mgr = AspectManager.instance();
-      MBeanServer server = MBeanServerLocator.locateJBoss();
-      try
-      {
-         server.setAttribute(AspectManagerService.DEFAULT_LOADER_REPOSITORY, new Attribute("Translator", mgr));
-      }
-      catch (InstanceNotFoundException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (AttributeNotFoundException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (InvalidAttributeValueException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (MBeanException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (ReflectionException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   public void detachDeprecatedTranslator()
-   {
-      MBeanServer server = MBeanServerLocator.locateJBoss();
-      try
-      {
-         server.setAttribute(AspectManagerService.DEFAULT_LOADER_REPOSITORY, new Attribute("Translator", null));
-      }
-      catch (InstanceNotFoundException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (AttributeNotFoundException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (InvalidAttributeValueException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (MBeanException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (ReflectionException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassLoaderValidator.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassLoaderValidator.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassLoaderValidator.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,43 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.aop.deployment;
-
-import org.jboss.aop.ClassLoaderValidation;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-/**
- * Comment
- *
- * TODO Is this used anywhere anymore? {@link JBoss4Integration} contains the real implementation
- * @Deprecated use JBossIntegration
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
- at Deprecated
-public class JBossClassLoaderValidator implements ClassLoaderValidation
-{
-   public boolean isValidClassLoader(ClassLoader loader)
-   {
-      if (!(loader instanceof RepositoryClassLoader)) return false;
-      return ((RepositoryClassLoader) loader).getLoaderRepository() != null;
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassPool.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassPool.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,138 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.aop.deployment;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-import java.security.ProtectionDomain;
-
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.mx.loading.RepositoryClassLoader;
-import javassist.CannotCompileException;
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-/**
- * Comment
- *
- * @deprecated TODO JBAOP-107 Need a different version for the JBoss5 classloader 
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision$
- */
- at Deprecated
-public class JBossClassPool extends AOPClassPool
-{
-   /**
-    * Used for dynamically created classes (see loadClass(String, byte[]), ClassLoader)
-    */
-   protected File tempdir = null;
-   protected URL tempURL = null;
-   // For loadClass tmpdir creation for UCL
-   protected final Object tmplock = new Object();
-   
-   protected JBossClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, File tmp, URL tmpURL)
-   {
-      super(cl, src, repository);
-      tempdir = tmp;
-      tempURL = tmpURL;
-   }
-
-   protected JBossClassPool(ClassPool src, ScopedClassPoolRepository repository)
-   {
-      super(src, repository);
-   }
-
-   public boolean isUnloadedClassLoader()
-   {
-      if (getClassLoader() instanceof RepositoryClassLoader)
-      {
-         RepositoryClassLoader rcl = (RepositoryClassLoader) getClassLoader();
-         return rcl.getLoaderRepository() == null;
-      }
-      return false;
-   }
-
-   public Class toClass(CtClass cc, ClassLoader loader, ProtectionDomain domain)
-   throws CannotCompileException
-   {
-      lockInCache(cc);
-      if (getClassLoader() == null || tempdir == null)
-      {
-         return super.toClass(cc, loader, domain);
-      }
-      Class dynClass = null;
-      try
-      {
-         File classFile = null;
-         String classFileName = getResourceName(cc.getName());
-         // Write the clas file to the tmpdir
-         synchronized (tmplock)
-         {
-            classFile = new File(tempdir, classFileName);
-            File pkgDirs = classFile.getParentFile();
-            pkgDirs.mkdirs();
-            FileOutputStream stream = new FileOutputStream(classFile);
-            stream.write(cc.toBytecode());
-            stream.flush();
-            stream.close();
-            classFile.deleteOnExit();
-         }
-         // We have to clear Blacklist caches or the class will never
-         // be found
-         //((UnifiedClassLoader)dcl).clearBlacklists();
-         // To be backward compatible
-         RepositoryClassLoader rcl = (RepositoryClassLoader) getClassLoader();
-         rcl.clearClassBlackList();
-         rcl.clearResourceBlackList();
-
-         // Now load the class through the cl
-         dynClass = getClassLoader().loadClass(cc.getName());
-      }
-      catch (Exception ex)
-      {
-         ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName());
-         cfe.initCause(ex);
-         throw cfe;
-      }
-
-      return dynClass;
-   }
-
-   protected boolean isLocalResource(String resourceName)
-   {
-      if (super.isLocalResource(resourceName))
-      {
-         return true;
-      }
-      
-      File file = new File(tempdir, resourceName);
-      if (file.exists())
-      {
-         return true;
-      }
-      
-      return false;
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassPoolFactory.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassPoolFactory.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassPoolFactory.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,134 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.aop.deployment;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.aop.classpool.AbstractJBossClassPoolFactory;
-import org.jboss.mx.loading.RepositoryClassLoader;
-import javassist.ClassPool;
-import javassist.scopedpool.ScopedClassPool;
-import javassist.scopedpool.ScopedClassPoolFactory;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-/**
- * Comment
- *
- * @deprecated TODO JBAOP-107 Need a different version for the JBoss5 classloader 
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision$
- **/
- at Deprecated
-public class JBossClassPoolFactory extends AbstractJBossClassPoolFactory implements ScopedClassPoolFactory
-{
-   protected File tmpClassesDir;
-
-   public JBossClassPoolFactory(File tmpClassesDir) throws IOException
-   {
-      this.tmpClassesDir = tmpClassesDir;
-
-   }
-   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
-   {
-      ClassPool parent = getCreateParentClassPools(cl, src, repository);
-      if (cl instanceof RepositoryClassLoader)
-      {
-         File tempdir = getTempDirectory(cl);
-         URL tmpCP;
-         try
-         {
-            tmpCP = createURLAndAddToLoader(cl, tempdir);
-         }
-         catch (IOException e)
-         {
-            throw new RuntimeException(e);
-         }
-         AOPClassLoaderScopingPolicy policy = AspectManager.getClassLoaderScopingPolicy();
-         if (ScopedRepositoryClassLoaderHelper.isScopedClassLoader(cl))
-         {
-            //It is scoped
-            return new ScopedJBossClassPool(cl, parent, repository, tempdir, tmpCP);
-         }
-         return new JBossClassPool(cl, parent, repository, tempdir, tmpCP);
-      }
-      return new AOPClassPool(cl, parent, repository);
-   }
-
-   protected File getTempDirectory(ClassLoader cl)
-   {
-      File tempdir = null;
-      int attempts = 0;
-      IOException ex = null;
-      while (tempdir == null && attempts < 5)
-      {
-         //Workaround for JBAOP-254, retry a few times
-         try
-         {
-            tempdir = createTempDir(cl);
-         }
-         catch (IOException e)
-         {
-            ex = e;
-         }
-      }
-      
-      if (tempdir == null)
-      {
-         throw new RuntimeException("", ex);
-      }
-      
-      return tempdir;
-   }
-
-   public File createTempDir(ClassLoader cl) throws IOException
-   {
-      File tempdir = File.createTempFile("ucl", "", tmpClassesDir);
-      tempdir.delete();
-      tempdir.mkdir();
-      tempdir.deleteOnExit();
-
-      return tempdir;
-   }
-   
-   private URL createURLAndAddToLoader(ClassLoader cl, File tempdir) throws IOException
-   {
-      URL tmpURL = tempdir.toURL();
-      URL tmpCP = new URL(tmpURL, "?dynamic=true");
-
-      RepositoryClassLoader ucl = (RepositoryClassLoader) cl;
-
-      // We may be undeploying.
-      if (ucl.getLoaderRepository() != null)
-      {
-         ucl.addURL(tmpCP);
-      }
-      
-      return tmpCP;
-   }
-
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossIntegration.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossIntegration.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossIntegration.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,69 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.aop.deployment;
-
-import java.io.File;
-
-import javassist.scopedpool.ScopedClassPoolFactory;
-
-import org.jboss.aop.ClassLoaderValidation;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-
-/**
- * AOPIntegration.<p>
- * 
- * This class is intended to identify all the integration
- * points AOP is making with the JBoss appserver.
- * 
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public interface JBossIntegration extends ClassLoaderValidation
-{
-   /**
-    * Create the AOPClassLoaderScopingPolicy
-    * 
-    * @return the policy
-    */
-   AOPClassLoaderScopingPolicy createAOPClassLoaderScopingPolicy();
-
-   /**
-    * Create a scoped classpool factory
-    *
-    * TODO JBAOP-107 need to review whether ScopedClassPool should also be replaced with
-    *      some other policy, e.g. javassist ClassPath notion is closer to new classloader?
-    * @param tmpDir the temporary directory for classes
-    * @return the factory
-    * @throws Exception for any error
-    */
-   ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception;
-   
-   /**
-    * Attach the depreacted translator
-    */
-   void attachDeprecatedTranslator();
-
-   /**
-    * Detach the deprecated translator
-    */
-   void detachDeprecatedTranslator();
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/LoaderRepositoryUrlUtil.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/LoaderRepositoryUrlUtil.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/LoaderRepositoryUrlUtil.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,177 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployment;
-
-import java.net.URL;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
-import org.jboss.mx.loading.LoaderRepository;
-import org.jboss.mx.util.MBeanServerLocator;
-
-/**
- * 
- * @deprecated TODO JBAOP-107 Need a different version for the JBoss5 classloader 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
- at Deprecated
-public class LoaderRepositoryUrlUtil implements NotificationListener
-{
-   final static MBeanServer SERVER;
-   final static ObjectName MAIN_LOADER_REPOSITORY_OBJECT_NAME;
-   final static LoaderRepository MAIN_LOADER_REPOSITORY;
-   static
-   {
-      SERVER = MBeanServerLocator.locateJBoss();
-      try
-      {
-         MAIN_LOADER_REPOSITORY_OBJECT_NAME = new ObjectName("JMImplementation:name=Default,service=LoaderRepository");
-         MAIN_LOADER_REPOSITORY = (LoaderRepository)SERVER.invoke(MAIN_LOADER_REPOSITORY_OBJECT_NAME, "getInstance", new Object[0], new String[0]);
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   long currentSequenceNumber;
-   long lastSequenceNumber = -1;
-   URL[] urls;
-   
-   public LoaderRepositoryUrlUtil()
-   {
-      try
-      {
-         SERVER.addNotificationListener(MAIN_LOADER_REPOSITORY_OBJECT_NAME, this, null, null);
-      }
-      catch (InstanceNotFoundException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   public synchronized void handleNotification(Notification notification, Object handback)
-   {
-      if (notification.getType().equals(LoaderRepository.CLASSLOADER_ADDED))
-      {
-         currentSequenceNumber = notification.getSequenceNumber();
-      }
-      else if (notification.getType().equals(LoaderRepository.CLASSLOADER_REMOVED))
-      {
-         currentSequenceNumber = notification.getSequenceNumber();
-      }
-   }
-   
-   public synchronized UrlInfo getURLInfo(HeirarchicalLoaderRepository3 scopedLoader, UrlInfo urlInfo)
-   {
-      boolean changed = false;
-      if (lastSequenceNumber != currentSequenceNumber)
-      {
-         urls = MAIN_LOADER_REPOSITORY.getURLs();
-         lastSequenceNumber = currentSequenceNumber;
-         changed = true;
-      }
-      if (!changed)
-      {
-         changed = urlInfo != null && (urlInfo.getSequenceNumber() != lastSequenceNumber);
-      }
-      if (urlInfo == null || changed)
-      {
-         URL[] localUrls = getLocalUrls(scopedLoader, urls);
-         urlInfo = new UrlInfo(urls, localUrls, lastSequenceNumber);
-      }
-      return urlInfo;
-   }
-   
-   public long getCurrentSequenceNumber()
-   {
-      return currentSequenceNumber;
-   }
-   
-   private URL[] getLocalUrls(HeirarchicalLoaderRepository3 scopedRepository, URL[] globalUrls)
-   {
-      URL[] scopedRepositoryUrls = scopedRepository.getURLs();
-
-      //This is a bit of a hack, since this relies on the order of the urls returned by HeirarchicalLoaderRepository3
-      //My urls, followed by parent urls.
-      int scopedLength = 0;
-      for (int i = 0 ; i < scopedRepositoryUrls.length ; i++)
-      {
-         URL scopedUrl = scopedRepositoryUrls[i];
-         for (int j = 0 ; j < globalUrls.length ; j ++)
-         {
-            URL globalUrl = globalUrls[j];
-            if (scopedRepositoryUrls[i].equals(globalUrls[j]))
-            {
-               scopedLength = i;
-               break;
-            }
-         }
-         if (scopedLength > 0)
-         {
-            break;
-         }
-      }
-      
-      URL[] localUrls = new URL[scopedLength];
-      System.arraycopy(scopedRepositoryUrls, 0, localUrls, 0, scopedLength);
-      return localUrls;
-   }
-   
-   public class UrlInfo
-   {
-      
-      URL[] globalUrls;
-      URL[] localUrls;
-      long sequenceNumber;
-
-      public UrlInfo(URL[] globalUrls, URL[] localUrls, long sequenceNumber)
-      {
-         super();
-         this.globalUrls = globalUrls;
-         this.localUrls = localUrls;
-         this.sequenceNumber = sequenceNumber;
-      }
-      
-      public URL[] getGlobalUrls()
-      {
-         return globalUrls;
-      }
-      
-      public URL[] getLocalUrls()
-      {
-         return localUrls;
-      }
-
-      public long getSequenceNumber()
-      {
-         return sequenceNumber;
-      }
-   }
-   
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/ScopedJBossClassPool.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/ScopedJBossClassPool.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/ScopedJBossClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,274 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployment;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.aop.classpool.AOPClassPoolRepository;
-import org.jboss.aop.deployment.LoaderRepositoryUrlUtil.UrlInfo;
-import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
-import org.jboss.mx.loading.LoaderRepository;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.NotFoundException;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-/**
- * A classpool in JBoss backed by a scoped (HierarchicalLoaderRepository) loader repository
- * 
- * @deprecated TODO JBAOP-107 Need a different version for the JBoss5 classloader 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
- at Deprecated
-public class ScopedJBossClassPool extends JBossClassPool 
-{
-   final static LoaderRepositoryUrlUtil LOADER_REPOSITORY_UTIL = new LoaderRepositoryUrlUtil();
-   
-   WeakReference repository = null;
-   UrlInfo urlInfo;
-   ThreadLocal lastPool = new ThreadLocal();
-
-   public ScopedJBossClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, File tmp, URL tmpURL)
-   {
-      super(cl, src, repository, tmp, tmpURL);
-      
-      boolean parentFirst = false;
-      LoaderRepository loaderRepository = null;
-      ClassLoader prnt = cl;
-      while (prnt != null)
-      {
-         if (prnt instanceof RepositoryClassLoader)
-         {
-            loaderRepository = ((RepositoryClassLoader)prnt).getLoaderRepository();
-            if (loaderRepository instanceof HeirarchicalLoaderRepository3)
-            {
-               parentFirst = ((HeirarchicalLoaderRepository3)loaderRepository).getUseParentFirst();
-            }
-            break;
-         }
-         prnt = SecurityActions.getParent(cl);
-      }
-      
-      super.childFirstLookup = !parentFirst;
-   }
-   
-
-   private HeirarchicalLoaderRepository3 getRepository()
-   {
-      ClassLoader cl = getClassLoader0();
-      if (cl != null)
-      {
-         return (HeirarchicalLoaderRepository3)((RepositoryClassLoader)cl).getLoaderRepository();
-      }
-      return null;
-   }
-
-   private URL getResourceUrlForClass(String resourcename)
-   {
-      HeirarchicalLoaderRepository3 repo = getRepository();
-      return repo.getResource(resourcename, super.getClassLoader());
-   }
-   
-   private boolean isMine(URL url)
-   {
-      HeirarchicalLoaderRepository3 repo = getRepository();
-      if (repo != null)
-      {
-         //The URL of the class loaded with my scoped classloader
-         if (url != null)
-         {
-            urlInfo = LOADER_REPOSITORY_UTIL.getURLInfo(getRepository(), urlInfo);
-            
-            URL[] myUrls = urlInfo.getLocalUrls();
-            String resource = url.toString();
-            for (int i = 0 ; i < myUrls.length ; i++)
-            {
-               if (resource.indexOf(myUrls[i].toString()) >= 0)
-               {
-                  return true;
-               }
-            }
-            return false;
-         }
-      }
-      return true;
-   }
-
-   public CtClass getCached(String classname)
-   {
-      if (classname == null)
-      {
-         return null;
-      }
-      if (isUnloadedClassLoader())
-      {
-         return null;
-      }
-
-      if (generatedClasses.get(classname) != null)
-      {
-         //It is a new class, and this callback is probably coming from the frozen check when creating a new nested class
-         return super.getCached(classname);
-      }
-      
-      //Is this from the scoped classloader itself of from the parent?
-      String resourcename = getResourceName(classname);
-      URL url = getResourceUrlForClass(resourcename);
-      boolean isMine = isMine(url);
-      
-      if (isMine)
-      {
-         if (super.childFirstLookup)
-         {
-            //Parent delegation is false, attempt to get this class out of ourselves
-            CtClass clazz = super.getCachedLocally(classname);
-            if (clazz == null)
-            {
-               clazz = createCtClass(classname, false);
-               if (clazz != null)
-               {
-                  lockInCache(clazz);
-               }
-            }
-            if (clazz != null)
-            {
-               return clazz;
-            }
-         }
-         return super.getCached(classname);
-      }
-      
-
-      try
-      {
-         ClassPool pool = getCorrectPoolForResource(classname, url);
-         if (pool != lastPool.get())
-         {
-            lastPool.set(pool);
-            return pool.get(classname);
-         }
-      }
-      catch (NotFoundException e)
-      {
-      }
-      catch(StackOverflowError e)
-      {
-         throw e;
-      }
-      finally
-      {
-         lastPool.set(null);
-      }
-
-      return null;
-   }
-   
-   private ClassPool getCorrectPoolForResource(String classname, URL url)
-   {
-      synchronized(AspectManager.getRegisteredCLs())
-      {
-         //JBoss 5 has an extra NoAnnotationURLCLassLoader that is not on the default path, make sure that that is checked at the end
-         //FIXME This needs revisiting/removing once the 
-         ArrayList noAnnotationURLClassLoaderPools = null;
-         String resource = url.toString();
-         for(Iterator it = AspectManager.getRegisteredCLs().values().iterator() ; it.hasNext() ; )
-         {
-            AOPClassPool candidate = (AOPClassPool)it.next();
-            if (candidate.isUnloadedClassLoader())
-            {
-               AspectManager.instance().unregisterClassLoader(candidate.getClassLoader());
-               continue;
-            }
-            
-            if (candidate.getClassLoader() instanceof RepositoryClassLoader)
-            {
-               //Sometimes the ClassLoader is a proxy for MBeanProxyExt?!
-               RepositoryClassLoader rcl = (RepositoryClassLoader)candidate.getClassLoader();
-               URL[] urls = rcl.getClasspath();
-               
-               for (int i = 0 ; i < urls.length ; i++)
-               {
-                  if (resource.indexOf(urls[i].getFile()) >= 0)
-                  {
-                     return candidate;
-                  }
-               }
-            }
-            //FIXME Remove once we have the JBoss 5 version of pool
-            else if (isInstanceOfNoAnnotationURLClassLoader(candidate.getClassLoader()))
-            {
-               if (noAnnotationURLClassLoaderPools == null)
-               {
-                  noAnnotationURLClassLoaderPools = new ArrayList(); 
-               }
-               noAnnotationURLClassLoaderPools.add(candidate);
-            }
-         }
-         
-         //FIXME Remove once we have the JBoss 5 version of pool
-         if (noAnnotationURLClassLoaderPools != null)
-         {
-            for (Iterator it = noAnnotationURLClassLoaderPools.iterator() ; it.hasNext() ; )
-            {
-               ClassPool pool = (ClassPool)it.next();
-               
-               try
-               {
-                  pool.get(classname);
-                  return pool;
-               }
-               catch(NotFoundException ignoreTryNext)
-               {
-               }
-            }
-         }
-      }
-
-      return AOPClassPool.createAOPClassPool(ClassPool.getDefault(), AOPClassPoolRepository.getInstance());
-   }
-   
-   /**
-    * NoAnnotationURLCLassLoader lives in different packages in JBoss 4 and 5
-    */
-   private boolean isInstanceOfNoAnnotationURLClassLoader(ClassLoader loader)
-   {
-      Class parent = loader.getClass();
-      while (parent != null)
-      {
-         if ("NoAnnotationURLClassLoader".equals(parent.getSimpleName()))
-         {
-            return true;
-         }
-         parent = parent.getSuperclass();
-      }
-      return false;
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/ScopedRepositoryClassLoaderHelper.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/ScopedRepositoryClassLoaderHelper.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/ScopedRepositoryClassLoaderHelper.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,52 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployment;
-
-import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
-import org.jboss.mx.loading.LoaderRepository;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-/**
- * 
- * TODO JBAOP-107 Need a different version for the JBoss5 classloader
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @autor adrian at jboss.org
- * @version $Revision$
- */
-public class ScopedRepositoryClassLoaderHelper
-{
-   public static boolean isScopedClassLoader(ClassLoader loader)
-   {
-      boolean scoped = false;
-      if (loader instanceof RepositoryClassLoader)
-      {
-         LoaderRepository repository = ((RepositoryClassLoader)loader).getLoaderRepository();
-         if (repository instanceof HeirarchicalLoaderRepository3)
-         {
-            scoped = true;
-            HeirarchicalLoaderRepository3 hlr = (HeirarchicalLoaderRepository3)repository;
-            boolean parentFirst = hlr.getUseParentFirst();
-         }
-      }
-      return scoped;
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/SecurityActions.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/SecurityActions.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/SecurityActions.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,80 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployment;
-
-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: 1.1 $
- */
-public 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);
-      }
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/TempJBossClassPool.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/TempJBossClassPool.java	2007-10-19 15:15:40 UTC (rev 66288)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/TempJBossClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,71 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployment;
-
-import org.jboss.aop.classpool.AOPClassPool;
-
-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: 1.1 $
- */
-public class TempJBossClassPool extends AOPClassPool
-{
-   boolean isParentPoolAOP;
-   public TempJBossClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
-   {
-      super(cl, src, repository);
-      if (src instanceof AOPClassPool)
-      {
-         isParentPoolAOP = true;
-      }
-   }
-
-   public TempJBossClassPool(ClassPool src, ScopedClassPoolRepository repository)
-   {
-      super(src, repository);
-      if (src instanceof AOPClassPool)
-      {
-         isParentPoolAOP = true;
-      }
-   }
-
-   public CtClass getCached(String classname)
-   {
-      CtClass clazz = null;
-      if (isParentPoolAOP)
-      {
-         clazz = ((AOPClassPool)parent).getCached(classname);
-      }
-      if (clazz == null)
-      {
-         clazz = super.getCached(classname);
-      }
-      return clazz;
-   }
-
-}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/JBossIntegration.java (from rev 66081, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossIntegration.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/JBossIntegration.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/JBossIntegration.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.asintegration;
+
+import java.io.File;
+
+import javassist.scopedpool.ScopedClassPoolFactory;
+
+import org.jboss.aop.ClassLoaderValidation;
+import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+
+/**
+ * AOPIntegration.<p>
+ * 
+ * This class is intended to identify all the integration
+ * points AOP is making with the JBoss appserver.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface JBossIntegration extends ClassLoaderValidation
+{
+   /**
+    * Create the AOPClassLoaderScopingPolicy
+    * 
+    * @return the policy
+    */
+   AOPClassLoaderScopingPolicy createAOPClassLoaderScopingPolicy();
+
+   /**
+    * Create a scoped classpool factory
+    *
+    * TODO JBAOP-107 need to review whether ScopedClassPool should also be replaced with
+    *      some other policy, e.g. javassist ClassPath notion is closer to new classloader?
+    * @param tmpDir the temporary directory for classes
+    * @return the factory
+    * @throws Exception for any error
+    */
+   ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception;
+   
+   /**
+    * Attach the depreacted translator
+    */
+   void attachDeprecatedTranslator();
+
+   /**
+    * Detach the deprecated translator
+    */
+   void detachDeprecatedTranslator();
+}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBoss4Integration.java (from rev 66081, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBoss4Integration.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBoss4Integration.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBoss4Integration.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,156 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.asintegration.jboss4;
+
+import java.io.File;
+
+import javax.management.Attribute;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.InvalidAttributeValueException;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.ReflectionException;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPool;
+import javassist.scopedpool.ScopedClassPoolFactory;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+import org.jboss.aop.deployment.AspectManagerService;
+import org.jboss.asintegration.JBossIntegration;
+import org.jboss.mx.loading.RepositoryClassLoader;
+import org.jboss.mx.util.MBeanServerLocator;
+
+/**
+ * JBoss4Integration.<p>
+ * 
+ * This class and its associated classes are
+ * for the old JBoss4 integration with the LoaderRepository<p>
+ * 
+ * <ul>Related Classes:
+ * <li> {@link JBossClassPool}
+ * <li> {@link JBossClassPoolFactory}
+ * <li> {@link ScopedRepositoryClassLoaderHelper}
+ * <li> {@link LoaderRepositoryUrlUtil}
+ * <li> {@link ScopedRepositoryClassLoaderDomain}
+ * <li> {@link ScopedJBossClassPool}
+ * </ul>
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBoss4Integration implements JBossIntegration, ScopedClassPoolFactory
+{
+   /** The delegate classpool factory */
+   private ScopedClassPoolFactory delegateClassPoolFactory;
+   
+   public boolean isValidClassLoader(ClassLoader loader)
+   {
+      if (!(loader instanceof RepositoryClassLoader)) return false;
+      return ((RepositoryClassLoader) loader).getLoaderRepository() != null;
+   }
+
+   public AOPClassLoaderScopingPolicy createAOPClassLoaderScopingPolicy()
+   {
+      return new RepositoryClassLoaderScopingPolicy();
+   }
+
+   public ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception
+   {
+      delegateClassPoolFactory = new JBossClassPoolFactory(tmpDir);
+      return this;
+   }
+   
+   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      return delegateClassPoolFactory.create(cl, src, repository);
+   }
+
+   public ScopedClassPool create(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      return delegateClassPoolFactory.create(src, repository);
+   }
+   
+   public void attachDeprecatedTranslator()
+   {
+      AspectManager mgr = AspectManager.instance();
+      MBeanServer server = MBeanServerLocator.locateJBoss();
+      try
+      {
+         server.setAttribute(AspectManagerService.DEFAULT_LOADER_REPOSITORY, new Attribute("Translator", mgr));
+      }
+      catch (InstanceNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (AttributeNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (InvalidAttributeValueException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (MBeanException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (ReflectionException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public void detachDeprecatedTranslator()
+   {
+      MBeanServer server = MBeanServerLocator.locateJBoss();
+      try
+      {
+         server.setAttribute(AspectManagerService.DEFAULT_LOADER_REPOSITORY, new Attribute("Translator", null));
+      }
+      catch (InstanceNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (AttributeNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (InvalidAttributeValueException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (MBeanException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (ReflectionException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBossClassPool.java (from rev 66081, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassPool.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBossClassPool.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBossClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,136 @@
+/*
+* 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.asintegration.jboss4;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.security.ProtectionDomain;
+
+import org.jboss.aop.classpool.AOPClassPool;
+import org.jboss.mx.loading.RepositoryClassLoader;
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author adrian at jboss.org
+ * @version $Revision$
+ */
+public class JBossClassPool extends AOPClassPool
+{
+   /**
+    * Used for dynamically created classes (see loadClass(String, byte[]), ClassLoader)
+    */
+   protected File tempdir = null;
+   protected URL tempURL = null;
+   // For loadClass tmpdir creation for UCL
+   protected final Object tmplock = new Object();
+   
+   protected JBossClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, File tmp, URL tmpURL)
+   {
+      super(cl, src, repository);
+      tempdir = tmp;
+      tempURL = tmpURL;
+   }
+
+   protected JBossClassPool(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      super(src, repository);
+   }
+
+   public boolean isUnloadedClassLoader()
+   {
+      if (getClassLoader() instanceof RepositoryClassLoader)
+      {
+         RepositoryClassLoader rcl = (RepositoryClassLoader) getClassLoader();
+         return rcl.getLoaderRepository() == null;
+      }
+      return false;
+   }
+
+   public Class toClass(CtClass cc, ClassLoader loader, ProtectionDomain domain)
+   throws CannotCompileException
+   {
+      lockInCache(cc);
+      if (getClassLoader() == null || tempdir == null)
+      {
+         return super.toClass(cc, loader, domain);
+      }
+      Class dynClass = null;
+      try
+      {
+         File classFile = null;
+         String classFileName = getResourceName(cc.getName());
+         // Write the clas file to the tmpdir
+         synchronized (tmplock)
+         {
+            classFile = new File(tempdir, classFileName);
+            File pkgDirs = classFile.getParentFile();
+            pkgDirs.mkdirs();
+            FileOutputStream stream = new FileOutputStream(classFile);
+            stream.write(cc.toBytecode());
+            stream.flush();
+            stream.close();
+            classFile.deleteOnExit();
+         }
+         // We have to clear Blacklist caches or the class will never
+         // be found
+         //((UnifiedClassLoader)dcl).clearBlacklists();
+         // To be backward compatible
+         RepositoryClassLoader rcl = (RepositoryClassLoader) getClassLoader();
+         rcl.clearClassBlackList();
+         rcl.clearResourceBlackList();
+
+         // Now load the class through the cl
+         dynClass = getClassLoader().loadClass(cc.getName());
+      }
+      catch (Exception ex)
+      {
+         ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName());
+         cfe.initCause(ex);
+         throw cfe;
+      }
+
+      return dynClass;
+   }
+
+   protected boolean isLocalResource(String resourceName)
+   {
+      if (super.isLocalResource(resourceName))
+      {
+         return true;
+      }
+      
+      File file = new File(tempdir, resourceName);
+      if (file.exists())
+      {
+         return true;
+      }
+      
+      return false;
+   }
+}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBossClassPoolFactory.java (from rev 66284, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/JBossClassPoolFactory.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBossClassPoolFactory.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/JBossClassPoolFactory.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,132 @@
+/*
+* 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.asintegration.jboss4;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+import org.jboss.aop.classpool.AOPClassPool;
+import org.jboss.aop.classpool.AbstractJBossClassPoolFactory;
+import org.jboss.mx.loading.RepositoryClassLoader;
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPool;
+import javassist.scopedpool.ScopedClassPoolFactory;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author adrian at jboss.org
+ * @version $Revision$
+ **/
+public class JBossClassPoolFactory extends AbstractJBossClassPoolFactory implements ScopedClassPoolFactory
+{
+   protected File tmpClassesDir;
+
+   public JBossClassPoolFactory(File tmpClassesDir) throws IOException
+   {
+      this.tmpClassesDir = tmpClassesDir;
+
+   }
+   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      ClassPool parent = getCreateParentClassPools(cl, src, repository);
+      if (cl instanceof RepositoryClassLoader)
+      {
+         File tempdir = getTempDirectory(cl);
+         URL tmpCP;
+         try
+         {
+            tmpCP = createURLAndAddToLoader(cl, tempdir);
+         }
+         catch (IOException e)
+         {
+            throw new RuntimeException(e);
+         }
+         AOPClassLoaderScopingPolicy policy = AspectManager.getClassLoaderScopingPolicy();
+         if (ScopedRepositoryClassLoaderHelper.isScopedClassLoader(cl))
+         {
+            //It is scoped
+            return new ScopedJBossClassPool(cl, parent, repository, tempdir, tmpCP);
+         }
+         return new JBossClassPool(cl, parent, repository, tempdir, tmpCP);
+      }
+      return new AOPClassPool(cl, parent, repository);
+   }
+
+   protected File getTempDirectory(ClassLoader cl)
+   {
+      File tempdir = null;
+      int attempts = 0;
+      IOException ex = null;
+      while (tempdir == null && attempts < 5)
+      {
+         //Workaround for JBAOP-254, retry a few times
+         try
+         {
+            tempdir = createTempDir(cl);
+         }
+         catch (IOException e)
+         {
+            ex = e;
+         }
+      }
+      
+      if (tempdir == null)
+      {
+         throw new RuntimeException("", ex);
+      }
+      
+      return tempdir;
+   }
+
+   public File createTempDir(ClassLoader cl) throws IOException
+   {
+      File tempdir = File.createTempFile("ucl", "", tmpClassesDir);
+      tempdir.delete();
+      tempdir.mkdir();
+      tempdir.deleteOnExit();
+
+      return tempdir;
+   }
+   
+   private URL createURLAndAddToLoader(ClassLoader cl, File tempdir) throws IOException
+   {
+      URL tmpURL = tempdir.toURL();
+      URL tmpCP = new URL(tmpURL, "?dynamic=true");
+
+      RepositoryClassLoader ucl = (RepositoryClassLoader) cl;
+
+      // We may be undeploying.
+      if (ucl.getLoaderRepository() != null)
+      {
+         ucl.addURL(tmpCP);
+      }
+      
+      return tmpCP;
+   }
+
+}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/LoaderRepositoryUrlUtil.java (from rev 66081, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/LoaderRepositoryUrlUtil.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/LoaderRepositoryUrlUtil.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/LoaderRepositoryUrlUtil.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,175 @@
+/*
+* 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.asintegration.jboss4;
+
+import java.net.URL;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
+import org.jboss.mx.loading.LoaderRepository;
+import org.jboss.mx.util.MBeanServerLocator;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class LoaderRepositoryUrlUtil implements NotificationListener
+{
+   final static MBeanServer SERVER;
+   final static ObjectName MAIN_LOADER_REPOSITORY_OBJECT_NAME;
+   final static LoaderRepository MAIN_LOADER_REPOSITORY;
+   static
+   {
+      SERVER = MBeanServerLocator.locateJBoss();
+      try
+      {
+         MAIN_LOADER_REPOSITORY_OBJECT_NAME = new ObjectName("JMImplementation:name=Default,service=LoaderRepository");
+         MAIN_LOADER_REPOSITORY = (LoaderRepository)SERVER.invoke(MAIN_LOADER_REPOSITORY_OBJECT_NAME, "getInstance", new Object[0], new String[0]);
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+   
+   long currentSequenceNumber;
+   long lastSequenceNumber = -1;
+   URL[] urls;
+   
+   public LoaderRepositoryUrlUtil()
+   {
+      try
+      {
+         SERVER.addNotificationListener(MAIN_LOADER_REPOSITORY_OBJECT_NAME, this, null, null);
+      }
+      catch (InstanceNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   public synchronized void handleNotification(Notification notification, Object handback)
+   {
+      if (notification.getType().equals(LoaderRepository.CLASSLOADER_ADDED))
+      {
+         currentSequenceNumber = notification.getSequenceNumber();
+      }
+      else if (notification.getType().equals(LoaderRepository.CLASSLOADER_REMOVED))
+      {
+         currentSequenceNumber = notification.getSequenceNumber();
+      }
+   }
+   
+   public synchronized UrlInfo getURLInfo(HeirarchicalLoaderRepository3 scopedLoader, UrlInfo urlInfo)
+   {
+      boolean changed = false;
+      if (lastSequenceNumber != currentSequenceNumber)
+      {
+         urls = MAIN_LOADER_REPOSITORY.getURLs();
+         lastSequenceNumber = currentSequenceNumber;
+         changed = true;
+      }
+      if (!changed)
+      {
+         changed = urlInfo != null && (urlInfo.getSequenceNumber() != lastSequenceNumber);
+      }
+      if (urlInfo == null || changed)
+      {
+         URL[] localUrls = getLocalUrls(scopedLoader, urls);
+         urlInfo = new UrlInfo(urls, localUrls, lastSequenceNumber);
+      }
+      return urlInfo;
+   }
+   
+   public long getCurrentSequenceNumber()
+   {
+      return currentSequenceNumber;
+   }
+   
+   private URL[] getLocalUrls(HeirarchicalLoaderRepository3 scopedRepository, URL[] globalUrls)
+   {
+      URL[] scopedRepositoryUrls = scopedRepository.getURLs();
+
+      //This is a bit of a hack, since this relies on the order of the urls returned by HeirarchicalLoaderRepository3
+      //My urls, followed by parent urls.
+      int scopedLength = 0;
+      for (int i = 0 ; i < scopedRepositoryUrls.length ; i++)
+      {
+         URL scopedUrl = scopedRepositoryUrls[i];
+         for (int j = 0 ; j < globalUrls.length ; j ++)
+         {
+            URL globalUrl = globalUrls[j];
+            if (scopedRepositoryUrls[i].equals(globalUrls[j]))
+            {
+               scopedLength = i;
+               break;
+            }
+         }
+         if (scopedLength > 0)
+         {
+            break;
+         }
+      }
+      
+      URL[] localUrls = new URL[scopedLength];
+      System.arraycopy(scopedRepositoryUrls, 0, localUrls, 0, scopedLength);
+      return localUrls;
+   }
+   
+   public class UrlInfo
+   {
+      
+      URL[] globalUrls;
+      URL[] localUrls;
+      long sequenceNumber;
+
+      public UrlInfo(URL[] globalUrls, URL[] localUrls, long sequenceNumber)
+      {
+         super();
+         this.globalUrls = globalUrls;
+         this.localUrls = localUrls;
+         this.sequenceNumber = sequenceNumber;
+      }
+      
+      public URL[] getGlobalUrls()
+      {
+         return globalUrls;
+      }
+      
+      public URL[] getLocalUrls()
+      {
+         return localUrls;
+      }
+
+      public long getSequenceNumber()
+      {
+         return sequenceNumber;
+      }
+   }
+   
+}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/RepositoryClassLoaderScopingPolicy.java (from rev 66284, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/RepositoryClassLoaderScopingPolicy.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/RepositoryClassLoaderScopingPolicy.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/RepositoryClassLoaderScopingPolicy.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,157 @@
+/*
+* 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.asintegration.jboss4;
+
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+import org.jboss.aop.classpool.AOPClassPoolRepository;
+import org.jboss.aop.domain.RepositoryClassLoaderDomainIntializer;
+import org.jboss.aop.domain.ScopedRepositoryClassLoaderDomain;
+import org.jboss.logging.Logger;
+import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
+import org.jboss.mx.loading.RepositoryClassLoader;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class RepositoryClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy, RepositoryClassLoaderDomainIntializer
+{
+   Logger log = Logger.getLogger(RepositoryClassLoaderScopingPolicy.class);
+   
+   /** A map of domains by loader repository, maintaned by the top level AspectManager */
+   private Map<Object, Domain> scopedClassLoaderDomains = new WeakHashMap<Object, Domain>();
+
+
+   public Domain initScopedDomain(ClassLoader loader)
+   {
+      Domain domain = getDomain(loader, AspectManager.getTopLevelAspectManager());
+      
+      AspectManager.instance().registerClassLoader(loader); //Ends up in classpool factory create method
+
+      return domain;
+   }
+
+   public synchronized Domain getDomain(ClassLoader classLoader, AspectManager parent)
+   {
+      ClassLoader scopedClassLoader = ifScopedDeploymentGetScopedParentUclForCL(classLoader);
+      if (scopedClassLoader != null)
+      {
+         Domain scopedManager = null;
+         synchronized (AOPClassPoolRepository.getInstance().getRegisteredCLs())
+         {
+            Object loaderRepository = getLoaderRepository(classLoader);
+            scopedManager = scopedClassLoaderDomains.get(loaderRepository);
+            
+            // FIXME: JBAOP-107 REMOVE THIS HACK
+            if (scopedManager != null && scopedManager.isValid() == false)
+            {
+               scopedClassLoaderDomains.remove(loaderRepository);
+               scopedManager = null;
+            }
+            
+            if (scopedManager == null)
+            {
+               scopedManager = getScopedClassLoaderDomain(scopedClassLoader, parent);
+               log.debug("Created domain " + scopedManager + " for scoped deployment on: " +
+                        classLoader + "; identifying scoped ucl: " + scopedClassLoader);
+               scopedManager.setInheritsBindings(true);
+               scopedManager.setInheritsDeclarations(true);
+               
+               scopedClassLoaderDomains.put(loaderRepository, scopedManager);
+            }
+            return scopedManager;
+         }
+      }
+      return null;
+   }
+
+   public Domain getTopLevelDomain(AspectManager parent)
+   {
+      ClassLoader classLoader = getTopLevelJBossClassLoader();
+      return getDomain(classLoader, parent);
+   }
+   
+//////////
+   
+   private ClassLoader ifScopedDeploymentGetScopedParentUclForCL(ClassLoader loader)
+   {
+      ClassLoader parent = loader;
+      //The web classloader will be a child of the unified classloader - find out if that is scoped
+      while (parent != null)
+      {
+         if (ScopedRepositoryClassLoaderHelper.isScopedClassLoader(parent))
+         {
+            return parent;
+         }
+         if (parent instanceof RepositoryClassLoader)
+         {
+            //We were a repository classloader, but not scoped - ignore the parents like a sulky teenager
+            return null;
+         }
+         parent = parent.getParent();
+      }
+      return null;
+   }
+   
+   private ClassLoader getTopLevelJBossClassLoader()
+   {
+      ClassLoader loader = Thread.currentThread().getContextClassLoader();
+      RepositoryClassLoader topRcl = null;
+      while (loader != null)
+      {
+         if (loader instanceof RepositoryClassLoader)
+         {
+            topRcl = (RepositoryClassLoader)loader;
+         }
+         loader = loader.getParent();
+      }
+      return topRcl;
+   }
+
+   private Domain getScopedClassLoaderDomain(ClassLoader cl, AspectManager parent)
+   {
+      boolean parentDelegation = true;
+      if (cl instanceof RepositoryClassLoader)
+      {
+         HeirarchicalLoaderRepository3 repository = (HeirarchicalLoaderRepository3)((RepositoryClassLoader)cl).getLoaderRepository();
+         parentDelegation = repository.getUseParentFirst();
+      }
+      String name = String.valueOf(System.identityHashCode(cl));
+      return new ScopedRepositoryClassLoaderDomain(cl, name, parentDelegation, parent, false);
+   }
+
+   private Object getLoaderRepository(ClassLoader loader)
+   {
+      ClassLoader cl = ifScopedDeploymentGetScopedParentUclForCL(loader);
+      if (cl != null)
+      {
+         return ((RepositoryClassLoader)cl).getLoaderRepository();
+      }
+      return null;
+   }
+}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/ScopedJBossClassPool.java (from rev 66081, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/ScopedJBossClassPool.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/ScopedJBossClassPool.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/ScopedJBossClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,272 @@
+/*
+* 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.asintegration.jboss4;
+
+import java.io.File;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.classpool.AOPClassPool;
+import org.jboss.aop.classpool.AOPClassPoolRepository;
+import org.jboss.asintegration.jboss4.LoaderRepositoryUrlUtil.UrlInfo;
+import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
+import org.jboss.mx.loading.LoaderRepository;
+import org.jboss.mx.loading.RepositoryClassLoader;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+/**
+ * A classpool in JBoss backed by a scoped (HierarchicalLoaderRepository) loader repository
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedJBossClassPool extends JBossClassPool 
+{
+   final static LoaderRepositoryUrlUtil LOADER_REPOSITORY_UTIL = new LoaderRepositoryUrlUtil();
+   
+   WeakReference repository = null;
+   UrlInfo urlInfo;
+   ThreadLocal lastPool = new ThreadLocal();
+
+   public ScopedJBossClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, File tmp, URL tmpURL)
+   {
+      super(cl, src, repository, tmp, tmpURL);
+      
+      boolean parentFirst = false;
+      LoaderRepository loaderRepository = null;
+      ClassLoader prnt = cl;
+      while (prnt != null)
+      {
+         if (prnt instanceof RepositoryClassLoader)
+         {
+            loaderRepository = ((RepositoryClassLoader)prnt).getLoaderRepository();
+            if (loaderRepository instanceof HeirarchicalLoaderRepository3)
+            {
+               parentFirst = ((HeirarchicalLoaderRepository3)loaderRepository).getUseParentFirst();
+            }
+            break;
+         }
+         prnt = SecurityActions.getParent(cl);
+      }
+      
+      super.childFirstLookup = !parentFirst;
+   }
+   
+
+   private HeirarchicalLoaderRepository3 getRepository()
+   {
+      ClassLoader cl = getClassLoader0();
+      if (cl != null)
+      {
+         return (HeirarchicalLoaderRepository3)((RepositoryClassLoader)cl).getLoaderRepository();
+      }
+      return null;
+   }
+
+   private URL getResourceUrlForClass(String resourcename)
+   {
+      HeirarchicalLoaderRepository3 repo = getRepository();
+      return repo.getResource(resourcename, super.getClassLoader());
+   }
+   
+   private boolean isMine(URL url)
+   {
+      HeirarchicalLoaderRepository3 repo = getRepository();
+      if (repo != null)
+      {
+         //The URL of the class loaded with my scoped classloader
+         if (url != null)
+         {
+            urlInfo = LOADER_REPOSITORY_UTIL.getURLInfo(getRepository(), urlInfo);
+            
+            URL[] myUrls = urlInfo.getLocalUrls();
+            String resource = url.toString();
+            for (int i = 0 ; i < myUrls.length ; i++)
+            {
+               if (resource.indexOf(myUrls[i].toString()) >= 0)
+               {
+                  return true;
+               }
+            }
+            return false;
+         }
+      }
+      return true;
+   }
+
+   public CtClass getCached(String classname)
+   {
+      if (classname == null)
+      {
+         return null;
+      }
+      if (isUnloadedClassLoader())
+      {
+         return null;
+      }
+
+      if (generatedClasses.get(classname) != null)
+      {
+         //It is a new class, and this callback is probably coming from the frozen check when creating a new nested class
+         return super.getCached(classname);
+      }
+      
+      //Is this from the scoped classloader itself of from the parent?
+      String resourcename = getResourceName(classname);
+      URL url = getResourceUrlForClass(resourcename);
+      boolean isMine = isMine(url);
+      
+      if (isMine)
+      {
+         if (super.childFirstLookup)
+         {
+            //Parent delegation is false, attempt to get this class out of ourselves
+            CtClass clazz = super.getCachedLocally(classname);
+            if (clazz == null)
+            {
+               clazz = createCtClass(classname, false);
+               if (clazz != null)
+               {
+                  lockInCache(clazz);
+               }
+            }
+            if (clazz != null)
+            {
+               return clazz;
+            }
+         }
+         return super.getCached(classname);
+      }
+      
+
+      try
+      {
+         ClassPool pool = getCorrectPoolForResource(classname, url);
+         if (pool != lastPool.get())
+         {
+            lastPool.set(pool);
+            return pool.get(classname);
+         }
+      }
+      catch (NotFoundException e)
+      {
+      }
+      catch(StackOverflowError e)
+      {
+         throw e;
+      }
+      finally
+      {
+         lastPool.set(null);
+      }
+
+      return null;
+   }
+   
+   private ClassPool getCorrectPoolForResource(String classname, URL url)
+   {
+      synchronized(AspectManager.getRegisteredCLs())
+      {
+         //JBoss 5 has an extra NoAnnotationURLCLassLoader that is not on the default path, make sure that that is checked at the end
+         //FIXME This needs revisiting/removing once the 
+         ArrayList noAnnotationURLClassLoaderPools = null;
+         String resource = url.toString();
+         for(Iterator it = AspectManager.getRegisteredCLs().values().iterator() ; it.hasNext() ; )
+         {
+            AOPClassPool candidate = (AOPClassPool)it.next();
+            if (candidate.isUnloadedClassLoader())
+            {
+               AspectManager.instance().unregisterClassLoader(candidate.getClassLoader());
+               continue;
+            }
+            
+            if (candidate.getClassLoader() instanceof RepositoryClassLoader)
+            {
+               //Sometimes the ClassLoader is a proxy for MBeanProxyExt?!
+               RepositoryClassLoader rcl = (RepositoryClassLoader)candidate.getClassLoader();
+               URL[] urls = rcl.getClasspath();
+               
+               for (int i = 0 ; i < urls.length ; i++)
+               {
+                  if (resource.indexOf(urls[i].getFile()) >= 0)
+                  {
+                     return candidate;
+                  }
+               }
+            }
+            //FIXME Remove once we have the JBoss 5 version of pool
+            else if (isInstanceOfNoAnnotationURLClassLoader(candidate.getClassLoader()))
+            {
+               if (noAnnotationURLClassLoaderPools == null)
+               {
+                  noAnnotationURLClassLoaderPools = new ArrayList(); 
+               }
+               noAnnotationURLClassLoaderPools.add(candidate);
+            }
+         }
+         
+         //FIXME Remove once we have the JBoss 5 version of pool
+         if (noAnnotationURLClassLoaderPools != null)
+         {
+            for (Iterator it = noAnnotationURLClassLoaderPools.iterator() ; it.hasNext() ; )
+            {
+               ClassPool pool = (ClassPool)it.next();
+               
+               try
+               {
+                  pool.get(classname);
+                  return pool;
+               }
+               catch(NotFoundException ignoreTryNext)
+               {
+               }
+            }
+         }
+      }
+
+      return AOPClassPool.createAOPClassPool(ClassPool.getDefault(), AOPClassPoolRepository.getInstance());
+   }
+   
+   /**
+    * NoAnnotationURLCLassLoader lives in different packages in JBoss 4 and 5
+    */
+   private boolean isInstanceOfNoAnnotationURLClassLoader(ClassLoader loader)
+   {
+      Class parent = loader.getClass();
+      while (parent != null)
+      {
+         if ("NoAnnotationURLClassLoader".equals(parent.getSimpleName()))
+         {
+            return true;
+         }
+         parent = parent.getSuperclass();
+      }
+      return false;
+   }
+}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/ScopedRepositoryClassLoaderHelper.java (from rev 66081, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/ScopedRepositoryClassLoaderHelper.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/ScopedRepositoryClassLoaderHelper.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/ScopedRepositoryClassLoaderHelper.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -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.asintegration.jboss4;
+
+import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
+import org.jboss.mx.loading.LoaderRepository;
+import org.jboss.mx.loading.RepositoryClassLoader;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @autor adrian at jboss.org
+ * @version $Revision$
+ */
+public class ScopedRepositoryClassLoaderHelper
+{
+   public static boolean isScopedClassLoader(ClassLoader loader)
+   {
+      boolean scoped = false;
+      if (loader instanceof RepositoryClassLoader)
+      {
+         LoaderRepository repository = ((RepositoryClassLoader)loader).getLoaderRepository();
+         if (repository instanceof HeirarchicalLoaderRepository3)
+         {
+            scoped = true;
+            HeirarchicalLoaderRepository3 hlr = (HeirarchicalLoaderRepository3)repository;
+            boolean parentFirst = hlr.getUseParentFirst();
+         }
+      }
+      return scoped;
+   }
+}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/SecurityActions.java (from rev 66081, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/SecurityActions.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/SecurityActions.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss4/SecurityActions.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -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.asintegration.jboss4;
+
+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: 1.1 $
+ */
+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);
+      }
+   }
+}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5 (from rev 66081, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp)

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/DefaultTranslator.java (from rev 66284, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/DefaultTranslator.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/DefaultTranslator.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/DefaultTranslator.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,68 @@
+/*
+* 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.asintegration.jboss5;
+
+import java.security.ProtectionDomain;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.util.loading.Translator;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class DefaultTranslator implements Translator
+{
+   AspectManager manager;
+   boolean translate;
+   
+   public DefaultTranslator(AspectManager manager)
+   {
+      this.manager = manager;
+   }
+
+   public void setTranslate(boolean translate)
+   {
+      this.translate = translate;
+   }
+   
+   public boolean getTranslate()
+   {
+      return translate;
+   }
+   
+   public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined,
+         ProtectionDomain protectionDomain, byte[] classfileBuffer) throws Exception
+   {
+      if (translate)
+      {
+         return manager.transform(loader, className, classBeingRedefined, protectionDomain, classfileBuffer);
+      }
+      return classfileBuffer;   
+   }
+
+   public void unregisterClassLoader(ClassLoader loader)
+   {
+      manager.unregisterClassLoader(loader);
+   }
+}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ExtraClassPoolFactoryParameters.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ExtraClassPoolFactoryParameters.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ExtraClassPoolFactoryParameters.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,53 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.util.Map;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ExtraClassPoolFactoryParameters
-{
-   /** A map of properties that can be used to configure the classpool factories further */
-   private static ThreadLocal<Map> properties = new ThreadLocal<Map>();
-   
-   public static void pushThreadProperties(Map props)
-   {
-      properties.set(props);
-   }
-   
-   public static Map peekThreadProperties()
-   {
-      return properties.get();
-   }
-   
-   public static Map popThreadProperties()
-   {
-      Map props = properties.get();
-      properties.remove();
-      return props;
-   }
-
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPool.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPool.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,138 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.URL;
-import java.security.ProtectionDomain;
-
-import javassist.CannotCompileException;
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class JBoss5ClassPool extends AOPClassPool
-{
-   /**
-    * Used for dynamically created classes (see loadClass(String, byte[]), ClassLoader)
-    */
-   protected File tempdir = null;
-   protected URL tempURL = null;
-   // For loadClass tmpdir creation for UCL
-   protected final Object tmplock = new Object();
-   
-   protected JBoss5ClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, File tmp, URL tmpURL)
-   {
-      super(cl, src, repository);
-      tempdir = tmp;
-      tempURL = tmpURL;
-   }
-
-   protected JBoss5ClassPool(ClassPool src, ScopedClassPoolRepository repository)
-   {
-      super(src, repository);
-   }
-
-   public boolean isUnloadedClassLoader()
-   {
-      if (getClassLoader() instanceof RepositoryClassLoader)
-      {
-         RepositoryClassLoader rcl = (RepositoryClassLoader) getClassLoader();
-         return rcl.getLoaderRepository() == null;
-      }
-      return false;
-   }
-
-   public Class toClass(CtClass cc, ClassLoader loader, ProtectionDomain domain)
-   throws CannotCompileException
-   {
-      ClassLoader useLoader = getClassLoader() == null ? loader : getClassLoader(); 
-      return super.toClass(cc, useLoader, domain);
-//      lockInCache(cc);
-//      if (getClassLoader() == null || tempdir == null)
-//      {
-//         return super.toClass(cc, loader, domain);
-//      }
-//      Class dynClass = null;
-//      try
-//      {
-//         File classFile = null;
-//         String classFileName = getResourceName(cc.getName());
-//         // Write the clas file to the tmpdir
-//         synchronized (tmplock)
-//         {
-//            classFile = new File(tempdir, classFileName);
-//            File pkgDirs = classFile.getParentFile();
-//            pkgDirs.mkdirs();
-//            FileOutputStream stream = new FileOutputStream(classFile);
-//            stream.write(cc.toBytecode());
-//            stream.flush();
-//            stream.close();
-//            classFile.deleteOnExit();
-//         }
-//         // We have to clear Blacklist caches or the class will never
-//         // be found
-//         //((UnifiedClassLoader)dcl).clearBlacklists();
-//         // To be backward compatible
-//         RepositoryClassLoader rcl = (RepositoryClassLoader) getClassLoader();
-//         rcl.clearClassBlackList();
-//         rcl.clearResourceBlackList();
-//
-//         // Now load the class through the cl
-//         dynClass = getClassLoader().loadClass(cc.getName());
-//      }
-//      catch (Exception ex)
-//      {
-//         ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName());
-//         cfe.initCause(ex);
-//         throw cfe;
-//      }
-//
-//      return dynClass;
-   }
-
-   protected boolean isLocalResource(String resourceName)
-   {
-      if (super.isLocalResource(resourceName))
-      {
-         return true;
-      }
-      
-      File file = new File(tempdir, resourceName);
-      if (file.exists())
-      {
-         return true;
-      }
-      
-      return false;
-   }
-
-}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPool.java (from rev 66284, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPool.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPool.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,242 @@
+/*
+* 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.asintegration.jboss5;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.security.ProtectionDomain;
+import java.util.Set;
+
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.aop.classpool.AOPClassPool;
+import org.jboss.classloader.spi.base.BaseClassLoader;
+import org.jboss.mx.loading.RepositoryClassLoader;
+import org.jboss.virtual.plugins.context.memory.MemoryContextFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBoss5ClassPool extends AOPClassPool
+{
+   protected URL tempURL = null;
+   // For loadClass tmpdir creation for UCL
+   protected final Object tmplock = new Object();
+   
+   protected JBoss5ClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, URL tmpURL)
+   {
+      super(cl, src, repository);
+      tempURL = tmpURL;
+   }
+
+   protected JBoss5ClassPool(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      super(src, repository);
+   }
+
+   public boolean isUnloadedClassLoader()
+   {
+      if (getClassLoader() instanceof RepositoryClassLoader)
+      {
+         RepositoryClassLoader rcl = (RepositoryClassLoader) getClassLoader();
+         return rcl.getLoaderRepository() == null;
+      }
+      return false;
+   }
+
+   
+   public Class toClass(CtClass cc, ClassLoader loader, ProtectionDomain domain) throws CannotCompileException
+   {
+      lockInCache(cc);
+      final ClassLoader myloader = getClassLoader();
+      if (myloader == null || tempURL == null)
+      {
+         return super.toClass(cc, loader, domain);
+      }
+      
+      try
+      {
+         String classFileName = getResourceName(cc.getName());
+         URL outputURL = new URL(tempURL.toString() + "/" + classFileName);
+         //Write the classfile to the temporary url
+         synchronized (tmplock)
+         {
+            ByteArrayOutputStream byteout = new ByteArrayOutputStream();
+            BufferedOutputStream out = new BufferedOutputStream(byteout);
+            out.write(cc.toBytecode());
+            out.flush();
+            out.close();
+            
+            byte[] classBytes = byteout.toByteArray();
+            MemoryContextFactory factory = MemoryContextFactory.getInstance();
+            factory.putFile(outputURL, classBytes);
+
+            clearCacheOnLoaderHack(myloader);
+            
+            Class clazz = myloader.loadClass(cc.getName());
+//System.out.println("====> created " + clazz.getName() + " on " + myloader + " loaded with " + clazz.getClassLoader());
+            return clazz;
+         }
+      }
+      catch(Exception e)
+      {
+       ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName());
+       cfe.initCause(e);
+       throw cfe;
+      }
+   }
+   
+   
+   private void clearCacheOnLoaderHack(final ClassLoader loader)
+   {
+      if (loader instanceof BaseClassLoader)
+      {
+         try
+         {
+            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+
+               public Object run() throws Exception
+               {
+                  Class clazz = loader.getClass();
+                  while (clazz != null && clazz != BaseClassLoader.class)
+                  {
+                     clazz = clazz.getSuperclass();
+                  }
+                  Field field = clazz.getDeclaredField("blackList");
+                  field.setAccessible(true);
+                  Set<String> set = (Set<String>)field.get(loader);
+                  set.clear();
+                  return null;
+               }});
+         }
+         catch (PrivilegedActionException e)
+         {
+            // AutoGenerated
+            throw new RuntimeException(e.getCause());
+         }
+      }
+   }
+   
+   public Class toClassOld(CtClass cc, ClassLoader loader, ProtectionDomain domain)
+   throws CannotCompileException
+   {
+      ClassLoader useLoader = getClassLoader() == null ? loader : getClassLoader();
+      localResources.put(getResourceName(cc.getName()), Boolean.TRUE);
+      System.out.println("===> Creating class " + cc.getName() + " on loader " + useLoader);
+      
+      if ("org.jboss.test.aop.scopedextender.Child_A2$Child_A2Advisor".equals(cc.getName()))
+      {
+         try
+         {
+            useLoader.loadClass("org.jboss.test.aop.scopedextender.Base_A1$Base_A1Advisor");
+            System.out.println("Got BaseAdvisor");
+         }
+         catch (ClassNotFoundException e)
+         {
+            System.out.println("Could not get BaseAdvisor");
+         }
+      }
+      
+      Class clazz = super.toClass(cc, useLoader, domain);
+      try
+      {
+         if ("org.jboss.test.aop.scopedextender.Base_A1$Base_A1Advisor".equals(cc.getName()))
+         {
+            Class clazz2 = useLoader.loadClass(cc.getName());
+            System.out.println("Found recently created class");
+         }
+      }
+      catch (ClassNotFoundException e)
+      {
+         System.out.println("Not found recently created class");
+      }
+      return clazz;
+//      lockInCache(cc);
+//      if (getClassLoader() == null || tempdir == null)
+//      {
+//         return super.toClass(cc, loader, domain);
+//      }
+//      Class dynClass = null;
+//      try
+//      {
+//         File classFile = null;
+//         String classFileName = getResourceName(cc.getName());
+//         // Write the clas file to the tmpdir
+//         synchronized (tmplock)
+//         {
+//            classFile = new File(tempdir, classFileName);
+//            File pkgDirs = classFile.getParentFile();
+//            pkgDirs.mkdirs();
+//            FileOutputStream stream = new FileOutputStream(classFile);
+//            stream.write(cc.toBytecode());
+//            stream.flush();
+//            stream.close();
+//            classFile.deleteOnExit();
+//         }
+//         // We have to clear Blacklist caches or the class will never
+//         // be found
+//         //((UnifiedClassLoader)dcl).clearBlacklists();
+//         // To be backward compatible
+//         RepositoryClassLoader rcl = (RepositoryClassLoader) getClassLoader();
+//         rcl.clearClassBlackList();
+//         rcl.clearResourceBlackList();
+//
+//         // Now load the class through the cl
+//         dynClass = getClassLoader().loadClass(cc.getName());
+//      }
+//      catch (Exception ex)
+//      {
+//         ClassFormatError cfe = new ClassFormatError("Failed to load dyn class: " + cc.getName());
+//         cfe.initCause(ex);
+//         throw cfe;
+//      }
+//
+//      return dynClass;
+   }
+
+//   protected boolean isLocalResource(String resourceName)
+//   {
+//      if (super.isLocalResource(resourceName))
+//      {
+//         return true;
+//      }
+//      
+//      File file = new File(tempdir, resourceName);
+//      if (file.exists())
+//      {
+//         return true;
+//      }
+//      
+//      return false;
+//   }
+
+}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPoolFactory.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPoolFactory.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPoolFactory.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,113 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.aop.deployers.temp;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Map;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.aop.deployment.JBossClassPool;
-import org.jboss.aop.deployment.JBossClassPoolFactory;
-import org.jboss.aop.deployment.ScopedJBossClassPool;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.base.BaseClassLoader;
-import org.jboss.deployers.plugins.classloading.Module;
-import org.jboss.mx.loading.RepositoryClassLoader;
-import javassist.ClassPool;
-import javassist.scopedpool.ScopedClassPool;
-import javassist.scopedpool.ScopedClassPoolFactory;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-/**
- * Comment
- *
- * @deprecated TODO JBAOP-107 Need a different version for the JBoss5 classloader 
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision: 64815 $
- **/
- at Deprecated
-public class JBoss5ClassPoolFactory extends JBossClassPoolFactory implements ScopedClassPoolFactory
-{
-   public JBoss5ClassPoolFactory(File tmpClassesDir) throws IOException
-   {
-      super(tmpClassesDir);
-   }
-   
-   static ThreadLocal<Boolean> reentry = new ThreadLocal<Boolean>();    
-   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
-   {
-      
-      ClassPool parent = getCreateParentClassPools(cl, src, repository);
-      if (cl instanceof BaseClassLoader)
-      {
-         Map props = ExtraClassPoolFactoryParameters.peekThreadProperties();
-         Module module = (Module)props.get(Module.class);
-            
-         File tempdir = getTempDirectory(cl);
-         
-         //Do we need a way to add urls to the repository
-         URL tmpCP;
-         try
-         {
-            tmpCP = createURLAndAddToLoader(cl, tempdir);
-         }
-         catch (IOException e)
-         {
-            throw new RuntimeException(e);
-         }
-         if (module != null && module.getParentDomain() != null)
-         {
-            //It is scoped
-            ClassLoaderSystem sys = ClassLoaderSystem.getInstance();
-            ClassLoaderDomain domain = sys.getDomain(module.getDomainName());
-            boolean parentFirst = module.getMetadata().isJ2seClassLoadingCompliance();
-            
-            return new ScopedJBoss5ClassPool(cl, parent, repository, tempdir, tmpCP, parentFirst, domain);
-         }
-         return new JBoss5ClassPool(cl, parent, repository, tempdir, tmpCP);
-      }
-      return new AOPClassPool(cl, parent, repository);
-   }
-
-   private URL createURLAndAddToLoader(ClassLoader cl, File tempdir) throws IOException
-   {
-      URL tmpURL = tempdir.toURL();
-      URL tmpCP = new URL(tmpURL, "?dynamic=true");
-
-      //FIXME IS this needed
-//      RepositoryClassLoader ucl = (RepositoryClassLoader) cl;
-//
-//      // We may be undeploying.
-//      if (ucl.getLoaderRepository() != null)
-//      {
-//         ucl.addURL(tmpCP);
-//      }
-      
-      return tmpCP;
-   }
-}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPoolFactory.java (from rev 66284, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5ClassPoolFactory.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPoolFactory.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5ClassPoolFactory.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -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.asintegration.jboss5;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+import org.jboss.aop.classpool.AOPClassPool;
+import org.jboss.aop.classpool.AbstractJBossClassPoolFactory;
+import org.jboss.aop.classpool.ExtraClassPoolFactoryParameters;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloader.spi.base.BaseClassLoader;
+import org.jboss.deployers.plugins.classloading.Module;
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPool;
+import javassist.scopedpool.ScopedClassPoolFactory;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author adrian at jboss.org
+ * @version $Revision: 64815 $
+ **/
+public class JBoss5ClassPoolFactory extends AbstractJBossClassPoolFactory implements ScopedClassPoolFactory
+{
+   static ThreadLocal<Boolean> reentry = new ThreadLocal<Boolean>();    
+   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      
+      ClassPool parent = getCreateParentClassPools(cl, src, repository);
+      if (cl instanceof BaseClassLoader)
+      {
+         Map props = ExtraClassPoolFactoryParameters.peekThreadProperties();
+         Module module = (Module)props.get(Module.class);
+            
+         if (module != null && module.getParentDomain() != null)
+         {
+            //It is scoped
+            ClassLoaderSystem sys = ClassLoaderSystem.getInstance();
+            ClassLoaderDomain domain = sys.getDomain(module.getDomainName());
+            boolean parentFirst = module.getMetadata().isJ2seClassLoadingCompliance();
+            
+            return new ScopedJBoss5ClassPool(cl, parent, repository, getTempURL(module), parentFirst, domain);
+         }
+         return new JBoss5ClassPool(cl, parent, repository, getTempURL(module));
+      }
+      return new AOPClassPool(cl, parent, repository);
+   }
+   
+   private URL getTempURL(Module module)
+   {
+      try
+      {
+         URL tempUrl = module.getDynamicClassRoot();
+         return new URL(tempUrl,  "/classes");
+      }
+      catch (MalformedURLException e)
+      {
+         throw new RuntimeException(e);
+      } 
+   }
+}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5Integration.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5Integration.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5Integration.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,95 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.io.File;
-
-import javassist.ClassPool;
-import javassist.scopedpool.ScopedClassPool;
-import javassist.scopedpool.ScopedClassPoolFactory;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.aop.deployment.JBossIntegration;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class JBoss5Integration implements JBossIntegration, ScopedClassPoolFactory
-{
-   /** The delegate classpool factory */
-   private ScopedClassPoolFactory delegateClassPoolFactory;
-   private AOPClassLoaderScopingPolicy policy;
-   
-   public boolean isValidClassLoader(ClassLoader loader)
-   {
-      if (!(loader instanceof RepositoryClassLoader)) return false;
-      return ((RepositoryClassLoader) loader).getLoaderRepository() != null;
-   }
-
-   public void setScopingPolicy(AOPClassLoaderScopingPolicy policy)
-   {
-      this.policy = policy;
-   }
-   
-   public AOPClassLoaderScopingPolicy getScopingPolicy()
-   {
-      return policy;
-   }
-   
-   public AOPClassLoaderScopingPolicy createAOPClassLoaderScopingPolicy()
-   {
-      return policy;
-   }
-
-   public ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception
-   {
-      delegateClassPoolFactory = new JBoss5ClassPoolFactory(tmpDir);
-      return this;
-   }
-   
-   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
-   {
-      return delegateClassPoolFactory.create(cl, src, repository);
-   }
-
-   public ScopedClassPool create(ClassPool src, ScopedClassPoolRepository repository)
-   {
-      return delegateClassPoolFactory.create(src, repository);
-   }
-   
-   public void attachDeprecatedTranslator()
-   {
-      AspectManager mgr = AspectManager.instance();
-      ClassLoaderSystem.getInstance().setTranslator(mgr);
-   }
-
-   public void detachDeprecatedTranslator()
-   {
-      ClassLoaderSystem.getInstance().setTranslator(null);
-   }
-}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5Integration.java (from rev 66284, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5Integration.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5Integration.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/JBoss5Integration.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,118 @@
+/*
+* 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.asintegration.jboss5;
+
+import java.io.File;
+
+import javassist.ClassPool;
+import javassist.scopedpool.ScopedClassPool;
+import javassist.scopedpool.ScopedClassPoolFactory;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+import org.jboss.asintegration.JBossIntegration;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.mx.loading.RepositoryClassLoader;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBoss5Integration implements JBossIntegration, ScopedClassPoolFactory
+{
+   /** The delegate classpool factory */
+   private ScopedClassPoolFactory delegateClassPoolFactory;
+   private AOPClassLoaderScopingPolicy policy;
+   private AspectManager manager = AspectManager.getTopLevelAspectManager();
+   DefaultTranslator translator = new DefaultTranslator(manager);
+
+   NewClassLoaderDomainRegistry registry;
+   
+   public NewClassLoaderDomainRegistry getRegistry()
+   {
+      return registry;
+   }
+
+   public void setRegistry(NewClassLoaderDomainRegistry registry)
+   {
+      this.registry = registry;
+   }
+   
+   public void start()
+   {
+      ClassLoaderSystem.getInstance().setTranslator(translator);
+   }
+
+   public void stop()
+   {
+      ClassLoaderSystem.getInstance().setTranslator(null);
+   }
+   
+   public boolean isValidClassLoader(ClassLoader loader)
+   {
+      if (!(loader instanceof RepositoryClassLoader)) return false;
+      return ((RepositoryClassLoader) loader).getLoaderRepository() != null;
+   }
+
+   public void setScopingPolicy(AOPClassLoaderScopingPolicy policy)
+   {
+      this.policy = policy;
+   }
+   
+   public AOPClassLoaderScopingPolicy getScopingPolicy()
+   {
+      return policy;
+   }
+   
+   public AOPClassLoaderScopingPolicy createAOPClassLoaderScopingPolicy()
+   {
+      return policy;
+   }
+
+   public ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception
+   {
+      delegateClassPoolFactory = new JBoss5ClassPoolFactory();
+      return this;
+   }
+   
+   public ScopedClassPool create(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository)
+   {
+      return delegateClassPoolFactory.create(cl, src, repository);
+   }
+
+   public ScopedClassPool create(ClassPool src, ScopedClassPoolRepository repository)
+   {
+      return delegateClassPoolFactory.create(src, repository);
+   }
+   
+   public void attachDeprecatedTranslator()
+   {
+      translator.setTranslate(true);
+   }
+
+   public void detachDeprecatedTranslator()
+   {
+      translator.setTranslate(false);
+   }
+}

Modified: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/MetaDataClassLoaderScopingPolicy.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/MetaDataClassLoaderScopingPolicy.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/MetaDataClassLoaderScopingPolicy.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -19,7 +19,7 @@
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */ 
-package org.jboss.aop.deployers.temp;
+package org.jboss.asintegration.jboss5;
 
 import java.util.Map;
 import java.util.WeakHashMap;

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderDomainInitializer.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderDomainInitializer.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderDomainInitializer.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,36 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import org.jboss.aop.Domain;
-import org.jboss.deployers.plugins.classloading.Module;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public interface NewClassLoaderDomainInitializer
-{
-   Domain initScopedDomain(ClassLoader loader, Module module);
-   
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderDomainRegistry.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderDomainRegistry.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderDomainRegistry.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,92 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.lang.ref.WeakReference;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.jboss.aop.Domain;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.deployers.plugins.classloading.Module;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-class NewClassLoaderDomainRegistry
-{
-   final static ClassLoaderDomain domain = new ClassLoaderDomain("NOT_USED_PLACEHOLDER");
-   
-   /** classloader domains by their classloaders */
-   private Map<ClassLoader, WeakReference<ClassLoaderDomain>> classLoaderDomainsByLoader = new WeakHashMap<ClassLoader, WeakReference<ClassLoaderDomain>>();
-
-   /** aopDomains by classloader domain */
-   private Map<ClassLoaderDomain, ScopedNewClassLoaderDomain> aopDomainsByClassLoaderDomain = new WeakHashMap<ClassLoaderDomain, ScopedNewClassLoaderDomain>();
-
-   synchronized void initMapsForLoader(ClassLoader loader, Module module, ScopedNewClassLoaderDomain domain)
-   {
-      ClassLoaderSystem system = ClassLoaderSystem.getInstance();
-      
-      String domainName = module.getDomainName();
-      ClassLoaderDomain clDomain = system.getDomain(domainName);
-      classLoaderDomainsByLoader.put(loader, new WeakReference<ClassLoaderDomain>(clDomain));
-      
-      if (domain != null)
-      {
-         aopDomainsByClassLoaderDomain.put(clDomain, domain);
-      }
-   }
-
-   synchronized Domain getRegisteredDomain(ClassLoader cl)
-   {
-      ClassLoaderDomain clDomain = getClassLoaderDomainForLoader(cl);
-      if (clDomain != null)
-      {
-         return aopDomainsByClassLoaderDomain.get(clDomain);
-      }
-      return null;
-   }
-   
-   synchronized ClassLoaderDomain getClassLoaderDomainForLoader(ClassLoader cl)
-   {
-      WeakReference<ClassLoaderDomain> clDomainRef = classLoaderDomainsByLoader.get(cl);
-      if (clDomainRef != null)
-      {
-         return clDomainRef.get();
-      }
-      
-      ClassLoader parent = cl.getParent();
-      if (parent != null)
-      {
-         ClassLoaderDomain domain = getClassLoaderDomainForLoader(parent);
-         if (domain != null)
-         {
-            classLoaderDomainsByLoader.put(parent, new WeakReference<ClassLoaderDomain>(domain));
-            return domain;
-         }
-      }
-      return null;
-   }
-}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderDomainRegistry.java (from rev 66284, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderDomainRegistry.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderDomainRegistry.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderDomainRegistry.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,92 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.asintegration.jboss5;
+
+import java.lang.ref.WeakReference;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.jboss.aop.Domain;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.deployers.plugins.classloading.Module;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class NewClassLoaderDomainRegistry
+{
+   final static ClassLoaderDomain domain = new ClassLoaderDomain("NOT_USED_PLACEHOLDER");
+   
+   /** classloader domains by their classloaders */
+   private Map<ClassLoader, WeakReference<ClassLoaderDomain>> classLoaderDomainsByLoader = new WeakHashMap<ClassLoader, WeakReference<ClassLoaderDomain>>();
+
+   /** aopDomains by classloader domain */
+   private Map<ClassLoaderDomain, ScopedNewClassLoaderDomain> aopDomainsByClassLoaderDomain = new WeakHashMap<ClassLoaderDomain, ScopedNewClassLoaderDomain>();
+
+   synchronized void initMapsForLoader(ClassLoader loader, Module module, ScopedNewClassLoaderDomain domain)
+   {
+      ClassLoaderSystem system = ClassLoaderSystem.getInstance();
+      
+      String domainName = module.getDomainName();
+      ClassLoaderDomain clDomain = system.getDomain(domainName);
+      classLoaderDomainsByLoader.put(loader, new WeakReference<ClassLoaderDomain>(clDomain));
+      
+      if (domain != null)
+      {
+         aopDomainsByClassLoaderDomain.put(clDomain, domain);
+      }
+   }
+
+   synchronized Domain getRegisteredDomain(ClassLoader cl)
+   {
+      ClassLoaderDomain clDomain = getClassLoaderDomainForLoader(cl);
+      if (clDomain != null)
+      {
+         return aopDomainsByClassLoaderDomain.get(clDomain);
+      }
+      return null;
+   }
+   
+   synchronized ClassLoaderDomain getClassLoaderDomainForLoader(ClassLoader cl)
+   {
+      WeakReference<ClassLoaderDomain> clDomainRef = classLoaderDomainsByLoader.get(cl);
+      if (clDomainRef != null)
+      {
+         return clDomainRef.get();
+      }
+      
+      ClassLoader parent = cl.getParent();
+      if (parent != null)
+      {
+         ClassLoaderDomain domain = getClassLoaderDomainForLoader(parent);
+         if (domain != null)
+         {
+            classLoaderDomainsByLoader.put(parent, new WeakReference<ClassLoaderDomain>(domain));
+            return domain;
+         }
+      }
+      return null;
+   }
+}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderScopingPolicy.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderScopingPolicy.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderScopingPolicy.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,124 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.lang.ref.WeakReference;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.Domain;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.deployers.plugins.classloading.Module;
-import org.jboss.deployers.structure.spi.classloading.ClassLoaderMetaData;
-import org.jboss.logging.Logger;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class NewClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy, NewClassLoaderDomainInitializer
-{
-   static Logger log = Logger.getLogger(NewClassLoaderScopingPolicy.class);
-   NewClassLoaderDomainRegistry registry = new NewClassLoaderDomainRegistry();
-   
-   public Domain initScopedDomain(ClassLoader loader, Module module)
-   {
-      ScopedNewClassLoaderDomain scopedDomain = (ScopedNewClassLoaderDomain)registry.getRegisteredDomain(loader);
-      if (scopedDomain == null)
-      {
-         if (module.getParentDomain() != null/* && module.getParentDomain().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME)*/)
-         {
-            ClassLoaderSystem system = ClassLoaderSystem.getInstance();
-            String domainName = module.getDomainName();
-            ClassLoaderDomain domain = system.getDomain(domainName);
-   
-            ClassLoaderMetaData cmd = module.getMetadata();
-            boolean parentDelegation = cmd.isJ2seClassLoadingCompliance();
-            String name = String.valueOf(System.identityHashCode(loader));
-            
-            scopedDomain = new ScopedNewClassLoaderDomain(loader, name, parentDelegation, AspectManager.getTopLevelAspectManager(), false, domain, registry);
-         }
-   
-         registry.initMapsForLoader(loader, module, scopedDomain);
-         
-         //Need to pass some data through to the classpoolfactory here
-         Map properties = new HashMap();
-         //The module is needed by the JBoss5ClassPoolFactory, the legacy JBossClassPoolFactory will ignore this
-         properties.put(Module.class, module);
-         ExtraClassPoolFactoryParameters.pushThreadProperties(properties);
-         try
-         {
-            AspectManager.instance().registerClassLoader(loader); //Ends up in classpool factory create method
-         }
-         finally
-         {
-            ExtraClassPoolFactoryParameters.popThreadProperties();
-         }
-      }      
-      return scopedDomain;
-   }
-   
-   public Domain getDomain(ClassLoader classLoader, AspectManager parent)
-   {
-      //Check the stored domains
-      Domain domain = registry.getRegisteredDomain(classLoader);
-      if (domain != null)
-      {
-         return domain;
-      }
-      
-      return null;
-   }
-
-   public Domain getTopLevelDomain(AspectManager parent)
-   {
-      Thread.currentThread().getContextClassLoader();
-      return null;
-   }
-
-//   public boolean isScoped(Module module)
-//   {
-//      String domainName = module.getDomainName();
-//      ClassLoaderMetaData cmd = module.getMetadata();
-////      boolean parentDelegation = cmd.isJ2seClassLoadingCompliance();
-//      
-//      System.out.println("****** DomainName: " + domainName + " parentDomain: " + module.getParentDomain());
-//      
-//      
-//      //FIXME There seems to be no way to navigate the tree of domains
-//      
-//      if (module.getParentDomain() != null && module.getParentDomain().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME))
-//      {
-//         //Should probably check for more levels?
-//         return true;
-//      }
-//      return false;
-//   }
-
-
-}
-   
\ No newline at end of file

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderScopingPolicy.java (from rev 66284, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/NewClassLoaderScopingPolicy.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderScopingPolicy.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/NewClassLoaderScopingPolicy.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,134 @@
+/*
+* 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.asintegration.jboss5;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+import org.jboss.aop.classpool.ExtraClassPoolFactoryParameters;
+import org.jboss.aop.domain.NewClassLoaderDomainInitializer;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.deployers.plugins.classloading.Module;
+import org.jboss.deployers.structure.spi.classloading.ClassLoaderMetaData;
+import org.jboss.logging.Logger;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class NewClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy, NewClassLoaderDomainInitializer
+{
+   static Logger log = Logger.getLogger(NewClassLoaderScopingPolicy.class);
+   NewClassLoaderDomainRegistry registry;
+   
+   public NewClassLoaderDomainRegistry getRegistry()
+   {
+      return registry;
+   }
+
+   public void setRegistry(NewClassLoaderDomainRegistry registry)
+   {
+      this.registry = registry;
+   }
+
+   public Domain initScopedDomain(ClassLoader loader, Module module)
+   {
+      ScopedNewClassLoaderDomain scopedDomain = (ScopedNewClassLoaderDomain)registry.getRegisteredDomain(loader);
+      if (scopedDomain == null)
+      {
+         if (module.getParentDomain() != null/* && module.getParentDomain().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME)*/)
+         {
+            ClassLoaderSystem system = ClassLoaderSystem.getInstance();
+            String domainName = module.getDomainName();
+            ClassLoaderDomain domain = system.getDomain(domainName);
+   
+            ClassLoaderMetaData cmd = module.getMetadata();
+            boolean parentDelegation = cmd.isJ2seClassLoadingCompliance();
+            String name = String.valueOf(System.identityHashCode(loader));
+            
+            scopedDomain = new ScopedNewClassLoaderDomain(loader, name, parentDelegation, AspectManager.getTopLevelAspectManager(), false, domain, registry);
+         }
+   
+         registry.initMapsForLoader(loader, module, scopedDomain);
+         
+         //Need to pass some data through to the classpoolfactory here
+         Map properties = new HashMap();
+         //The module is needed by the JBoss5ClassPoolFactory, the legacy JBossClassPoolFactory will ignore this
+         properties.put(Module.class, module);
+         ExtraClassPoolFactoryParameters.pushThreadProperties(properties);
+         try
+         {
+            AspectManager.instance().registerClassLoader(loader); //Ends up in classpool factory create method
+         }
+         finally
+         {
+            ExtraClassPoolFactoryParameters.popThreadProperties();
+         }
+      }      
+      return scopedDomain;
+   }
+   
+   public Domain getDomain(ClassLoader classLoader, AspectManager parent)
+   {
+      //Check the stored domains
+      Domain domain = registry.getRegisteredDomain(classLoader);
+      if (domain != null)
+      {
+         return domain;
+      }
+      
+      return null;
+   }
+
+   public Domain getTopLevelDomain(AspectManager parent)
+   {
+      Thread.currentThread().getContextClassLoader();
+      return null;
+   }
+
+//   public boolean isScoped(Module module)
+//   {
+//      String domainName = module.getDomainName();
+//      ClassLoaderMetaData cmd = module.getMetadata();
+////      boolean parentDelegation = cmd.isJ2seClassLoadingCompliance();
+//      
+//      System.out.println("****** DomainName: " + domainName + " parentDomain: " + module.getParentDomain());
+//      
+//      
+//      //FIXME There seems to be no way to navigate the tree of domains
+//      
+//      if (module.getParentDomain() != null && module.getParentDomain().equals(ClassLoaderSystem.DEFAULT_DOMAIN_NAME))
+//      {
+//         //Should probably check for more levels?
+//         return true;
+//      }
+//      return false;
+//   }
+
+
+}
+   
\ No newline at end of file

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/RepositoryClassLoaderDomainIntializer.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/RepositoryClassLoaderDomainIntializer.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/RepositoryClassLoaderDomainIntializer.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,34 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import org.jboss.aop.Domain;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public interface RepositoryClassLoaderDomainIntializer
-{
-   Domain initScopedDomain(ClassLoader loader);
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/RepositoryClassLoaderScopingPolicy.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/RepositoryClassLoaderScopingPolicy.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/RepositoryClassLoaderScopingPolicy.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,158 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.Domain;
-import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
-import org.jboss.aop.classpool.AOPClassPoolRepository;
-import org.jboss.aop.deployment.ScopedRepositoryClassLoaderHelper;
-import org.jboss.aop.domain.ScopedRepositoryClassLoaderDomain;
-import org.jboss.logging.Logger;
-import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
-import org.jboss.mx.loading.LoaderRepository;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class RepositoryClassLoaderScopingPolicy implements AOPClassLoaderScopingPolicy, RepositoryClassLoaderDomainIntializer
-{
-   Logger log = Logger.getLogger(RepositoryClassLoaderScopingPolicy.class);
-   
-   /** A map of domains by loader repository, maintaned by the top level AspectManager */
-   private Map<Object, Domain> scopedClassLoaderDomains = new WeakHashMap<Object, Domain>();
-
-
-   public Domain initScopedDomain(ClassLoader loader)
-   {
-      Domain domain = getDomain(loader, AspectManager.getTopLevelAspectManager());
-      
-      AspectManager.instance().registerClassLoader(loader); //Ends up in classpool factory create method
-
-      return domain;
-   }
-
-   public synchronized Domain getDomain(ClassLoader classLoader, AspectManager parent)
-   {
-      ClassLoader scopedClassLoader = ifScopedDeploymentGetScopedParentUclForCL(classLoader);
-      if (scopedClassLoader != null)
-      {
-         Domain scopedManager = null;
-         synchronized (AOPClassPoolRepository.getInstance().getRegisteredCLs())
-         {
-            Object loaderRepository = getLoaderRepository(classLoader);
-            scopedManager = scopedClassLoaderDomains.get(loaderRepository);
-            
-            // FIXME: JBAOP-107 REMOVE THIS HACK
-            if (scopedManager != null && scopedManager.isValid() == false)
-            {
-               scopedClassLoaderDomains.remove(loaderRepository);
-               scopedManager = null;
-            }
-            
-            if (scopedManager == null)
-            {
-               scopedManager = getScopedClassLoaderDomain(scopedClassLoader, parent);
-               log.debug("Created domain " + scopedManager + " for scoped deployment on: " +
-                        classLoader + "; identifying scoped ucl: " + scopedClassLoader);
-               scopedManager.setInheritsBindings(true);
-               scopedManager.setInheritsDeclarations(true);
-               
-               scopedClassLoaderDomains.put(loaderRepository, scopedManager);
-            }
-            return scopedManager;
-         }
-      }
-      return null;
-   }
-
-   public Domain getTopLevelDomain(AspectManager parent)
-   {
-      ClassLoader classLoader = getTopLevelJBossClassLoader();
-      return getDomain(classLoader, parent);
-   }
-   
-//////////
-   
-   private ClassLoader ifScopedDeploymentGetScopedParentUclForCL(ClassLoader loader)
-   {
-      ClassLoader parent = loader;
-      //The web classloader will be a child of the unified classloader - find out if that is scoped
-      while (parent != null)
-      {
-         if (ScopedRepositoryClassLoaderHelper.isScopedClassLoader(parent))
-         {
-            return parent;
-         }
-         if (parent instanceof RepositoryClassLoader)
-         {
-            //We were a repository classloader, but not scoped - ignore the parents like a sulky teenager
-            return null;
-         }
-         parent = parent.getParent();
-      }
-      return null;
-   }
-   
-   private ClassLoader getTopLevelJBossClassLoader()
-   {
-      ClassLoader loader = Thread.currentThread().getContextClassLoader();
-      RepositoryClassLoader topRcl = null;
-      while (loader != null)
-      {
-         if (loader instanceof RepositoryClassLoader)
-         {
-            topRcl = (RepositoryClassLoader)loader;
-         }
-         loader = loader.getParent();
-      }
-      return topRcl;
-   }
-
-   private Domain getScopedClassLoaderDomain(ClassLoader cl, AspectManager parent)
-   {
-      boolean parentDelegation = true;
-      if (cl instanceof RepositoryClassLoader)
-      {
-         HeirarchicalLoaderRepository3 repository = (HeirarchicalLoaderRepository3)((RepositoryClassLoader)cl).getLoaderRepository();
-         parentDelegation = repository.getUseParentFirst();
-      }
-      String name = String.valueOf(System.identityHashCode(cl));
-      return new ScopedRepositoryClassLoaderDomain(cl, name, parentDelegation, parent, false);
-   }
-
-   private Object getLoaderRepository(ClassLoader loader)
-   {
-      ClassLoader cl = ifScopedDeploymentGetScopedParentUclForCL(loader);
-      if (cl != null)
-      {
-         return ((RepositoryClassLoader)cl).getLoaderRepository();
-      }
-      return null;
-   }
-}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedJBoss5ClassPool.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedJBoss5ClassPool.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedJBoss5ClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,284 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source.
-* Copyright 2006, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors. 
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-import java.io.File;
-import java.lang.ref.WeakReference;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import javassist.ClassPool;
-import javassist.CtClass;
-import javassist.NotFoundException;
-import javassist.scopedpool.ScopedClassPoolRepository;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.classpool.AOPClassPool;
-import org.jboss.aop.classpool.AOPClassPoolRepository;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.base.BaseClassLoader;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class ScopedJBoss5ClassPool extends JBoss5ClassPool
-{
-//   final static LoaderRepositoryUrlUtil LOADER_REPOSITORY_UTIL = new LoaderRepositoryUrlUtil();
-//   
-//   WeakReference repository = null;
-//   UrlInfo urlInfo;
-   ThreadLocal lastPool = new ThreadLocal();
-   WeakReference<ClassLoaderDomain> domainRef;
-
-   public ScopedJBoss5ClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, File tmp,
-         URL tmpURL, boolean parentFirst, ClassLoaderDomain domain)
-   {
-      super(cl, src, repository, tmp, tmpURL);
-      super.childFirstLookup = !parentFirst;
-      this.domainRef = new WeakReference(domain);
-   }
-
-   
-
-//   public ScopedJBossClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, File tmp, URL tmpURL)
-//   {
-//      super(cl, src, repository, tmp, tmpURL);
-//      
-//      boolean parentFirst = false;
-//      LoaderRepository loaderRepository = null;
-//      ClassLoader prnt = cl;
-//      while (prnt != null)
-//      {
-//         if (prnt instanceof RepositoryClassLoader)
-//         {
-//            loaderRepository = ((RepositoryClassLoader)prnt).getLoaderRepository();
-//            if (loaderRepository instanceof HeirarchicalLoaderRepository3)
-//            {
-//               parentFirst = ((HeirarchicalLoaderRepository3)loaderRepository).getUseParentFirst();
-//            }
-//            break;
-//         }
-//         prnt = SecurityActions.getParent(cl);
-//      }
-//      
-//      super.childFirstLookup = !parentFirst;
-//   }
-   
-
-//   private HeirarchicalLoaderRepository3 getRepository()
-//   {
-//      ClassLoader cl = getClassLoader0();
-//      if (cl != null)
-//      {
-//         return (HeirarchicalLoaderRepository3)((RepositoryClassLoader)cl).getLoaderRepository();
-//      }
-//      return null;
-//   }
-
-   private URL getResourceUrlForClass(String resourcename)
-   {
-//      HeirarchicalLoaderRepository3 repo = getRepository();
-//      return repo.getResource(resourcename, super.getClassLoader());
-      ClassLoaderDomain domain = domainRef.get();
-      return domain.getResource(resourcename);
-   }
-   
-   private boolean isMine(URL url)
-   {
-//      HeirarchicalLoaderRepository3 repo = getRepository();
-//      if (repo != null)
-//      {
-//         //The URL of the class loaded with my scoped classloader
-//         if (url != null)
-//         {
-//            urlInfo = LOADER_REPOSITORY_UTIL.getURLInfo(getRepository(), urlInfo);
-//            
-//            URL[] myUrls = urlInfo.getLocalUrls();
-//            String resource = url.toString();
-//            for (int i = 0 ; i < myUrls.length ; i++)
-//            {
-//               if (resource.indexOf(myUrls[i].toString()) >= 0)
-//               {
-//                  return true;
-//               }
-//            }
-//            return false;
-//         }
-//      }
-      return true;
-   }
-
-   public CtClass getCached(String classname)
-   {
-      if (classname == null)
-      {
-         return null;
-      }
-      if (isUnloadedClassLoader())
-      {
-         return null;
-      }
-
-      if (generatedClasses.get(classname) != null)
-      {
-         //It is a new class, and this callback is probably coming from the frozen check when creating a new nested class
-         return super.getCached(classname);
-      }
-      
-      //Is this from the scoped classloader itself of from the parent?
-      String resourcename = getResourceName(classname);
-      URL url = getResourceUrlForClass(resourcename);
-      boolean isMine = isMine(url);
-      
-      if (isMine)
-      {
-         if (super.childFirstLookup)
-         {
-            //Parent delegation is false, attempt to get this class out of ourselves
-            CtClass clazz = super.getCachedLocally(classname);
-            if (clazz == null)
-            {
-               clazz = createCtClass(classname, false);
-               if (clazz != null)
-               {
-                  lockInCache(clazz);
-               }
-            }
-            if (clazz != null)
-            {
-               return clazz;
-            }
-         }
-         return super.getCached(classname);
-      }
-      
-
-      try
-      {
-         ClassPool pool = getCorrectPoolForResource(classname, url);
-         if (pool != lastPool.get())
-         {
-            lastPool.set(pool);
-            return pool.get(classname);
-         }
-      }
-      catch (NotFoundException e)
-      {
-      }
-      catch(StackOverflowError e)
-      {
-         throw e;
-      }
-      finally
-      {
-         lastPool.set(null);
-      }
-
-      return null;
-   }
-   
-   private ClassPool getCorrectPoolForResource(String classname, URL url)
-   {
-      synchronized(AspectManager.getRegisteredCLs())
-      {
-         //JBoss 5 has an extra NoAnnotationURLCLassLoader that is not on the default path, make sure that that is checked at the end
-         //FIXME This needs revisiting/removing once the 
-         ArrayList noAnnotationURLClassLoaderPools = null;
-         String resource = url.toString();
-         for(Iterator it = AspectManager.getRegisteredCLs().values().iterator() ; it.hasNext() ; )
-         {
-            AOPClassPool candidate = (AOPClassPool)it.next();
-            if (candidate.isUnloadedClassLoader())
-            {
-               AspectManager.instance().unregisterClassLoader(candidate.getClassLoader());
-               continue;
-            }
-            
-            if (candidate.getClassLoader() instanceof BaseClassLoader)
-            {
-               //Sometimes the ClassLoader is a proxy for MBeanProxyExt?!
-               RepositoryClassLoader rcl = (RepositoryClassLoader)candidate.getClassLoader();
-               URL[] urls = rcl.getClasspath();
-               
-               for (int i = 0 ; i < urls.length ; i++)
-               {
-                  if (resource.indexOf(urls[i].getFile()) >= 0)
-                  {
-                     return candidate;
-                  }
-               }
-            }
-            //FIXME Remove once we have the JBoss 5 version of pool
-            else if (isInstanceOfNoAnnotationURLClassLoader(candidate.getClassLoader()))
-            {
-               if (noAnnotationURLClassLoaderPools == null)
-               {
-                  noAnnotationURLClassLoaderPools = new ArrayList(); 
-               }
-               noAnnotationURLClassLoaderPools.add(candidate);
-            }
-         }
-         
-         //FIXME Remove once we have the JBoss 5 version of pool
-         if (noAnnotationURLClassLoaderPools != null)
-         {
-            for (Iterator it = noAnnotationURLClassLoaderPools.iterator() ; it.hasNext() ; )
-            {
-               ClassPool pool = (ClassPool)it.next();
-               
-               try
-               {
-                  pool.get(classname);
-                  return pool;
-               }
-               catch(NotFoundException ignoreTryNext)
-               {
-               }
-            }
-         }
-      }
-
-      return AOPClassPool.createAOPClassPool(ClassPool.getDefault(), AOPClassPoolRepository.getInstance());
-   }
-   
-   /**
-    * NoAnnotationURLCLassLoader lives in different packages in JBoss 4 and 5
-    */
-   private boolean isInstanceOfNoAnnotationURLClassLoader(ClassLoader loader)
-   {
-      Class parent = loader.getClass();
-      while (parent != null)
-      {
-         if ("NoAnnotationURLClassLoader".equals(parent.getSimpleName()))
-         {
-            return true;
-         }
-         parent = parent.getSuperclass();
-      }
-      return false;
-   }
-   
-}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedJBoss5ClassPool.java (from rev 66284, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedJBoss5ClassPool.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedJBoss5ClassPool.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedJBoss5ClassPool.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,282 @@
+/*
+* 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.asintegration.jboss5;
+
+import java.io.File;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.NotFoundException;
+import javassist.scopedpool.ScopedClassPoolRepository;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.classpool.AOPClassPool;
+import org.jboss.aop.classpool.AOPClassPoolRepository;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.Loader;
+import org.jboss.classloader.spi.base.BaseClassLoader;
+import org.jboss.logging.Logger;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedJBoss5ClassPool extends JBoss5ClassPool
+{
+   Logger log = Logger.getLogger(ScopedJBoss5ClassPool.class);
+   
+   ThreadLocal<ClassPool> lastPool = new ThreadLocal<ClassPool>();
+   WeakReference<ClassLoaderDomain> domainRef;
+
+   public ScopedJBoss5ClassPool(ClassLoader cl, ClassPool src, ScopedClassPoolRepository repository, 
+         URL tmpURL, boolean parentFirst, ClassLoaderDomain domain)
+   {
+      super(cl, src, repository, tmpURL);
+      super.childFirstLookup = !parentFirst;
+      this.domainRef = new WeakReference<ClassLoaderDomain>(domain);
+   }
+
+   private URL getResourceUrlForClass(String resourcename)
+   {
+      ClassLoaderDomain domain = domainRef.get();
+      return domain.getResource(resourcename);
+   }
+
+   private boolean isMine(URL myURL, String resourceName)
+   {
+      if (myURL == null)
+      {
+         return false;
+      }
+      
+      ClassLoaderDomain domain = domainRef.get();
+      Loader parent = domain.getParent();
+      URL parentURL = parent.getResource(resourceName);
+      
+      if (parentURL == null)
+      {
+         return true;
+      }
+      
+      if (!myURL.equals(parentURL))
+      {
+         return true;
+      }
+      
+      return false;
+   }
+   
+   public CtClass getCached(String classname)
+   {
+      if (classname == null)
+      {
+         return null;
+      }
+      if (isUnloadedClassLoader())
+      {
+         return null;
+      }
+
+      if (generatedClasses.get(classname) != null)
+      {
+         //It is a new class, and this callback is probably coming from the frozen check when creating a new nested class
+         return super.getCached(classname);
+      }
+      
+      //Is this from the scoped classloader itself of from the parent?
+      String resourcename = getResourceName(classname);
+      URL url = getResourceUrlForClass(resourcename);
+      
+      if (isMine(url, resourcename))
+      {
+         if (super.childFirstLookup)
+         {
+            //Parent delegation is false, attempt to get this class out of ourselves
+            CtClass clazz = super.getCachedLocally(classname);
+            if (clazz == null)
+            {
+               clazz = createCtClass(classname, false);
+               if (clazz != null)
+               {
+                  lockInCache(clazz);
+               }
+            }
+            if (clazz != null)
+            {
+               return clazz;
+            }
+         }
+         return super.getCached(classname);
+      }
+      else if (url == null)
+      {
+         return super.getCached(classname);
+      }
+      
+
+      try
+      {
+         ClassPool pool = getCorrectPoolForResource(classname, resourcename, url);
+         if (pool != lastPool.get())
+         {
+            lastPool.set(pool);
+            return pool.get(classname);
+         }
+      }
+      catch (NotFoundException e)
+      {
+      }
+      catch(StackOverflowError e)
+      {
+         throw e;
+      }
+      finally
+      {
+         lastPool.set(null);
+      }
+
+      return null;
+   }
+   
+   private ClassPool getCorrectPoolForResource(String classname, String resourceName, URL url)
+   {
+      boolean trace = log.isTraceEnabled();
+      synchronized(AspectManager.getRegisteredCLs())
+      {
+         //JBoss 5 has an extra NoAnnotationURLCLassLoader that is not on the default path, make sure that that is checked at the end
+         //FIXME This needs revisiting/removing once the 
+         ArrayList<ClassPool> noAnnotationURLClassLoaderPools = null;
+         
+//         //EXTRA DEBUG STUFF
+//         if (classname.equals("org.jboss.test.aop.scopedextender.Base_A1"))
+//         {
+//            System.out.println("********** Looking for proper pool for Base_A1 - this pool " + this);
+//            boolean found = false;
+//            for(Iterator it = AspectManager.getRegisteredCLs().values().iterator() ; it.hasNext() ; )
+//            {
+//               AOPClassPool candidate = (AOPClassPool)it.next();
+//               if (candidate.isUnloadedClassLoader())
+//               {
+//                  System.out.println("Found something unloaded " + candidate);
+//                  continue;
+//               }
+//
+//               if (candidate.getClassLoader() instanceof BaseClassLoader)
+//               {
+//                  BaseClassLoader bcl = (BaseClassLoader)candidate.getClassLoader();
+//                  URL foundUrl = bcl.getResourceLocally(resourceName);
+//                  if (foundUrl != null)
+//                  {
+//                     System.out.println("=============> Found in " + bcl);
+//                     if (url.equals(foundUrl))
+//                     {
+//                        if (!found)
+//                        {
+//                           System.out.println("^^^ The one returned ^^^");
+//                           found = true;
+//                        }
+//                     }
+//                  }
+//               }
+//            }
+//         }         
+         
+         for(Iterator it = AspectManager.getRegisteredCLs().values().iterator() ; it.hasNext() ; )
+         {
+            AOPClassPool candidate = (AOPClassPool)it.next();
+            if (candidate.isUnloadedClassLoader())
+            {
+               AspectManager.instance().unregisterClassLoader(candidate.getClassLoader());
+               continue;
+            }
+            
+            if (candidate.getClassLoader() instanceof BaseClassLoader)
+            {
+               //Sometimes the ClassLoader is a proxy for MBeanProxyExt?!
+               BaseClassLoader bcl = (BaseClassLoader)candidate.getClassLoader();
+               URL foundUrl = bcl.getResourceLocally(resourceName);
+               if (trace)
+               {
+                  log.trace("Candidate classloader " + bcl + " has local resource " + foundUrl);
+               }
+               if (foundUrl != null)
+               {
+                  if (url.equals(foundUrl))
+                  {
+                     return candidate;
+                  }
+               }
+            }
+            //FIXME Remove once we have the JBoss 5 version of pool
+            else if (isInstanceOfNoAnnotationURLClassLoader(candidate.getClassLoader()))
+            {
+               if (noAnnotationURLClassLoaderPools == null)
+               {
+                  noAnnotationURLClassLoaderPools = new ArrayList<ClassPool>(); 
+               }
+               noAnnotationURLClassLoaderPools.add(candidate);
+            }
+         }
+         
+         //FIXME Remove once we have the JBoss 5 version of pool
+         if (noAnnotationURLClassLoaderPools != null)
+         {
+            for (ClassPool pool : noAnnotationURLClassLoaderPools)
+            {
+               try
+               {
+                  pool.get(classname);
+                  return pool;
+               }
+               catch(NotFoundException ignoreTryNext)
+               {
+               }
+            }
+         }
+      }
+
+      return AOPClassPool.createAOPClassPool(ClassPool.getDefault(), AOPClassPoolRepository.getInstance());
+   }
+   
+   /**
+    * NoAnnotationURLCLassLoader lives in different packages in JBoss 4 and 5
+    */
+   private boolean isInstanceOfNoAnnotationURLClassLoader(ClassLoader loader)
+   {
+      Class parent = loader.getClass();
+      while (parent != null)
+      {
+         if ("NoAnnotationURLClassLoader".equals(parent.getSimpleName()))
+         {
+            return true;
+         }
+         parent = parent.getSuperclass();
+      }
+      return false;
+   }
+   
+}

Deleted: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedNewClassLoaderDomain.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedNewClassLoaderDomain.java	2007-10-12 09:16:02 UTC (rev 66081)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedNewClassLoaderDomain.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -1,151 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.aop.deployers.temp;
-
-
-import java.lang.ref.WeakReference;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.advice.AspectDefinition;
-import org.jboss.aop.domain.ScopedClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
-import org.jboss.mx.loading.LoaderRepository;
-import org.jboss.mx.loading.RepositoryClassLoader;
-
-
-/**
- * A domain that is used for scoped classloaders with the new JBoss 5 classloaders 
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @author adrian at jboss.org
- * @version $Revision: 1.1 $
- */
-public class ScopedNewClassLoaderDomain extends ScopedClassLoaderDomain
-{
-   WeakReference<ClassLoaderDomain> classLoaderDomainRef;
-   NewClassLoaderDomainRegistry registry;
-   
-   public ScopedNewClassLoaderDomain(ClassLoader loader, String name, boolean parentDelegation, AspectManager manager, boolean parentFirst, 
-         ClassLoaderDomain classLoaderDomain, NewClassLoaderDomainRegistry registry)
-   {
-      super(loader, name, parentDelegation, manager, parentFirst);
-      classLoaderDomainRef = new WeakReference<ClassLoaderDomain>(classLoaderDomain);
-      this.registry = registry;
-   }
-
-   private ClassLoaderDomain getClassLoaderDomain()
-   {
-      if (classLoaderDomainRef != null)
-      {
-         return classLoaderDomainRef.get();
-      }
-      return null;
-   }
-   
-   // FIXME: JBAOP-107 REMOVE THIS HACK
-   public boolean isValid()
-   {
-      ClassLoader cl = getClassLoader();
-      if (cl == null)
-         return false;
-    
-      ClassLoaderDomain domain = getClassLoaderDomain();
-      if (domain == null)
-         return false;
-      
-      if (domain.hasClassLoaders())
-      {
-         return true;
-      }
-      
-      return false;
-//      return cl.getLoaderRepository() != null;
-   }
-
-   protected Object getPerVmAspectWithNoParentDelegation(String def)
-   {
-      Object aspect = myPerVMAspects.get(def);
-      if (aspect != null)
-      {
-         return aspect;
-      }
-
-      aspect = super.getSuperPerVmAspect(def);
-      if (aspect != null)
-      {
-         ClassLoaderDomain loadingDomain = getAspectRepository(aspect);
-//         LoaderRepository myRepository = getScopedRepository();
-         ClassLoaderDomain myDomain = getClassLoaderDomain();
-         
-         if (loadingDomain == myDomain)
-         {
-            //The parent does not load this class
-            myPerVMAspects.put(def, aspect);
-         }
-         else
-         {
-            //The class has been loaded by a parent domain, find out if we also have a copy
-            Class clazz = myDomain.loadClass(aspect.getClass().getName());
-            if (clazz == aspect.getClass())
-            {
-               notMyPerVMAspects.put(def, Boolean.TRUE);
-            }
-            else
-            {
-               //We have a different version of the class deployed
-               AspectDefinition aspectDefinition = getAspectDefinition(def);
-               //Override the classloader to create the aspect instance
-               aspect = createPerVmAspect(def, aspectDefinition, getClassLoader());
-               myPerVMAspects.put(def, aspect);
-            }
-         }
-      }
-      
-      return aspect;
-   }
-   
-   
-   
-   private ClassLoaderDomain getAspectRepository(Object aspect)
-   {
-      ClassLoader cl = aspect.getClass().getClassLoader();
-      ClassLoaderDomain domain = registry.getClassLoaderDomainForLoader(cl);
-      return domain;
-   }
-   
-//   private HeirarchicalLoaderRepository3 getScopedRepository()
-//   {
-//      ClassLoader classloader = getClassLoader();
-//      if (classloader == null)
-//         throw new IllegalStateException("ClassLoader no longer exists: " + classLoaderString);
-//      if (classloader instanceof RepositoryClassLoader == false)
-//         throw new IllegalStateException("ClassLoader is not an instanceof RepositoryClassLoader " + classLoaderString);
-//      RepositoryClassLoader repositoryClassLoader = (RepositoryClassLoader) classloader;
-//      LoaderRepository loaderRepository = repositoryClassLoader.getLoaderRepository();
-//      if (loaderRepository == null)
-//         throw new IllegalStateException("ClassLoader has been undeployed: " + classLoaderString);
-//      if (loaderRepository instanceof HeirarchicalLoaderRepository3 == false)
-//         throw new IllegalStateException("Repository " + loaderRepository + " for classlaoder " + classLoaderString + " is not an HeirarchicalLoaderRepository3");
-//      return (HeirarchicalLoaderRepository3) loaderRepository;
-//   }
-}

Copied: projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedNewClassLoaderDomain.java (from rev 66093, projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/ScopedNewClassLoaderDomain.java)
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedNewClassLoaderDomain.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/asintegration/jboss5/ScopedNewClassLoaderDomain.java	2007-10-19 15:34:41 UTC (rev 66289)
@@ -0,0 +1,154 @@
+/*
+* 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.asintegration.jboss5;
+
+
+import java.lang.ref.WeakReference;
+import java.net.URL;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.aop.domain.ScopedClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
+import org.jboss.mx.loading.LoaderRepository;
+import org.jboss.mx.loading.RepositoryClassLoader;
+
+
+/**
+ * A domain that is used for scoped classloaders with the new JBoss 5 classloaders 
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author adrian at jboss.org
+ * @version $Revision: 1.1 $
+ */
+public class ScopedNewClassLoaderDomain extends ScopedClassLoaderDomain
+{
+   WeakReference<ClassLoaderDomain> classLoaderDomainRef;
+   NewClassLoaderDomainRegistry registry;
+   
+   public ScopedNewClassLoaderDomain(ClassLoader loader, String name, boolean parentDelegation, AspectManager manager, boolean parentFirst, 
+         ClassLoaderDomain classLoaderDomain, NewClassLoaderDomainRegistry registry)
+   {
+      super(loader, name, parentDelegation, manager, parentFirst);
+      classLoaderDomainRef = new WeakReference<ClassLoaderDomain>(classLoaderDomain);
+      this.registry = registry;
+   }
+
+   private ClassLoaderDomain getClassLoaderDomain()
+   {
+      if (classLoaderDomainRef != null)
+      {
+         return classLoaderDomainRef.get();
+      }
+      return null;
+   }
+   
+   // FIXME: JBAOP-107 REMOVE THIS HACK
+   public boolean isValid()
+   {
+      ClassLoader cl = getClassLoader();
+      if (cl == null)
+         return false;
+    
+      ClassLoaderDomain domain = getClassLoaderDomain();
+      if (domain == null)
+         return false;
+      
+      if (domain.hasClassLoaders())
+      {
+         return true;
+      }
+      
+      return false;
+//      return cl.getLoaderRepository() != null;
+   }
+
+   protected Object getPerVmAspectWithNoParentDelegation(String def)
+   {
+      Object aspect = myPerVMAspects.get(def);
+      if (aspect != null)
+      {
+         return aspect;
+      }
+
+      aspect = super.getSuperPerVmAspect(def);
+      if (aspect != null)
+      {
+         Class superAspectClass = aspect.getClass();
+         ClassLoaderDomain loadingDomain = getAspectRepository(superAspectClass);
+
+         ClassLoaderDomain myDomain = getClassLoaderDomain();
+         
+         if (loadingDomain == myDomain)
+         {
+            //The parent does not load this class
+            myPerVMAspects.put(def, aspect);
+         }
+         else
+         {
+            //The class has been loaded by a parent domain, find out if we also have a copy
+            Class myAspectClazz = myDomain.loadClass(aspect.getClass().getName());
+            
+            if (myAspectClazz == superAspectClass)
+            {
+               notMyPerVMAspects.put(def, Boolean.TRUE);
+            }
+            else
+            {
+               //We have a different version of the class deployed
+               AspectDefinition aspectDefinition = getAspectDefinition(def);
+               //Override the classloader to create the aspect instance
+               aspect = createPerVmAspect(def, aspectDefinition, getClassLoader());
+               myPerVMAspects.put(def, aspect);
+            }
+         }
+      }
+      
+      return aspect;
+   }
+   
+   
+   
+   private ClassLoaderDomain getAspectRepository(Class clazz)
+   {
+      ClassLoader cl = clazz.getClassLoader();
+      ClassLoaderDomain domain = registry.getClassLoaderDomainForLoader(cl);
+      return domain;
+   }
+   
+//   private HeirarchicalLoaderRepository3 getScopedRepository()
+//   {
+//      ClassLoader classloader = getClassLoader();
+//      if (classloader == null)
+//         throw new IllegalStateException("ClassLoader no longer exists: " + classLoaderString);
+//      if (classloader instanceof RepositoryClassLoader == false)
+//         throw new IllegalStateException("ClassLoader is not an instanceof RepositoryClassLoader " + classLoaderString);
+//      RepositoryClassLoader repositoryClassLoader = (RepositoryClassLoader) classloader;
+//      LoaderRepository loaderRepository = repositoryClassLoader.getLoaderRepository();
+//      if (loaderRepository == null)
+//         throw new IllegalStateException("ClassLoader has been undeployed: " + classLoaderString);
+//      if (loaderRepository instanceof HeirarchicalLoaderRepository3 == false)
+//         throw new IllegalStateException("Repository " + loaderRepository + " for classlaoder " + classLoaderString + " is not an HeirarchicalLoaderRepository3");
+//      return (HeirarchicalLoaderRepository3) loaderRepository;
+//   }
+}




More information about the jboss-cvs-commits mailing list