[jboss-cvs] JBossAS SVN: r60579 - in trunk: testsuite and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 15 18:48:16 EST 2007


Author: kabir.khan at jboss.com
Date: 2007-02-15 18:48:16 -0500 (Thu, 15 Feb 2007)
New Revision: 60579

Added:
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/POJO.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedAspect.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedAspectFactory.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedFactoryAspect.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedInterceptor.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedMetadataBinding.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedMetadataLoader.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPCInterceptor.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPCJInterceptor.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPJInterceptor.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedTester.java
   trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedTesterMBean.java
   trunk/testsuite/src/resources/aop/scoped-attach/
   trunk/testsuite/src/resources/aop/scoped-attach/sar1/
   trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/
   trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/jboss-aop.xml
   trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/jboss-service.xml
   trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/prepare-aop.xml
   trunk/testsuite/src/resources/aop/scoped-attach/sar2/
   trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/
   trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/jboss-aop.xml
   trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/jboss-service.xml
   trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/prepare-aop.xml
Modified:
   trunk/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java
   trunk/aspects/src/main/org/jboss/aop/deployment/JBossScopedClassLoaderHelper.java
   trunk/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java
   trunk/testsuite/.classpath
   trunk/testsuite/build.xml
   trunk/testsuite/imports/sections/aop.xml
Log:
[JBAOP-356] Ability to attach a .aop deployment to a particular scoped classloader.

Register ScopedClassLoaderDomains per LoaderRepository instead of per (scoped) classloader.

Still need to get tests to work in head...



Modified: trunk/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java	2007-02-15 23:09:35 UTC (rev 60578)
+++ trunk/aspects/src/main/org/jboss/aop/deployment/AspectDeployer.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -25,6 +25,8 @@
 import java.net.URL;
 import java.util.Iterator;
 
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanInfo;
 import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.Notification;
@@ -38,8 +40,14 @@
 import org.jboss.deployment.DeploymentState;
 import org.jboss.deployment.SubDeployer;
 import org.jboss.deployment.SubDeployerSupport;
+import org.jboss.mx.loading.HeirarchicalLoaderRepository3;
+import org.jboss.mx.loading.LoaderRepository;
 import org.jboss.util.file.ArchiveBrowser;
 import org.jboss.util.file.ClassFileFilter;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 /**
  * Deployer for Aspects
@@ -290,7 +298,7 @@
       return docURL;
    }
    
-   private ClassLoader getScopedClassLoader(DeploymentInfo di, URL docUrl)
+   private ClassLoader getScopedClassLoader(DeploymentInfo di, URL docUrl) throws Exception
    {
       //Scoped AOP deployments are only available when deployed as part of a scoped sar, ear etc.
       //It can contain an aop.xml file, or it can be part of a .aop file
@@ -300,6 +308,80 @@
          return di.ucl;
       }
       
+      LoaderRepository attachToRepository = getLoaderRepositoryIfAttaching(di, docUrl);
+      if (attachToRepository != null)
+      {
+         di.ucl.setRepository(attachToRepository);
+         attachToRepository.addClassLoader(di.ucl);
+         return di.ucl;
+      }
       return null;
    }
+   
+   private LoaderRepository getLoaderRepositoryIfAttaching(DeploymentInfo di, URL docUrl) throws Exception
+   {
+      if (di.parent == null)
+      {
+         //We are a top-level deployment, check if we are meant to be attaching to a scoped repository
+         
+         Document doc = AspectXmlLoader.loadURL(docUrl);
+         Element top = doc.getDocumentElement();
+         NodeList children = top.getChildNodes();
+         int childlength = children.getLength();
+         for (int i = 0; i < childlength ; i++)
+         {
+            Node child = children.item(i); 
+            if (child.getNodeType() == Node.ELEMENT_NODE)
+            {
+               Element element = (Element)child;  
+               if (element.getTagName().equals("loader-repository"))
+               {
+                  String repositoryName = null;
+                  NodeList nestedChildren = child.getChildNodes();
+                  int nestedChildLength = nestedChildren.getLength();
+                  for (int j = 0 ; j < nestedChildLength ; j++)
+                  {
+                     Node nestedChild = nestedChildren.item(j);
+                     if (nestedChild.getNodeType() == Node.TEXT_NODE || nestedChild.getNodeType() == Node.CDATA_SECTION_NODE)
+                     {
+                        repositoryName = nestedChild.getNodeValue().trim();
+                        break;
+                     }
+                  }
+                  log.info("Should attach deployment to loader repository " + repositoryName);
+                  ObjectName on;
+                  try
+                  {
+                     on = new ObjectName(repositoryName);
+                  }
+                  catch (MalformedObjectNameException e)
+                  {
+                     throw new RuntimeException("loader-repository='" + repositoryName + "' is not a valid object name", e);
+                  }
+                  
+                  try
+                  {
+                     MBeanInfo info = server.getMBeanInfo(on);
+                  }
+                  catch (InstanceNotFoundException e)
+                  {
+                     log.warn("No scoped loader repository exists with the name " + on);
+                  }
+                  
+                  LoaderRepository repository = (LoaderRepository)server.getAttribute(on, "Instance");
+                  if (repository instanceof HeirarchicalLoaderRepository3)
+                  {
+                     return repository;
+                  }
+                  else
+                  {
+                     log.warn("Loader repository " + on + " is not a isolated loader repository. Deploying aspects in default domain.");
+                  }
+               }
+            }            
+         }
+      }
+      
+      return null;
+   }
 }
\ No newline at end of file

Modified: trunk/aspects/src/main/org/jboss/aop/deployment/JBossScopedClassLoaderHelper.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployment/JBossScopedClassLoaderHelper.java	2007-02-15 23:09:35 UTC (rev 60578)
+++ trunk/aspects/src/main/org/jboss/aop/deployment/JBossScopedClassLoaderHelper.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -99,4 +99,13 @@
       return new ScopedClassLoaderDomain(cl, name, parentDelegation, parent, false);
    }
 
+   public Object getLoaderRepository(ClassLoader loader)
+   {
+      ClassLoader cl = ifScopedDeploymentGetScopedParentUclForCL(loader);
+      if (cl != null)
+      {
+         return ((RepositoryClassLoader)cl).getLoaderRepository();
+      }
+      return null;
+   }
 }

Modified: trunk/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java	2007-02-15 23:09:35 UTC (rev 60578)
+++ trunk/aspects/src/main/org/jboss/aop/deployment/ScopedClassLoaderDomain.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -65,6 +65,15 @@
       return null;
    }
    
+   public void removeAspectDefinition(String name)
+   {
+      AspectDefinition def = super.internalRemoveAspectDefintion(name);
+      if (def != null)
+      {
+         Object o = myPerVMAspects.remove(name);
+      }
+   }
+
    public Object getPerVMAspect(AspectDefinition def)
    {
       return getPerVMAspect(def.getName());

Modified: trunk/testsuite/.classpath
===================================================================
--- trunk/testsuite/.classpath	2007-02-15 23:09:35 UTC (rev 60578)
+++ trunk/testsuite/.classpath	2007-02-15 23:48:16 UTC (rev 60579)
@@ -85,5 +85,6 @@
 	<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-managed.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-managed-src.zip"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/profileservice"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/profiler/jvmti/lib/jboss-profiler-jvmti.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jbossws/lib/jboss-jaxws.jar"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Modified: trunk/testsuite/build.xml
===================================================================
--- trunk/testsuite/build.xml	2007-02-15 23:09:35 UTC (rev 60578)
+++ trunk/testsuite/build.xml	2007-02-15 23:48:16 UTC (rev 60579)
@@ -3125,8 +3125,8 @@
       <copy todir="${jboss.dist}/bin" file="${jboss.aop.lib}/jdk14-pluggable-instrumentor.jar"/>
       <server:start name="scoped-aop-jdk14"/>
 
-      <run-junit junit.patternset="aop-with-classloader.includes"/>
-
+	   <antcall target="run-tests-aop-scoped" inheritRefs="true"/>
+	
       <server:stop name="scoped-aop-jdk14"/>
 
       <delete dir="${jboss.dist}/bin/woven-classloader"/>
@@ -3140,8 +3140,7 @@
       <!--copy todir="${jboss.dist}/bin" file="${jboss.aop.lib}/pluggable-instrumentor.jar"/>
       <server:start name="scoped-aop-jdk50"/-->
 
-       <run-junit junit.patternset="aop-with-classloader.includes"/>
-
+	   <antcall target="run-tests-aop-scoped" inheritRefs="true"/>
       <!--server:stop name="scoped-aop-jdk50"/>
 
       <delete file="${jboss.dist}/bin/pluggable-instrumentor.jar"/-->
@@ -3160,7 +3159,10 @@
 
       <delete file="${jboss.dist}/bin/pluggable-instrumentor.jar"/>
    </target>
-
+   <target name="run-tests-aop-scoped"
+     description="AOP tests requiring a native classloader hook">
+       <run-junit junit.patternset="aop-with-classloader.includes" junit.configuration="aop-scoped"/>
+   </target>
    <!-- Test for ws-bpel integration -->
    <target name="tests-bpel">
       <!-- define tasks used in this target -->

Modified: trunk/testsuite/imports/sections/aop.xml
===================================================================
--- trunk/testsuite/imports/sections/aop.xml	2007-02-15 23:09:35 UTC (rev 60578)
+++ trunk/testsuite/imports/sections/aop.xml	2007-02-15 23:48:16 UTC (rev 60579)
@@ -484,6 +484,52 @@
         </fileset>
      </jar>
 
+    <!-- jars for scoped attachment test -->
+    <jar destfile="${build.lib}/aop-scopedattachtest1.aop">
+      <fileset dir="${build.classes}">
+        <include name="org/jboss/test/aop/scopedattach/**/*.class"/>
+        <exclude name="org/jboss/test/aop/scopedattach/ScopedTester*.class"/>
+        <exclude name="org/jboss/test/aop/scopedattach/POJO.class"/>
+      </fileset>
+      <fileset dir="${build.resources}/aop/scoped-attach/sar1">
+        <include name="META-INF/jboss-aop.xml"/>
+      </fileset>
+    </jar>
+    <jar destfile="${build.lib}/aop-scopedattachtest1.sar">
+      <fileset dir="${build.classes}">
+        <include name="org/jboss/test/aop/scopedattach/ScopedTester*.class"/>
+        <include name="org/jboss/test/aop/scopedattach/POJO.class"/>
+      </fileset>
+      <fileset dir="${build.resources}/aop/scoped-attach/sar1">
+        <include name="META-INF/jboss-service.xml"/>
+      </fileset>
+      <fileset dir="${build.resources}/aop/scoped-attach/sar1/META-INF">
+        <include name="prepare-aop.xml"/>
+      </fileset>      
+    </jar>
+    <jar destfile="${build.lib}/aop-scopedattachtest2.aop">
+      <fileset dir="${build.classes}">
+        <include name="org/jboss/test/aop/scopedattach/**/*.class"/>
+        <exclude name="org/jboss/test/aop/scopedattach/ScopedTester*.class"/>
+        <exclude name="org/jboss/test/aop/scopedattach/POJO.class"/>
+      </fileset>
+      <fileset dir="${build.resources}/aop/scoped-attach/sar2">
+        <include name="META-INF/jboss-aop.xml"/>
+      </fileset>
+    </jar>
+    <jar destfile="${build.lib}/aop-scopedattachtest2.sar">
+      <fileset dir="${build.classes}">
+        <include name="org/jboss/test/aop/scopedattach/ScopedTester*.class"/>
+        <include name="org/jboss/test/aop/scopedattach/POJO.class"/>
+      </fileset>
+      <fileset dir="${build.resources}/aop/scoped-attach/sar2">
+        <include name="META-INF/jboss-service.xml"/>
+      </fileset>
+      <fileset dir="${build.resources}/aop/scoped-attach/sar2/META-INF">
+        <include name="prepare-aop.xml"/>
+      </fileset>      
+    </jar>
+    
      <!-- Create jars for earwithwebinf test -->
      <jar destfile="${build.lib}/aop-classesinwebinf.aop">
         <fileset dir="${build.classes}">

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/POJO.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/POJO.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/POJO.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.scopedattach;
+
+import javax.naming.InitialContext;
+import javax.transaction.TransactionManager;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class POJO
+{
+   public POJO()
+   {
+      System.out.println("*** POJO constructor");    
+   }
+   
+   public void method()
+   {
+      System.out.println("*** POJO method");      
+      try
+      {
+         TransactionManager tm = (TransactionManager)new InitialContext().lookup("java:/TransactionManager");
+         if (tm.getTransaction() == null) throw new RuntimeException("method() has no tx set");
+      }
+      catch (Exception e)
+      {
+         // AutoGenerated
+         throw new RuntimeException(e);
+      }
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedAspect.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedAspect.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedAspect.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.aop.scopedattach;
+
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ScopedAspect
+{
+   public static int intercepted;
+   public static int value;
+   
+   public void setValue(int i)
+   {
+      value = i;
+   }
+
+   public Object test(Invocation invocation) throws Throwable
+   {
+//      System.out.println("--- ScopedAspect intercepting " + getClass().getClassLoader());
+      intercepted++;
+      return invocation.invokeNext();
+   }
+   
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedAspectFactory.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedAspectFactory.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedAspectFactory.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,73 @@
+/*
+ * 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.scopedattach;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.InstanceAdvisor;
+import org.jboss.aop.advice.AspectFactory;
+import org.jboss.aop.joinpoint.Joinpoint;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ScopedAspectFactory implements AspectFactory
+{
+
+   public ScopedAspectFactory()
+   {
+      // FIXME ScopedAspectFactory constructor
+      super();
+   }
+
+   public Object createPerVM()
+   {
+      return new ScopedFactoryAspect();
+   }
+
+   public Object createPerClass(Advisor advisor)
+   {
+      throw new RuntimeException("Illegal scope");
+   }
+
+   public Object createPerInstance(Advisor advisor, InstanceAdvisor instanceAdvisor)
+   {
+      throw new RuntimeException("Illegal scope");
+   }
+
+   public Object createPerJoinpoint(Advisor advisor, Joinpoint jp)
+   {
+      throw new RuntimeException("Illegal scope");
+   }
+
+   public Object createPerJoinpoint(Advisor advisor, InstanceAdvisor instanceAdvisor, Joinpoint jp)
+   {
+      throw new RuntimeException("Illegal scope");
+   }
+
+   public String getName()
+   {
+      return "ScopedAspectFactory";
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedFactoryAspect.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedFactoryAspect.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedFactoryAspect.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,50 @@
+/*
+ * 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.scopedattach;
+
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ScopedFactoryAspect
+{
+   public static String metadata;
+   public static String customMetadata;
+   public static int intercepted;
+   
+   public ScopedFactoryAspect()
+   {
+      super();
+   }
+
+   
+   public Object test(Invocation inv) throws Throwable
+   {
+      intercepted++;
+      metadata = (String)inv.getMetaData("test", "data");
+      customMetadata = (String)inv.getMetaData("custom", "data");
+      return inv.invokeNext();
+   }
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedInterceptor.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedInterceptor.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedInterceptor.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,65 @@
+/*
+ * 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.scopedattach;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ScopedInterceptor implements Interceptor
+{
+   public static int intercepted;
+   public static int value;
+   
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+   
+   public void setValue(int i)
+   {
+      value = i;
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+//      System.out.println("--- ScopedInterceptor intercepting " + getClass().getClassLoader());
+      intercepted++;
+      
+      if (invocation instanceof MethodInvocation)
+      {
+         MethodInvocation mi = (MethodInvocation)invocation;
+         if (mi.getMethod().getName().equals("testMethod"))
+         {
+            return null;
+         }
+      }
+      
+      return invocation.invokeNext();
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedMetadataBinding.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedMetadataBinding.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedMetadataBinding.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -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.test.aop.scopedattach;
+
+import org.jboss.aop.metadata.ClassMetaDataBinding;
+import org.jboss.aop.metadata.ClassMetaDataLoader;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ScopedMetadataBinding extends ClassMetaDataBinding
+{
+   String data;
+   
+   public ScopedMetadataBinding(ClassMetaDataLoader loader, String name, String tag, String exp)
+   {
+      super(loader, name, tag, exp);
+   }
+
+   public String getData()
+   {
+      return data;
+   }
+
+   public void setData(String data)
+   {
+      this.data = data;
+   }
+   
+   
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedMetadataLoader.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedMetadataLoader.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedMetadataLoader.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -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.test.aop.scopedattach;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import javassist.CtConstructor;
+import javassist.CtField;
+import javassist.CtMethod;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.metadata.ClassMetaDataBinding;
+import org.jboss.aop.metadata.ClassMetaDataLoader;
+import org.jboss.aop.util.XmlHelper;
+import org.w3c.dom.Element;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public class ScopedMetadataLoader implements ClassMetaDataLoader
+{
+   public ClassMetaDataBinding importMetaData(Element element, String name, String tag, String classExpr) throws Exception
+   {
+      ScopedMetadataBinding data = new ScopedMetadataBinding(this, name, tag, classExpr);
+      String value = XmlHelper.getOptionalChildContent(element, "data");
+      data.setData(value);
+      
+      return data;
+   }
+
+   public void bind(Advisor advisor, ClassMetaDataBinding data, CtMethod[] methods, CtField[] fields, CtConstructor[] constructors) throws Exception
+   {
+      for (int i = 0 ; i < methods.length ; i++)
+      {
+         advisor.getMethodMetaData().addMethodMetaData(methods[i], "custom", "data", ((ScopedMetadataBinding)data).getData());
+      }
+      for (int i = 0 ; i < constructors.length ; i++)
+      {
+         advisor.getConstructorMetaData().addConstructorMetaData(constructors[i], "custom", "data", ((ScopedMetadataBinding)data).getData());
+      }
+   }
+
+   public void bind(Advisor advisor, ClassMetaDataBinding data, Method[] methods, Field[] fields, Constructor[] constructors) throws Exception
+   {
+      for (int i = 0 ; i < methods.length ; i++)
+      {
+         advisor.getMethodMetaData().addMethodMetaData(methods[i], "custom", "data", ((ScopedMetadataBinding)data).getData());
+      }
+      for (int i = 0 ; i < constructors.length ; i++)
+      {
+         advisor.getConstructorMetaData().addConstructorMetaData(constructors[i], "custom", "data", ((ScopedMetadataBinding)data).getData());
+      }
+   }
+
+
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPCInterceptor.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPCInterceptor.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPCInterceptor.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,65 @@
+/*
+* 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.scopedattach;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedPCInterceptor implements Interceptor
+{
+   public static int intercepted;
+   public static int value;
+   
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+   
+   public void setValue(int i)
+   {
+      value = i;
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+//      System.out.println("--- ScopedPCInterceptor intercepting " + getClass().getClassLoader());
+      intercepted++;
+      
+      if (invocation instanceof MethodInvocation)
+      {
+         MethodInvocation mi = (MethodInvocation)invocation;
+         if (mi.getMethod().getName().equals("testMethod"))
+         {
+            return null;
+         }
+      }
+      
+      return invocation.invokeNext();
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPCJInterceptor.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPCJInterceptor.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPCJInterceptor.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,65 @@
+/*
+* 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.scopedattach;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedPCJInterceptor implements Interceptor
+{
+   public static int intercepted;
+   public static int value;
+   
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+   
+   public void setValue(int i)
+   {
+      value = i;
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+//      System.out.println("--- ScopedPCJInterceptor intercepting " + getClass().getClassLoader());
+      intercepted++;
+      
+      if (invocation instanceof MethodInvocation)
+      {
+         MethodInvocation mi = (MethodInvocation)invocation;
+         if (mi.getMethod().getName().equals("testMethod"))
+         {
+            return null;
+         }
+      }
+      
+      return invocation.invokeNext();
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPJInterceptor.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPJInterceptor.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedPJInterceptor.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,65 @@
+/*
+* 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.scopedattach;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedPJInterceptor implements Interceptor
+{
+   public static int intercepted;
+   public static int value;
+   
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+   
+   public void setValue(int i)
+   {
+      value = i;
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+//      System.out.println("--- ScopedPJInterceptor intercepting " + getClass().getClassLoader());
+      intercepted++;
+      
+      if (invocation instanceof MethodInvocation)
+      {
+         MethodInvocation mi = (MethodInvocation)invocation;
+         if (mi.getMethod().getName().equals("testMethod"))
+         {
+            return null;
+         }
+      }
+      
+      return invocation.invokeNext();
+   }
+
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedTester.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedTester.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedTester.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,211 @@
+/*
+ * 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.scopedattach;
+
+import java.lang.reflect.Method;
+
+import org.jboss.aop.Advised;
+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$
+ */
+public class ScopedTester implements ScopedTesterMBean
+{
+   int expectedInterceptorValue;
+   int expectedAspectValue;
+   int metadataSuffix;
+   
+   String ctorPlainMetadata;
+   String methodPlainMetadata;
+   String customMetadata;
+   
+   public void setExpectedInterceptorValue(int i)
+   {
+      expectedInterceptorValue = i;
+   }
+
+   public void setExpectedAspectValue(int i)
+   {
+      expectedAspectValue = i;
+   }
+   
+   public int getExpectedInterceptorValue()
+   {
+      return expectedInterceptorValue;
+   }
+
+   public int getExpectedAspectValue()
+   {
+      return expectedAspectValue;
+   }
+
+   public void setMetadataSuffix(int i)
+   {
+      metadataSuffix = i;
+      ctorPlainMetadata = "ctor" + metadataSuffix;
+      methodPlainMetadata = "method" + metadataSuffix;
+      customMetadata = "custom" + metadataSuffix;
+   }
+   
+   public void checkPOJOAdvised()
+   {
+      System.out.println("--------------------------- TESTING POJO ADVISED ------------------");
+      if (!Advised.class.isAssignableFrom(POJO.class))
+      {
+         throw new RuntimeException("POJO is not advised");
+      }
+   }
+   
+   public void testScoped() throws Exception
+   {
+      try
+      {
+         System.out.println("--------------------------- TESTING SCOPED ------------------");
+         System.out.println("MY CLASSLOADER " + getClass().getClassLoader());
+         System.out.println("SCOPED INTERCEPTOR CLASSLOADER " + ScopedInterceptor.class.getClassLoader());
+         System.out.println("POJO CLASSLOADER " + POJO.class.getClassLoader());
+   
+         //Check that the classloaders have the same repositories
+         LoaderRepository repository1 = ((RepositoryClassLoader)getClass().getClassLoader()).getLoaderRepository();
+         LoaderRepository repository2 = ((RepositoryClassLoader)ScopedInterceptor.class.getClassLoader()).getLoaderRepository();
+         LoaderRepository repository3 = ((RepositoryClassLoader)POJO.class.getClassLoader()).getLoaderRepository();
+         
+         if (repository1 != repository2)
+         {
+            throw new RuntimeException("Repositories were not the same");
+         }
+         if (repository1 != repository3)
+         {
+            throw new RuntimeException("Repositories were not the same");
+         }
+         
+         System.out.println("------- CTOR");
+         ScopedAspect.intercepted = 0;
+         ScopedFactoryAspect.intercepted = 0;
+         ScopedPCInterceptor.intercepted = 0;
+         ScopedPCJInterceptor.intercepted = 0;
+         ScopedFactoryAspect.metadata = null;
+         ScopedFactoryAspect.customMetadata = null;
+         
+         POJO pojo = new POJO();
+         if (ScopedAspect.intercepted != 1)
+         {
+            throw new RuntimeException("Expected ScopedAspect 1 for POJO constructor, was " + ScopedAspect.intercepted);
+         }
+         if (ScopedFactoryAspect.intercepted != 1)
+         {
+            throw new RuntimeException("Expected ScopedFactoryAspect 1 for POJO constructor, was " + ScopedFactoryAspect.intercepted);
+         }
+         if (ScopedPCInterceptor.intercepted != 1)
+         {
+            throw new RuntimeException("Expected ScopedPCInterceptor 1 for POJO constructor, was " + ScopedPCInterceptor.intercepted);
+         }
+         if (ScopedPCJInterceptor.intercepted != 1)
+         {
+            throw new RuntimeException("Expected ScopedPCJInterceptor 1 for POJO constructor, was " + ScopedPCJInterceptor.intercepted);
+         }
+         if (!ctorPlainMetadata.equals(ScopedFactoryAspect.metadata))
+         {
+            throw new RuntimeException("Expected ctor metadata " + ctorPlainMetadata + ", was " + ScopedFactoryAspect.metadata);
+         }
+         if (!customMetadata.equals(ScopedFactoryAspect.customMetadata))
+         {
+            throw new RuntimeException("Expected ctor customm metadata " + customMetadata + ", was " + ScopedFactoryAspect.customMetadata);
+         }
+         
+         System.out.println("------- METHOD");
+         ScopedInterceptor.intercepted = 0;
+         ScopedAspect.intercepted = 0;
+         ScopedFactoryAspect.intercepted = 0;
+         ScopedPCInterceptor.intercepted = 0;
+         ScopedPCJInterceptor.intercepted = 0;
+         ScopedPJInterceptor.intercepted = 0;
+         ScopedFactoryAspect.metadata = null;
+         ScopedFactoryAspect.customMetadata = null;
+   
+         pojo.method();
+         if (ScopedInterceptor.intercepted != 1)
+         {
+            throw new RuntimeException("Expected ScopedInterceptor 1 for POJO method, was " + ScopedInterceptor.intercepted);
+         }
+         if (ScopedAspect.intercepted != 1)
+         {
+            throw new RuntimeException("Expected ScopedAspect 1 for POJO method, was " + ScopedAspect.intercepted);
+         }
+         if (ScopedFactoryAspect.intercepted != 1)
+         {
+            throw new RuntimeException("Expected ScopedFactoryAspect 1 for POJO method, was " + ScopedFactoryAspect.intercepted);
+         }
+         if (ScopedPCInterceptor.intercepted != 1)
+         {
+            throw new RuntimeException("Expected ScopedPCInterceptor 1 for POJO method, was " + ScopedPCInterceptor.intercepted);
+         }
+         if (ScopedPCJInterceptor.intercepted != 1)
+         {
+            throw new RuntimeException("Expected ScopedPCJInterceptor 1 for POJO method, was " + ScopedPCJInterceptor.intercepted);
+         }
+         if (ScopedPJInterceptor.intercepted != 1)
+         {
+            throw new RuntimeException("Expected ScopedPJInterceptor 1 for POJO method, was " + ScopedPJInterceptor.intercepted);
+         }
+         if (!methodPlainMetadata.equals(ScopedFactoryAspect.metadata))
+         {
+            throw new RuntimeException("Expected method metadata '" + methodPlainMetadata + ", was " + ScopedFactoryAspect.metadata);
+         }
+         if (!customMetadata.equals(ScopedFactoryAspect.customMetadata))
+         {
+            throw new RuntimeException("Expected method customm metadata " + customMetadata + ", was " + ScopedFactoryAspect.customMetadata);
+         }
+         
+         
+         if (ScopedInterceptor.value != expectedInterceptorValue)
+         {
+            throw new RuntimeException("Expected " + expectedInterceptorValue + " was " + ScopedInterceptor.value);
+         }
+         if (ScopedPCInterceptor.value != expectedInterceptorValue)
+         {
+            throw new RuntimeException("Expected " + expectedInterceptorValue + " was " + ScopedPCInterceptor.value);
+         }
+         if (ScopedPJInterceptor.value != expectedInterceptorValue)
+         {
+            throw new RuntimeException("Expected " + expectedInterceptorValue + " was " + ScopedPJInterceptor.value);
+         }
+         if (ScopedPCJInterceptor.value != expectedInterceptorValue)
+         {
+            throw new RuntimeException("Expected " + expectedInterceptorValue + " was " + ScopedPCJInterceptor.value);
+         }
+         if (ScopedAspect.value != expectedAspectValue)
+         {
+            throw new RuntimeException("Expected " + expectedAspectValue + " was " + ScopedAspect.value);
+         }
+      }
+      catch(Exception e)
+      {
+         e.printStackTrace();
+         throw e;
+      }
+   }   
+}

Added: trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedTesterMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedTesterMBean.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/aop/scopedattach/ScopedTesterMBean.java	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,39 @@
+/*
+ * 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.scopedattach;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision$
+ */
+public interface ScopedTesterMBean
+{
+   void setExpectedInterceptorValue(int i);
+   int getExpectedInterceptorValue();
+   void setExpectedAspectValue(int i);
+   int getExpectedAspectValue();
+   void setMetadataSuffix(int i);
+
+   void checkPOJOAdvised();
+   void testScoped() throws Exception;
+}

Added: trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/jboss-aop.xml
===================================================================
--- trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/jboss-aop.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/jboss-aop.xml	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+	<loader-repository>aop.loading:loader=scope1</loader-repository>
+	
+   <interceptor class="org.jboss.test.aop.scopedattach.ScopedInterceptor" scope="PER_INSTANCE">
+      <attribute name="value">11</attribute>
+   </interceptor>
+   <interceptor class="org.jboss.test.aop.scopedattach.ScopedPJInterceptor" scope="PER_JOINPOINT">
+      <attribute name="value">11</attribute>
+   </interceptor>
+   <interceptor class="org.jboss.test.aop.scopedattach.ScopedPCInterceptor" scope="PER_CLASS">
+      <attribute name="value">11</attribute>
+   </interceptor>
+   <interceptor class="org.jboss.test.aop.scopedattach.ScopedPCJInterceptor" scope="PER_CLASS_JOINPOINT">
+      <attribute name="value">11</attribute>
+   </interceptor>
+   <aspect class="org.jboss.test.aop.scopedattach.ScopedAspect">
+      <attribute name="value">21</attribute>
+   </aspect>
+   <aspect factory="org.jboss.test.aop.scopedattach.ScopedAspectFactory"/>
+   <stack name="stuff">
+      <advice aspect="org.jboss.test.aop.scopedattach.ScopedAspectFactory" name="test"/>
+      <interceptor-ref name="org.jboss.test.aop.scopedattach.ScopedPJInterceptor"/>
+      <interceptor-ref name="org.jboss.test.aop.scopedattach.ScopedPCInterceptor"/>
+      <interceptor-ref name="org.jboss.test.aop.scopedattach.ScopedPCJInterceptor"/>
+   </stack>
+
+   <bind pointcut="all(org.jboss.test.aop.scopedattach.POJO)">
+      <interceptor-ref name="org.jboss.test.aop.scopedattach.ScopedInterceptor"/>
+      <advice aspect="org.jboss.test.aop.scopedattach.ScopedAspect" name="test"/>
+      <stack-ref name="stuff"/>
+   </bind>
+
+   <metadata tag="test" class="org.jboss.test.aop.scopedattach.POJO">
+      <constructor expr="POJO()">
+         <data>ctor1</data>
+      </constructor>
+      <method expr="void method(..)">
+         <data>method1</data>
+      </method>
+   </metadata>
+   
+   <metadata-loader tag="custom" class="org.jboss.test.aop.scopedattach.ScopedMetadataLoader"/>
+	<metadata tag="custom" class="org.jboss.test.aop.scopedattach.POJO">
+	      <data>custom1</data>
+	</metadata>
+   
+   <!-- Make sure we can see global aspects -->
+   <metadata tag="transaction" class="org.jboss.test.aop.scopedattach.POJO">
+      <method name="method">
+         <trans-attribute>Required</trans-attribute>
+      </method>
+   </metadata>
+</aop>

Added: trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/jboss-service.xml
===================================================================
--- trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/jboss-service.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/jboss-service.xml	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+   <loader-repository>
+   	aop.loading:loader=scope1
+   </loader-repository>
+	<mbean code="org.jboss.test.aop.scopedattach.ScopedTester" name="jboss.aop:name=ScopedTester1">
+	   <attribute name="ExpectedInterceptorValue">11</attribute>
+	   <attribute name="ExpectedAspectValue">21</attribute>
+	   <attribute name="MetadataSuffix">1</attribute>
+	</mbean>
+</server>

Added: trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/prepare-aop.xml
===================================================================
--- trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/prepare-aop.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/aop/scoped-attach/sar1/META-INF/prepare-aop.xml	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+   <prepare expr="all(org.jboss.test.aop.scopedattach.POJO)"/>
+</aop>

Added: trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/jboss-aop.xml
===================================================================
--- trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/jboss-aop.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/jboss-aop.xml	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+	<loader-repository>aop.loading:loader=scope2</loader-repository>
+	
+   <interceptor class="org.jboss.test.aop.scopedattach.ScopedInterceptor" scope="PER_INSTANCE">
+      <attribute name="value">12</attribute>
+   </interceptor>
+   <interceptor class="org.jboss.test.aop.scopedattach.ScopedPJInterceptor" scope="PER_JOINPOINT">
+      <attribute name="value">12</attribute>
+   </interceptor>
+   <interceptor class="org.jboss.test.aop.scopedattach.ScopedPCInterceptor" scope="PER_CLASS">
+      <attribute name="value">12</attribute>
+   </interceptor>
+   <interceptor class="org.jboss.test.aop.scopedattach.ScopedPCJInterceptor" scope="PER_CLASS_JOINPOINT">
+      <attribute name="value">12</attribute>
+   </interceptor>   
+   <aspect class="org.jboss.test.aop.scopedattach.ScopedAspect">
+      <attribute name="value">22</attribute>
+   </aspect>
+   <aspect factory="org.jboss.test.aop.scopedattach.ScopedAspectFactory"/>
+   <stack name="stuff">
+      <advice aspect="org.jboss.test.aop.scopedattach.ScopedAspectFactory" name="test"/>
+      <interceptor-ref name="org.jboss.test.aop.scopedattach.ScopedPJInterceptor"/>
+      <interceptor-ref name="org.jboss.test.aop.scopedattach.ScopedPCInterceptor"/>
+      <interceptor-ref name="org.jboss.test.aop.scopedattach.ScopedPCJInterceptor"/>
+   </stack>
+
+   <bind pointcut="all(org.jboss.test.aop.scopedattach.POJO)">
+      <interceptor-ref name="org.jboss.test.aop.scopedattach.ScopedInterceptor"/>
+      <advice aspect="org.jboss.test.aop.scopedattach.ScopedAspect" name="test"/>
+      <stack-ref name="stuff"/>
+   </bind>
+   
+   <metadata tag="test" class="org.jboss.test.aop.scopedattach.POJO">
+      <constructor expr="POJO()">
+         <data>ctor2</data>
+      </constructor>
+      <method expr="void method(..)">
+         <data>method2</data>
+      </method>
+   </metadata>
+
+   <metadata-loader tag="custom" class="org.jboss.test.aop.scopedattach.ScopedMetadataLoader"/>
+	<metadata tag="custom" class="org.jboss.test.aop.scopedattach.POJO">
+	      <data>custom2</data>
+	</metadata>
+
+   <!-- Make sure we can see global aspects -->
+   <metadata tag="transaction" class="org.jboss.test.aop.scopedattach.POJO">
+      <method name="method">
+         <trans-attribute>Required</trans-attribute>
+      </method>
+   </metadata>
+</aop>

Added: trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/jboss-service.xml
===================================================================
--- trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/jboss-service.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/jboss-service.xml	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+   <loader-repository>
+   	aop.loading:loader=scope2
+      <loader-repository-config>java2ParentDelegation=true</loader-repository-config> 
+   </loader-repository>
+	<mbean code="org.jboss.test.aop.scopedattach.ScopedTester" name="jboss.aop:name=ScopedTester2">
+	   <attribute name="ExpectedInterceptorValue">12</attribute>
+	   <attribute name="ExpectedAspectValue">22</attribute>
+	   <attribute name="MetadataSuffix">2</attribute>
+	</mbean>
+</server>

Added: trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/prepare-aop.xml
===================================================================
--- trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/prepare-aop.xml	                        (rev 0)
+++ trunk/testsuite/src/resources/aop/scoped-attach/sar2/META-INF/prepare-aop.xml	2007-02-15 23:48:16 UTC (rev 60579)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<aop>
+   <prepare expr="all(org.jboss.test.aop.scopedattach.POJO)"/>
+</aop>




More information about the jboss-cvs-commits mailing list