[jboss-cvs] JBossAS SVN: r65528 - in projects/aop/trunk: aop/src/main/org/jboss/aop/instrument and 14 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 21 07:53:30 EDT 2007


Author: kabir.khan at jboss.com
Date: 2007-09-21 07:53:30 -0400 (Fri, 21 Sep 2007)
New Revision: 65528

Added:
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/
   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/domain/
   projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/
   projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/
   projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForDomain-1-aop.xml
   projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForMainManager-1-aop.xml
   projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomains-1-aop.xml
   projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomains-2-aop.xml
   projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/
   projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/support/
   projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/support/TestIntercepted.java
   projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/support/TestInterceptor.java
   projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/
   projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/Helper.java
   projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForDomainUnitTestCase.java
   projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForMainManagerUnitTestCase.java
   projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomainsUnitTestCase.java
   projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainWovenForDomainUnitTestCase.java
Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/AOPTestDelegate.java
   projects/aop/trunk/asintegration/.classpath
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AspectDeployer.java
   projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectDeployer.java
   projects/aop/trunk/asintegration/src/tests/org/jboss/aop/integration/junit/AOPIntegrationTest.java
   projects/aop/trunk/asintegration/src/tests/org/jboss/aop/integration/junit/AOPIntegrationTestDelegate.java
Log:


Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2007-09-21 10:42:21 UTC (rev 65527)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectManager.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -111,12 +111,6 @@
    /** Advisors registered with this manager/domain */
    protected final WeakHashMap advisors = new WeakHashMap();
    
-   /** A map of domains by loader repository, maintaned by the top level AspectManager */
-   // This seems to be maintained but not used, to avoid garbage collection of domains?
-   // I moved it to the AOPClassLoaderScopingPolicy for now 
-   @Deprecated 
-   protected WeakHashMap scopedClassLoaderDomains = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
-
    /** A map of domains by class, maintaned by the top level AspectManager */
    protected WeakHashMap subDomainsPerClass = UnmodifiableEmptyCollections.EMPTY_WEAK_HASHMAP;
    
@@ -731,18 +725,9 @@
       AOPClassPoolRepository.getInstance().registerClass(clazz);
    }
 
-   @Deprecated
-   // This is never invoked, it always referenced the scopedClassLoaderDomains directly?
-   protected Map getScopedClassLoaderDomains()
-   {
-      return scopedClassLoaderDomains;
-   }
-
    public void unregisterClassLoader(ClassLoader cl)
    {
       AOPClassPoolRepository.getInstance().unregisterClassLoader(cl);
-      //top-level only
-//      getScopedClassLoaderDomains().remove(cl);
    }
 
    public ArrayList getExclude()

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java	2007-09-21 10:42:21 UTC (rev 65527)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/AspectXmlLoader.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -1240,9 +1240,13 @@
 
    public static void deployXML(URL url) throws Exception
    {
-      deployXML(url, null);
+      deployXML(url, null, AspectManager.instance());
    }
 
+   /**
+    * @deprecated Should pass in AspectManager explicitly
+    */
+   @Deprecated
    public static void deployXML(URL url, ClassLoader cl) throws Exception
    {
       XmlLoader loader = null;
@@ -1255,12 +1259,31 @@
          loader = factory.create();
       }
       loader.setClassLoader(cl);
-      loader.deploy(url, AspectManager.instance());
-
+      deployXML(url, cl, AspectManager.instance());
    }
+   
+   public static void deployXML(URL url, ClassLoader cl, AspectManager manager) throws Exception
+   {
+      XmlLoader loader = null;
+      if (factory == null)
+      {
+         loader = new AspectXmlLoader();
+      }
+      else
+      {
+         loader = factory.create();
+      }
+      loader.setClassLoader(cl);
+      loader.deploy(url, manager);
+   }
 
    public static void undeployXML(URL url) throws Exception
    {
+      undeployXML(url, AspectManager.instance());
+   }
+
+   public static void undeployXML(URL url, AspectManager manager) throws Exception
+   {
       XmlLoader loader = null;
       if (factory == null)
       {
@@ -1270,7 +1293,7 @@
       {
          loader = factory.create();
       }
-      loader.undeploy(url, AspectManager.instance());
+      loader.undeploy(url, manager);
    }
 
    private static class Resolver implements EntityResolver

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java	2007-09-21 10:42:21 UTC (rev 65527)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Domain.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -940,13 +940,6 @@
       return parent.getInterceptionMarkers();
    }
 
-
-   @Deprecated
-   protected Map getScopedClassLoaderDomains()
-   {
-      return parent.getScopedClassLoaderDomains();
-   }
-
    /** Managed by the top-level aspect manager */
    protected Map getSubDomainsPerClass()
    {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java	2007-09-21 10:42:21 UTC (rev 65527)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/JoinPointGenerator.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -301,6 +301,12 @@
       }
       catch (Throwable e)
       {
+//         for (int i = 0 ; i < info.getInterceptors().length ; i++)
+//         {
+//            GeneratedAdvisorInterceptor icptr = (GeneratedAdvisorInterceptor)info.getInterceptors()[i]; 
+//            System.out.println(" - - - - - - - - - - - - - ");
+//            System.out.println(icptr.getName());
+//         }
          throw new RuntimeException("Error generating joinpoint class for joinpoint " + info, e);
       }
    }
@@ -321,6 +327,11 @@
       catch (Exception e)
       {
          StringBuffer sb = new StringBuffer();
+//         Class advisedClass = info.getClazz();
+//         if (advisedClass != null)
+//         {
+//            sb.append("Target: " + advisedClass.getName() + " " + advisedClass.getClassLoader() + "\n");
+//         }
          throw new RuntimeException(debugClass(sb, clazz).toString(), e);
       }
       

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/AOPTestDelegate.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/AOPTestDelegate.java	2007-09-21 10:42:21 UTC (rev 65527)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/AOPTestDelegate.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -22,6 +22,8 @@
 package org.jboss.test.aop;
 
 import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Properties;
 
 import org.jboss.aop.AspectXmlLoader;
@@ -41,7 +43,14 @@
    {
       // FIXME AOPTestDelegate constructor
       super(clazz);
-      systemProps = (Properties)System.getProperties().clone();
+      
+      systemProps = AccessController.doPrivileged(new PrivilegedAction<Properties>() 
+      {
+         public Properties run()
+         {
+            return (Properties)System.getProperties().clone();
+         }
+      });
    }
 
    public Properties getSystemProperties()

Modified: projects/aop/trunk/asintegration/.classpath
===================================================================
--- projects/aop/trunk/asintegration/.classpath	2007-09-21 10:42:21 UTC (rev 65527)
+++ projects/aop/trunk/asintegration/.classpath	2007-09-21 11:53:30 UTC (rev 65528)
@@ -21,6 +21,8 @@
 	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-classloader.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-classloader-sources.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-log4j/lib/jboss-logging-log4j.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/apache-log4j/lib/log4j.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-container-metadata-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-container-metadata-spi.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-container-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-deployers-client-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-container-metadata.jar"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Modified: projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AspectDeployer.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AspectDeployer.java	2007-09-21 10:42:21 UTC (rev 65527)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AspectDeployer.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -34,10 +34,14 @@
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.AspectXmlLoader;
 import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+import org.jboss.classloader.spi.base.BaseClassLoader;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
 import org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer;
 import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.MutableMetaData;
+import org.jboss.metadata.spi.scope.ScopeKey;
 import org.jboss.virtual.VirtualFile;
 import org.jboss.virtual.VirtualFileFilter;
 import org.jboss.virtual.VisitorAttributes;
@@ -100,6 +104,8 @@
    
    public void deploy(VFSDeploymentUnit unit) throws DeploymentException
    {
+//      dumpDeploymentUnitStuffForTesting(unit);
+      
       List<VirtualFile> files = unit.getMetaDataFiles(null, AOP_DD_SUFFIX);
 
       if (isAopArchiveOrFolder(unit))
@@ -113,6 +119,25 @@
       }
    }
    
+//   public void dumpDeploymentUnitStuffForTesting(VFSDeploymentUnit unit)
+//   {
+//      ScopeKey scope = unit.getScope();
+//      ScopeKey mutable = unit.getMutableScope();
+//      
+//      MetaData metaData = unit.getMetaData();
+//      MutableMetaData mutableMetaData = unit.getMutableMetaData();
+//      System.out.println("====> SCOPE: " + scope + "\n\tMUTABLE_SCOPE: " + mutable + "\n\tMETADATA: " + metaData + "\n\tMUTABLE_METADATA: " + mutableMetaData);
+//      
+//      //Need to get information about the classloader
+//      ClassLoader loader = unit.getClassLoader();
+//      if (loader instanceof BaseClassLoader)
+//      {
+//         BaseClassLoader bcl = (BaseClassLoader)loader;
+////         bcl.get
+//      }
+//      
+//   }
+   
    public void undeploy(VFSDeploymentUnit unit)
    {
       List<VirtualFile> files = unit.getMetaDataFiles(null, AOP_DD_SUFFIX);

Added: 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	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/JBoss5Integration.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,62 @@
+/*
+* 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.scopedpool.ScopedClassPoolFactory;
+
+import org.jboss.aop.classpool.AOPClassLoaderScopingPolicy;
+import org.jboss.aop.deployment.JBossIntegration;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBoss5Integration implements JBossIntegration
+{
+
+   public void attachDeprecatedTranslator()
+   {
+   }
+
+   public AOPClassLoaderScopingPolicy createAOPClassLoaderScopingPolicy()
+   {
+      return null;
+   }
+
+   public ScopedClassPoolFactory createScopedClassPoolFactory(File tmpDir) throws Exception
+   {
+      return null;
+   }
+
+   public void detachDeprecatedTranslator()
+   {
+   }
+
+   public boolean isValidClassLoader(ClassLoader loader)
+   {
+      return false;
+   }
+
+}

Added: 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	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/temp/MetaDataClassLoaderScopingPolicy.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,101 @@
+/*
+* 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);
+   }
+}

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-09-21 10:42:21 UTC (rev 65527)
+++ projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AspectDeployer.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -165,16 +165,16 @@
          }
          
          Thread.currentThread().setContextClassLoader(di.ucl);
+         AspectManager manager = (scl != null) ? AspectManager.instance(scl) : AspectManager.instance();
          if (!di.isXML)
          {
             Iterator it = ArchiveBrowser.getBrowser(di.localUrl, new ClassFileFilter());
-            AspectManager manager = (scl != null) ? AspectManager.instance(scl) : AspectManager.instance();
             AspectAnnotationLoader loader = new AspectAnnotationLoader(manager);
             loader.setClassLoader(scl);
             loader.deployInputStreamIterator(it);
          }
          
-         AspectXmlLoader.deployXML(docURL, scl);
+         AspectXmlLoader.deployXML(docURL, scl, manager);
          Notification msg = new Notification("AOP Deploy", this, getNextNotificationSequenceNumber());
          sendNotification(msg);
          log.debug("Deployed AOP: " + di.url);

Added: projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForDomain-1-aop.xml
===================================================================
--- projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForDomain-1-aop.xml	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForDomain-1-aop.xml	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop>
+
+   <interceptor class="org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor">
+      <attribute name="property">First</attribute>
+   </interceptor>
+
+   <bind pointcut="execution(* org.jboss.test.aop.integration.metadatadomain.support.TestIntercepted->*(..))">
+      <interceptor-ref name="org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor"/>
+   </bind>
+   
+</aop>
\ No newline at end of file

Added: projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForMainManager-1-aop.xml
===================================================================
--- projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForMainManager-1-aop.xml	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForMainManager-1-aop.xml	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop>
+
+   <interceptor class="org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor">
+      <attribute name="property">First</attribute>
+   </interceptor>
+
+   <bind pointcut="execution(* org.jboss.test.aop.integration.metadatadomain.support.TestIntercepted->*(..))">
+      <interceptor-ref name="org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor"/>
+   </bind>
+   
+</aop>
\ No newline at end of file

Added: projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomains-1-aop.xml
===================================================================
--- projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomains-1-aop.xml	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomains-1-aop.xml	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop>
+
+   <interceptor class="org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor">
+      <attribute name="property">First</attribute>
+   </interceptor>
+
+   <bind pointcut="execution(* org.jboss.test.aop.integration.metadatadomain.support.TestIntercepted->*(..))">
+      <interceptor-ref name="org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor"/>
+   </bind>
+   
+</aop>
\ No newline at end of file

Added: projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomains-2-aop.xml
===================================================================
--- projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomains-2-aop.xml	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/resources/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomains-2-aop.xml	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<aop>
+
+   <interceptor class="org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor">
+      <attribute name="property">Second</attribute>
+   </interceptor>
+
+   <bind pointcut="execution(* org.jboss.test.aop.integration.metadatadomain.support.TestIntercepted->*(..))">
+      <interceptor-ref name="org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor"/>
+   </bind>
+   
+</aop>
\ No newline at end of file

Modified: projects/aop/trunk/asintegration/src/tests/org/jboss/aop/integration/junit/AOPIntegrationTest.java
===================================================================
--- projects/aop/trunk/asintegration/src/tests/org/jboss/aop/integration/junit/AOPIntegrationTest.java	2007-09-21 10:42:21 UTC (rev 65527)
+++ projects/aop/trunk/asintegration/src/tests/org/jboss/aop/integration/junit/AOPIntegrationTest.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -26,6 +26,7 @@
 
 import junit.framework.Test;
 
+import org.jboss.aop.AspectManager;
 import org.jboss.classloader.plugins.filter.PatternClassFilter;
 import org.jboss.classloader.spi.ClassLoaderDomain;
 import org.jboss.classloader.spi.ClassLoaderPolicy;
@@ -59,7 +60,7 @@
    public static Test suite(Class<?> clazz, boolean importAll, Class<?>... packages)
    {
       helper = new IsolatedClassLoaderTestHelper();
-      ClassFilter aopFilter = new PatternClassFilter(new String[] { "org\\.jboss\\.aop\\..+"}, new String[] { "org/jboss/aop/.+" });
+      ClassFilter aopFilter = new PatternClassFilter(new String[] { "org\\.jboss\\.aop\\..+", "org\\.jboss\\.metadata\\..+"}, new String[] { "org/jboss/aop/.+", "org/jboss/metadata/.+"});
       Class<?> newClass = helper.initializeClassLoader(clazz, aopFilter, importAll, packages);
       return AbstractTestCaseWithSetup.suite(newClass);
    }
@@ -104,6 +105,20 @@
    }
 
    /**
+    * Deploy the aop config
+    * 
+    * @param suffix the suffix
+    * @param classLoader the classloader
+    * @param manager the AspectManager/Domain to deploy into
+    * @return the url
+    * @throws Exception for any error
+    */
+   protected URL deploy(String suffix, ClassLoader classLoader, AspectManager manager) throws Exception
+   {
+      return getAOPDelegate().deploy(suffix, classLoader, manager);
+   }
+
+   /**
     * Undeploy the aop config
     * 
     * @param url the url
@@ -114,6 +129,17 @@
    }
    
    /**
+    * Undeploy the aop config
+    * 
+    * @param url the url
+    * @param manager the AspectManager/Domain to undeploy from
+    */
+   protected void undeploy(URL url, AspectManager manager)
+   {
+      getAOPDelegate().undeploy(url, manager);
+   }
+   
+   /**
     * Create a classloader
     * 
     * It exports everything

Modified: projects/aop/trunk/asintegration/src/tests/org/jboss/aop/integration/junit/AOPIntegrationTestDelegate.java
===================================================================
--- projects/aop/trunk/asintegration/src/tests/org/jboss/aop/integration/junit/AOPIntegrationTestDelegate.java	2007-09-21 10:42:21 UTC (rev 65527)
+++ projects/aop/trunk/asintegration/src/tests/org/jboss/aop/integration/junit/AOPIntegrationTestDelegate.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -22,7 +22,6 @@
 package org.jboss.aop.integration.junit;
 
 import java.net.URL;
-import java.util.Iterator;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.jboss.aop.AspectManager;
@@ -39,21 +38,26 @@
 public class AOPIntegrationTestDelegate extends AbstractTestDelegate
 {
    /** The deployed urls */
-   private static final CopyOnWriteArrayList<URL> urls = new CopyOnWriteArrayList<URL>();
+   private static final CopyOnWriteArrayList<ManagerURL> urls = new CopyOnWriteArrayList<ManagerURL>();
    
    /** The classloader system */
    private ClassLoaderSystem system;
    
+   /** Whether or not we should weave loaded classes */
+   boolean weaveClasses;
+   
    /**
     * Create a new AOPTestDelegate.
     * 
     * @param clazz the test class
+    * @param weaveClasses Whether or not we should weave loaded classes
     * @param system the classloader system
     */
    public AOPIntegrationTestDelegate(Class clazz, boolean weaveClasses, ClassLoaderSystem system) 
    {
       super(clazz);
       this.system = system;
+      this.weaveClasses = weaveClasses;
    }
 
    public void setUp() throws Exception
@@ -63,7 +67,10 @@
       
       AspectManager manager = AspectManager.instance();
       
-      system.setTranslator(manager);
+      if (weaveClasses)
+      {
+         system.setTranslator(manager);
+      }
       try
       {
          deploy(clazz.getClassLoader());
@@ -124,6 +131,20 @@
     */
    protected URL deploy(String suffix, ClassLoader classLoader) throws Exception
    {
+      return deploy(suffix, classLoader, null);
+   }
+   
+   /**
+    * Deploy the aop config
+    * 
+    * @param suffix the suffix
+    * @param classLoader the classloader
+    * @param manager the aspectmanager/domain to deploy into
+    * @return the url
+    * @throws Exception for any error
+    */
+   protected URL deploy(String suffix, ClassLoader classLoader, AspectManager manager) throws Exception
+   {
       String testName = clazz.getName();
       int index = testName.indexOf("UnitTestCase");
       if (index != -1)
@@ -131,7 +152,16 @@
       testName = testName.replace('.', '/') + "-" + suffix + "-aop.xml";
       URL url = clazz.getClassLoader().getResource(testName);
       if (url != null)
-         deploy(url, classLoader);
+      {
+         if (manager == null)
+         {
+            deploy(url, classLoader);
+         }
+         else
+         {
+            deploy(url, classLoader, manager);
+         }
+      }
       else
          throw new RuntimeException(testName + " not found");
       return url;
@@ -139,10 +169,9 @@
    
    protected void undeploy()
    {
-      for (Iterator i = urls.iterator(); i.hasNext();)
+      for (ManagerURL url : urls)
       {
-         URL url = (URL) i.next();
-         undeploy(url);
+         undeploy(url.getUrl(), url.getManager());
       }
    }
    
@@ -155,10 +184,24 @@
     */
    protected void deploy(URL url, ClassLoader classLoader) throws Exception
    {
+      deploy(url, classLoader, AspectManager.instance());
+   }
+   
+   /**
+    * Deploy the aop config
+    *
+    * @param url the url
+    * @param classLoader
+    * @throws Exception for any error
+    */
+   protected void deploy(URL url, ClassLoader classLoader, AspectManager manager) throws Exception
+   {
       log.debug("Deploying " + url);
-      urls.add(url);
-      AspectXmlLoader.deployXML(url, classLoader, AspectManager.instance());
+      urls.add(new ManagerURL(url, manager));
+      AspectXmlLoader.deployXML(url, classLoader, manager);
    }
+   
+   
 
    /**
     * Undeploy the aop config
@@ -167,15 +210,88 @@
     */
    protected void undeploy(URL url)
    {
+      undeploy(url, AspectManager.instance());
+   }
+   
+   /**
+    * Undeploy the aop config
+    * 
+    * @param url the url
+    * @param manager the AspectManager/Domain to undeploy from
+    */
+   protected void undeploy(URL url, AspectManager manager)
+   {
       try
       {
          log.debug("Undeploying " + url);
-         urls.remove(url);
-         AspectXmlLoader.undeployXML(url);
+         urls.remove(new ManagerURL(url, manager));
+         AspectXmlLoader.undeployXML(url, manager);
       }
       catch (Exception e)
       {
          log.warn("Ignored error undeploying " + url, e);
       }
    }
+   
+   class ManagerURL
+   {
+      URL url;
+      AspectManager manager;
+      
+      public ManagerURL(URL url, AspectManager manager)
+      {
+         super();
+         this.url = url;
+         this.manager = manager;
+      }
+      
+      public AspectManager getManager()
+      {
+         return manager;
+      }
+
+      public URL getUrl()
+      {
+         return url;
+      }
+
+      @Override
+      public int hashCode()
+      {
+         final int PRIME = 31;
+         int result = 1;
+         result = PRIME * result + ((manager == null) ? 0 : manager.hashCode());
+         result = PRIME * result + ((url == null) ? 0 : url.hashCode());
+         return result;
+      }
+
+      @Override
+      public boolean equals(Object obj)
+      {
+         if (this == obj)
+            return true;
+         if (obj == null)
+            return false;
+         if (getClass() != obj.getClass())
+            return false;
+         final ManagerURL other = (ManagerURL) obj;
+         if (manager == null)
+         {
+            if (other.manager != null)
+               return false;
+         }
+         else if (!manager.equals(other.manager))
+            return false;
+         if (url == null)
+         {
+            if (other.url != null)
+               return false;
+         }
+         else if (!url.equals(other.url))
+            return false;
+         return true;
+      }
+      
+      
+   }
 }

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

Added: projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/support/TestInterceptor.java
===================================================================
--- projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/support/TestInterceptor.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/support/TestInterceptor.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,52 @@
+/*
+* 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.test.aop.integration.metadatadomain.support;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * TestInterceptor.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 43840 $
+ */
+public class TestInterceptor implements Interceptor
+{
+   private String property;
+   public static String intercepted;
+
+   public String getName()
+   {
+      return getClass().getName();
+   }
+
+   public void setProperty(String property)
+   {
+      this.property = property;
+   }
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      intercepted = property;
+      return invocation.invokeNext();
+   }
+}
\ No newline at end of file

Added: projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/Helper.java
===================================================================
--- projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/Helper.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/Helper.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,75 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.integration.metadatadomain.test;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+import org.jboss.metadata.plugins.repository.basic.BasicMetaDataRepository;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.MutableMetaData;
+import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.stack.MetaDataStack;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Helper
+{
+
+   static Domain createScopedDomain(String name)
+   {
+      AspectManager manager = AspectManager.getTopLevelAspectManager();
+      Domain scopedDomain = new Domain(manager, name, false);
+      return scopedDomain;
+   }
+
+   static void createAndPushMetaData(Domain scopedDomain)
+   {
+      //Deployer creates Domain depending on classloader rules, and adds it to metadata for deployment
+      ScopeKey scopeKey = createScope("Test", scopedDomain.getDomainName());
+      MutableMetaDataRepository repository = new BasicMetaDataRepository();
+      MetaDataRetrieval retrieval = new MemoryMetaDataLoader(scopeKey);
+      repository.addMetaDataRetrieval(retrieval);
+      
+      if (scopedDomain != null)
+      {
+         ((MutableMetaData)retrieval).addMetaData(scopedDomain, Domain.class);
+      }
+      MetaData metadata = repository.getMetaData(scopeKey);
+      MetaDataStack.push(metadata);
+   }
+
+   static ScopeKey createScope(String app, String dep)
+   {
+      ScopeKey result = ScopeKey.DEFAULT_SCOPE.clone();
+      result.addScope(CommonLevels.APPLICATION, app);
+      result.addScope(CommonLevels.DEPLOYMENT, dep);
+      return result;
+   }
+
+}

Added: projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForDomainUnitTestCase.java
===================================================================
--- projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForDomainUnitTestCase.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForDomainUnitTestCase.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,120 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.integration.metadatadomain.test;
+
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.deployers.temp.MetaDataClassLoaderScopingPolicy;
+import org.jboss.aop.integration.junit.NotWovenAOPIntegrationTest;
+import org.jboss.aop.proxy.container.AOPProxyFactory;
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.stack.MetaDataStack;
+import org.jboss.test.aop.integration.metadatadomain.support.TestIntercepted;
+import org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor;
+
+/**
+ * FIXME This test requires a classloading snapshot before it can be run
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MetaDataDomainProxyForDomainUnitTestCase extends NotWovenAOPIntegrationTest
+{
+   public MetaDataDomainProxyForDomainUnitTestCase(String name)
+   {
+      // FIXME SimpleMetaDataDomainProxyTestCase constructor
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      System.setProperty("jboss.test.parent.pkgs", "org.jboss.metadata.spi.repository,org.jboss.metadata.spi.retrieval,org.jboss.metadata.spi.scope");
+      return suite(MetaDataDomainProxyForDomainUnitTestCase.class, TestIntercepted.class);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      AspectManager.setClassLoaderScopingPolicy(new MetaDataClassLoaderScopingPolicy());
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      AspectManager.setClassLoaderScopingPolicy(null);
+   }
+
+   /**
+    * Push a domain onto the metadata stack and deploy into that domain.
+    * Create a proxy for that domain.
+    */
+   public void testDomain() throws Exception
+   {
+      URL url = null;
+      Domain domain = null;
+      try
+      {
+         //Create our instance to be proxied before we start deploying stuff
+         TestIntercepted test = new TestIntercepted();
+         
+         //Deployer creates metadata and populates that with the necessary domain
+         Helper.createAndPushMetaData(Helper.createScopedDomain("xxx"));
+         
+         //We get the domain out of the metadata and deploy into that
+         MetaData md = MetaDataStack.peek();
+         domain = md.getMetaData(Domain.class);
+         assertNotNull(domain);
+
+         //Make sure we use the same classloader as loaded the test
+         url = deploy("1", this.getClass().getClassLoader(), domain);
+         
+         //create the proxy, the scoped manger is taken from the metadata stack
+         AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+         params.setTarget(test);
+         params.setMetaData(md);
+         
+         AOPProxyFactory factory = new GeneratedAOPProxyFactory();
+         TestIntercepted proxy = (TestIntercepted)factory.createAdvisedProxy(params);
+         assertFalse(proxy.getClass() == TestIntercepted.class);
+                  
+         TestInterceptor.intercepted = null;
+         proxy.doSomething();
+         assertNotNull(TestInterceptor.intercepted);
+         assertEquals("First", TestInterceptor.intercepted);
+      }
+      finally
+      {
+         if (MetaDataStack.peek() != null)
+         {
+            MetaDataStack.pop();
+         }
+         undeploy(url, domain);
+      }
+   }
+}

Added: projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForMainManagerUnitTestCase.java
===================================================================
--- projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForMainManagerUnitTestCase.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForMainManagerUnitTestCase.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,106 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.integration.metadatadomain.test;
+
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.deployers.temp.MetaDataClassLoaderScopingPolicy;
+import org.jboss.aop.integration.junit.NotWovenAOPIntegrationTest;
+import org.jboss.aop.proxy.container.AOPProxyFactory;
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+import org.jboss.test.aop.integration.metadatadomain.support.TestIntercepted;
+import org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor;
+
+/**
+ * FIXME This test requires a classloading snapshot before it can be run
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MetaDataDomainProxyForMainManagerUnitTestCase extends NotWovenAOPIntegrationTest
+{
+   public MetaDataDomainProxyForMainManagerUnitTestCase(String name)
+   {
+      // FIXME SimpleMetaDataDomainProxyTestCase constructor
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(MetaDataDomainProxyForMainManagerUnitTestCase.class, TestIntercepted.class);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      AspectManager.setClassLoaderScopingPolicy(new MetaDataClassLoaderScopingPolicy());
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      AspectManager.setClassLoaderScopingPolicy(null);
+   }
+
+   /**
+    * Create a domain and deploy into that domain.
+    * 
+    */
+   public void testDomain() throws Exception
+   {
+      URL url = null;
+      Domain domain = null;
+      try
+      {
+         
+         //Create our instance to be proxied before we start deploying stuff
+         TestIntercepted test = new TestIntercepted();
+         
+         //Create a domain and deploy into that
+         domain = Helper.createScopedDomain("xxx");
+         url = deploy("1", Thread.currentThread().getContextClassLoader(), domain);
+         
+         //create the proxy, it uses the main manager
+         AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+         params.setTarget(test);
+         params.setMetaData(null);
+         
+         AOPProxyFactory factory = new GeneratedAOPProxyFactory();
+         TestIntercepted proxy = (TestIntercepted)factory.createAdvisedProxy(params);
+         assertTrue(proxy.getClass() == TestIntercepted.class);
+                  
+         TestInterceptor.intercepted = null;
+         proxy.doSomething();
+         assertNull(TestInterceptor.intercepted);
+      }
+      finally
+      {
+         undeploy(url, domain);
+      }
+   }
+}

Added: projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomainsUnitTestCase.java
===================================================================
--- projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomainsUnitTestCase.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainProxyForSeveralDomainsUnitTestCase.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,137 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.integration.metadatadomain.test;
+
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.deployers.temp.MetaDataClassLoaderScopingPolicy;
+import org.jboss.aop.integration.junit.NotWovenAOPIntegrationTest;
+import org.jboss.aop.proxy.container.AOPProxyFactory;
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.stack.MetaDataStack;
+import org.jboss.test.aop.integration.metadatadomain.support.TestIntercepted;
+import org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor;
+
+/**
+ * FIXME This test requires a classloading snapshot before it can be run
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MetaDataDomainProxyForSeveralDomainsUnitTestCase extends NotWovenAOPIntegrationTest
+{
+   public MetaDataDomainProxyForSeveralDomainsUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      System.setProperty("jboss.test.parent.pkgs", "org.jboss.metadata.spi.repository, org.jboss.metadata.spi.retrieval, org.jboss.metadata.spi.scope");
+      return suite(MetaDataDomainProxyForSeveralDomainsUnitTestCase.class, TestIntercepted.class);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      AspectManager.setClassLoaderScopingPolicy(new MetaDataClassLoaderScopingPolicy());
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      AspectManager.setClassLoaderScopingPolicy(null);
+   }
+
+   /**
+    * Push a domain onto the metadata stack and deploy into that domain.
+    * Create a proxy for that domain.
+    */
+   public void testDomain() throws Exception
+   {
+      URL[] urls = new URL[2];
+      Domain[] domains = new Domain[2];
+      try
+      {
+         //Create our instance to be proxied before we start deploying stuff
+         TestIntercepted test = new TestIntercepted();
+         
+         TestIntercepted proxy1 = createDomainAndProxy("1", this.getClass().getClassLoader(), test, 0, urls, domains);
+         TestIntercepted proxy2 = createDomainAndProxy("2", this.getClass().getClassLoader(), test, 1, urls, domains);
+         
+         assertFalse(proxy1.getClass() == TestIntercepted.class);
+         assertFalse(proxy2.getClass() == TestIntercepted.class);
+         
+         TestInterceptor.intercepted = null;
+         proxy1.doSomething();
+         assertNotNull(TestInterceptor.intercepted);
+         assertEquals("First", TestInterceptor.intercepted);
+         
+         TestInterceptor.intercepted = null;
+         proxy2.doSomething();
+         assertNotNull(TestInterceptor.intercepted);
+         assertEquals("Second", TestInterceptor.intercepted);
+      }
+      finally
+      {
+         while (MetaDataStack.peek() != null)
+         {
+            MetaDataStack.pop();
+         }
+         for (int i = 0 ; i < urls.length ; i++)
+         {
+            if (urls[i] != null)
+            {
+               undeploy(urls[i], domains[i]);
+            }
+         }
+      }
+   }
+
+   private TestIntercepted createDomainAndProxy(String suffix, ClassLoader cl, TestIntercepted test, int i, URL[] urls, Domain[] domains) throws Exception
+   {
+      //Deployer creates metadata and populates that with the necessary domain_1
+      Helper.createAndPushMetaData(Helper.createScopedDomain("xxx"));
+      
+      //We get the domain_1 out of the metadata and deploy into that
+      MetaData md = MetaDataStack.peek();
+      domains[i] = md.getMetaData(Domain.class);
+      assertNotNull(domains[0]);
+      urls[i] = deploy("1", this.getClass().getClassLoader(), domains[0]);
+      
+      //create the proxy, the scoped manger is taken from the metadata stack
+      AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+      params.setTarget(test);
+      params.setMetaData(md);
+      
+      AOPProxyFactory factory = new GeneratedAOPProxyFactory();
+      return (TestIntercepted)factory.createAdvisedProxy(params);       
+   }
+   
+}

Added: projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainWovenForDomainUnitTestCase.java
===================================================================
--- projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainWovenForDomainUnitTestCase.java	                        (rev 0)
+++ projects/aop/trunk/asintegration/src/tests/org/jboss/test/aop/integration/metadatadomain/test/MetaDataDomainWovenForDomainUnitTestCase.java	2007-09-21 11:53:30 UTC (rev 65528)
@@ -0,0 +1,120 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/ 
+package org.jboss.test.aop.integration.metadatadomain.test;
+
+import java.net.URL;
+
+import junit.framework.Test;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.Domain;
+import org.jboss.aop.deployers.temp.MetaDataClassLoaderScopingPolicy;
+import org.jboss.aop.integration.junit.NotWovenAOPIntegrationTest;
+import org.jboss.aop.proxy.container.AOPProxyFactory;
+import org.jboss.aop.proxy.container.AOPProxyFactoryParameters;
+import org.jboss.aop.proxy.container.GeneratedAOPProxyFactory;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.stack.MetaDataStack;
+import org.jboss.test.aop.integration.metadatadomain.support.TestIntercepted;
+import org.jboss.test.aop.integration.metadatadomain.support.TestInterceptor;
+
+/**
+ * FIXME This test requires a classloading snapshot before it can be run
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class MetaDataDomainWovenForDomainUnitTestCase extends NotWovenAOPIntegrationTest
+{
+   public MetaDataDomainWovenForDomainUnitTestCase(String name)
+   {
+      // FIXME SimpleMetaDataDomainProxyTestCase constructor
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      System.setProperty("jboss.test.parent.pkgs", "org.jboss.metadata.spi.repository,org.jboss.metadata.spi.retrieval,org.jboss.metadata.spi.scope");
+      return suite(MetaDataDomainProxyForDomainUnitTestCase.class, TestIntercepted.class);
+   }
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      AspectManager.setClassLoaderScopingPolicy(new MetaDataClassLoaderScopingPolicy());
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      super.tearDown();
+      AspectManager.setClassLoaderScopingPolicy(null);
+   }
+
+   /**
+    * Push a domain onto the metadata stack and deploy into that domain.
+    * Create a proxy for that domain.
+    */
+   public void testDomain() throws Exception
+   {
+      URL url = null;
+      Domain domain = null;
+      try
+      {
+         //Create our instance to be proxied before we start deploying stuff
+         TestIntercepted test = new TestIntercepted();
+         
+         //Deployer creates metadata and populates that with the necessary domain
+         Helper.createAndPushMetaData(Helper.createScopedDomain("xxx"));
+         
+         //We get the domain out of the metadata and deploy into that
+         MetaData md = MetaDataStack.peek();
+         domain = md.getMetaData(Domain.class);
+         assertNotNull(domain);
+
+         //Make sure we use the same classloader as loaded the test
+         url = deploy("1", this.getClass().getClassLoader(), domain);
+         
+         //create the proxy, the scoped manger is taken from the metadata stack
+         AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
+         params.setTarget(test);
+         params.setMetaData(md);
+         
+         AOPProxyFactory factory = new GeneratedAOPProxyFactory();
+         TestIntercepted proxy = (TestIntercepted)factory.createAdvisedProxy(params);
+         assertFalse(proxy.getClass() == TestIntercepted.class);
+                  
+         TestInterceptor.intercepted = null;
+         proxy.doSomething();
+         assertNotNull(TestInterceptor.intercepted);
+         assertEquals("First", TestInterceptor.intercepted);
+      }
+      finally
+      {
+         if (MetaDataStack.peek() != null)
+         {
+            MetaDataStack.pop();
+         }
+         undeploy(url, domain);
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list