[jboss-cvs] JBossAS SVN: r88656 - in projects/microcontainer/trunk/aop-mc-int/src: test/java/org/jboss/test/microcontainer/beans and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon May 11 13:28:33 EDT 2009


Author: kabir.khan at jboss.com
Date: 2009-05-11 13:28:33 -0400 (Mon, 11 May 2009)
New Revision: 88656

Added:
   projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/ScopedAspectFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/ScopedFactoryAspect.java
   projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassAopTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassJoinpointAopTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerInstanceAopTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerJoinpointAopTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerVmAopTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassAopTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassJoinpointAopTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerInstanceAopTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerJoinpointAopTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerVmAopTestCase.xml
Modified:
   projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/beans/DelegatingBeanAspectFactory.java
Log:
[JBMICROCONT-427] Cache aspect factory in DelegatingBeanAspectFactory

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/beans/DelegatingBeanAspectFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/beans/DelegatingBeanAspectFactory.java	2009-05-11 17:22:25 UTC (rev 88655)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/java/org/jboss/aop/microcontainer/beans/DelegatingBeanAspectFactory.java	2009-05-11 17:28:33 UTC (rev 88656)
@@ -54,6 +54,8 @@
    
    protected KernelControllerContext context;
    
+   protected AspectFactory aspectFactory;
+   
    public DelegatingBeanAspectFactory(String name, BeanFactory factory, Element element)
    {
       this.name = name;
@@ -112,44 +114,47 @@
       return factory.createPerJoinpoint(advisor, instanceAdvisor, jp);
    }
 
-   protected AspectFactory doCreate()
+   protected synchronized AspectFactory doCreate()
    {
       try
       {
-         log.debug("Creating advice " + name);
-
-         PushedClassLoaderMetaData pcmd = null;
-         if (((GenericBeanFactory)factory).getClassLoader() == null)
+         if (aspectFactory == null)
          {
-            pcmd = new PushedClassLoaderMetaData();
-            ((GenericBeanFactory)factory).setClassLoader(pcmd);
-         }
-         
-         Object object = null;
-         try
-         {
-            //Try without looking at the context first which is what shold be used when running scoped in AS
-            object = factory.createBean();
-         }
-         catch(Throwable t)
-         {
-            if (pcmd != null)
+            log.debug("Creating advice " + name);
+   
+            PushedClassLoaderMetaData pcmd = null;
+            if (((GenericBeanFactory)factory).getClassLoader() == null)
             {
-               pcmd.setLookAtContext(true);
+               pcmd = new PushedClassLoaderMetaData();
+               ((GenericBeanFactory)factory).setClassLoader(pcmd);
             }
-            else
+            
+            Object object = null;
+            try
             {
-               throw new RuntimeException(t);
+               //Try without looking at the context first which is what shold be used when running scoped in AS
+               object = factory.createBean();
             }
-            object = factory.createBean();
+            catch(Throwable t)
+            {
+               if (pcmd != null)
+               {
+                  pcmd.setLookAtContext(true);
+               }
+               else
+               {
+                  throw new RuntimeException(t);
+               }
+               object = factory.createBean();
+            }
+   
+            aspectFactory = (AspectFactory)object;
+            if (aspectFactory instanceof XmlLoadable)
+            {
+               ((XmlLoadable)aspectFactory).importXml(element);
+            }
          }
-
-         AspectFactory fac = (AspectFactory)object;
-         if (fac instanceof XmlLoadable)
-         {
-            ((XmlLoadable)fac).importXml(element);
-         }
-         return fac;
+         return aspectFactory;
       }
       catch (Throwable throwable)
       {

Added: projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/ScopedAspectFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/ScopedAspectFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/ScopedAspectFactory.java	2009-05-11 17:28:33 UTC (rev 88656)
@@ -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.microcontainer.beans;
+
+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: 1.1 $
+ */
+public class ScopedAspectFactory implements AspectFactory
+{
+   public Object createPerClass(Advisor advisor)
+   {
+      return new ScopedFactoryAspect();
+   }
+
+   public Object createPerInstance(Advisor advisor, InstanceAdvisor instanceAdvisor)
+   {
+      return new ScopedFactoryAspect();
+   }
+
+   public Object createPerJoinpoint(Advisor advisor, Joinpoint jp)
+   {
+      return new ScopedFactoryAspect();
+   }
+
+   public Object createPerJoinpoint(Advisor advisor, InstanceAdvisor instanceAdvisor, Joinpoint jp)
+   {
+      return new ScopedFactoryAspect();
+   }
+
+   public Object createPerVM()
+   {
+      return new ScopedFactoryAspect();
+   }
+   
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/ScopedFactoryAspect.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/ScopedFactoryAspect.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/ScopedFactoryAspect.java	2009-05-11 17:28:33 UTC (rev 88656)
@@ -0,0 +1,41 @@
+/*
+* 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.microcontainer.beans;
+
+import org.jboss.aop.joinpoint.MethodInvocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedFactoryAspect
+{
+   public static ScopedFactoryAspect last;
+   
+   
+   public Object advice(MethodInvocation inv) throws Throwable
+   {
+      last = this;
+      return inv.invokeNext();
+   }   
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassAopTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassAopTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassAopTestCase.java	2009-05-11 17:28:33 UTC (rev 88656)
@@ -0,0 +1,64 @@
+/*
+* 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.microcontainer.beans.test;
+
+import org.jboss.test.aop.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.beans.POJO;
+import org.jboss.test.microcontainer.beans.POJO2;
+import org.jboss.test.microcontainer.beans.ScopedFactoryAspect;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedAspectFactoryPerClassAopTestCase extends AOPMicrocontainerTest
+{
+
+   public ScopedAspectFactoryPerClassAopTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testPerClass() throws Exception
+   {
+      POJO pojo = (POJO)getBean("POJO1A");
+      POJO2 pojo2 = (POJO2)getBean("POJO2");
+      
+      ScopedFactoryAspect.last = null;
+      pojo.method();
+      ScopedFactoryAspect a1 = ScopedFactoryAspect.last;
+      assertNotNull(a1);
+      
+      ScopedFactoryAspect.last = null;
+      pojo2.method();
+      ScopedFactoryAspect a2 = ScopedFactoryAspect.last;
+      assertNotNull(a2);
+      assertNotSame(a1, a2);
+      
+      ScopedFactoryAspect.last = null;
+      pojo.method(3);
+      ScopedFactoryAspect a3 = ScopedFactoryAspect.last;
+      assertNotNull(a3);
+      assertSame(a1, a3);
+   }
+}
\ No newline at end of file

Added: projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassJoinpointAopTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassJoinpointAopTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassJoinpointAopTestCase.java	2009-05-11 17:28:33 UTC (rev 88656)
@@ -0,0 +1,102 @@
+/*
+* 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.microcontainer.beans.test;
+
+import org.jboss.test.aop.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.beans.POJO;
+import org.jboss.test.microcontainer.beans.POJO2;
+import org.jboss.test.microcontainer.beans.ScopedFactoryAspect;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedAspectFactoryPerClassJoinpointAopTestCase extends AOPMicrocontainerTest
+{
+
+   public ScopedAspectFactoryPerClassJoinpointAopTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testPerClassJoinPoint() throws Exception
+   {
+      POJO pojoA = (POJO)getBean("POJO1A");
+      POJO pojoB = (POJO)getBean("POJO1B");
+      POJO2 pojo2 = (POJO2)getBean("POJO2");
+   
+      ScopedFactoryAspect.last = null;      
+      pojoA.method();
+      ScopedFactoryAspect a1 = ScopedFactoryAspect.last;
+      assertNotNull(a1);
+      
+      ScopedFactoryAspect.last = null;      
+      pojoA.method(1);
+      ScopedFactoryAspect a2 = ScopedFactoryAspect.last;
+      assertNotNull(a2);
+      
+      ScopedFactoryAspect.last = null;      
+      pojoB.method();
+      ScopedFactoryAspect a3 = ScopedFactoryAspect.last;
+      assertNotNull(a3);
+      
+      ScopedFactoryAspect.last = null;      
+      pojoB.method(1);
+      ScopedFactoryAspect a4 = ScopedFactoryAspect.last;
+      assertNotNull(a4);
+      
+      ScopedFactoryAspect.last = null;      
+      pojo2.method();
+      ScopedFactoryAspect a5 = ScopedFactoryAspect.last;
+      assertNotNull(a5);
+      
+      ScopedFactoryAspect.last = null;      
+      pojo2.method(1);
+      ScopedFactoryAspect a6 = ScopedFactoryAspect.last;
+      assertNotNull(a6);
+      
+      
+      assertNotSame(a1, a2);
+      assertSame(a1, a3);
+      assertNotSame(a1, a4);
+      assertNotSame(a1, a5);
+      assertNotSame(a1, a6);
+      assertNotSame(a2, a3);
+      assertSame(a2, a4);
+      assertNotSame(a2, a5);
+      assertNotSame(a2, a6);
+      assertNotSame(a3, a4);
+      assertNotSame(a3, a5);
+      assertNotSame(a3, a6);
+      assertNotSame(a4, a5);
+      assertNotSame(a4, a6);
+      assertNotSame(a5, a6);
+      
+      ScopedFactoryAspect.last = null;
+      pojoA.method();
+      ScopedFactoryAspect a7 = ScopedFactoryAspect.last;
+      assertNotNull(a7);
+      assertSame(a1, a7);
+   }
+
+}
\ No newline at end of file

Added: projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerInstanceAopTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerInstanceAopTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerInstanceAopTestCase.java	2009-05-11 17:28:33 UTC (rev 88656)
@@ -0,0 +1,84 @@
+/*
+* 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.microcontainer.beans.test;
+
+import org.jboss.test.aop.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.beans.POJO;
+import org.jboss.test.microcontainer.beans.POJO2;
+import org.jboss.test.microcontainer.beans.ScopedFactoryAspect;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedAspectFactoryPerInstanceAopTestCase extends AOPMicrocontainerTest
+{
+
+   public ScopedAspectFactoryPerInstanceAopTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testPerInstance() throws Exception
+   {
+      POJO pojoA = (POJO)getBean("POJO1A");
+      POJO pojoB = (POJO)getBean("POJO1B");
+      POJO2 pojo2 = (POJO2)getBean("POJO2");
+      
+      ScopedFactoryAspect.last = null;      
+      pojoA.method();
+      ScopedFactoryAspect a1 = ScopedFactoryAspect.last;
+      assertNotNull(a1);
+      
+      ScopedFactoryAspect.last = null;      
+      pojoA.method(2);
+      ScopedFactoryAspect a2 = ScopedFactoryAspect.last;
+      assertNotNull(a2);
+      assertSame(a1, a2);
+      
+      ScopedFactoryAspect.last = null;      
+      pojoB.method();
+      ScopedFactoryAspect a3 = ScopedFactoryAspect.last;
+      assertNotNull(a3);
+      assertNotSame(a3, a2);
+      
+      ScopedFactoryAspect.last = null;      
+      pojoB.method(4);
+      ScopedFactoryAspect a4 = ScopedFactoryAspect.last;
+      assertNotNull(a4);
+      assertSame(a3, a4);
+      
+      ScopedFactoryAspect.last = null;      
+      pojo2.method();
+      ScopedFactoryAspect a5 = ScopedFactoryAspect.last;
+      assertNotNull(a5);
+      assertNotSame(a5, a4);
+      assertNotSame(a5, a2);
+      
+      ScopedFactoryAspect.last = null;      
+      pojo2.method(4);
+      ScopedFactoryAspect a6 = ScopedFactoryAspect.last;
+      assertNotNull(a6);
+      assertSame(a5, a6);
+   }
+}
\ No newline at end of file

Added: projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerJoinpointAopTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerJoinpointAopTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerJoinpointAopTestCase.java	2009-05-11 17:28:33 UTC (rev 88656)
@@ -0,0 +1,100 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors. 
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.microcontainer.beans.test;
+
+import org.jboss.test.aop.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.beans.POJO;
+import org.jboss.test.microcontainer.beans.POJO2;
+import org.jboss.test.microcontainer.beans.ScopedFactoryAspect;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedAspectFactoryPerJoinpointAopTestCase extends AOPMicrocontainerTest
+{
+
+   public ScopedAspectFactoryPerJoinpointAopTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testPerJoinPoint() throws Exception
+   {
+      POJO pojoA = (POJO)getBean("POJO1A");
+      POJO pojoB = (POJO)getBean("POJO1B");
+      POJO2 pojo2 = (POJO2)getBean("POJO2");
+   
+      ScopedFactoryAspect.last = null;      
+      pojoA.method();
+      ScopedFactoryAspect a1 = ScopedFactoryAspect.last;
+      assertNotNull(a1);
+      
+      ScopedFactoryAspect.last = null;      
+      pojoA.method(1);
+      ScopedFactoryAspect a2 = ScopedFactoryAspect.last;
+      assertNotNull(a2);
+      
+      ScopedFactoryAspect.last = null;      
+      pojoB.method();
+      ScopedFactoryAspect a3 = ScopedFactoryAspect.last;
+      assertNotNull(a3);
+      
+      ScopedFactoryAspect.last = null;      
+      pojoB.method(1);
+      ScopedFactoryAspect a4 = ScopedFactoryAspect.last;
+      assertNotNull(a4);
+      
+      ScopedFactoryAspect.last = null;      
+      pojo2.method();
+      ScopedFactoryAspect a5 = ScopedFactoryAspect.last;
+      assertNotNull(a5);
+      
+      ScopedFactoryAspect.last = null;      
+      pojo2.method(1);
+      ScopedFactoryAspect a6 = ScopedFactoryAspect.last;
+      assertNotNull(a6);
+      
+      assertNotSame(a1, a2);
+      assertNotSame(a1, a3);
+      assertNotSame(a1, a4);
+      assertNotSame(a1, a5);
+      assertNotSame(a1, a6);
+      assertNotSame(a2, a3);
+      assertNotSame(a2, a4);
+      assertNotSame(a2, a5);
+      assertNotSame(a2, a6);
+      assertNotSame(a3, a4);
+      assertNotSame(a3, a5);
+      assertNotSame(a3, a6);
+      assertNotSame(a4, a5);
+      assertNotSame(a4, a6);
+      assertNotSame(a5, a6);
+      
+      ScopedFactoryAspect.last = null;
+      pojoA.method();
+      ScopedFactoryAspect a7 = ScopedFactoryAspect.last;
+      assertNotNull(a7);
+      assertSame(a1, a7);
+   }
+}
\ No newline at end of file

Added: projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerVmAopTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerVmAopTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/java/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerVmAopTestCase.java	2009-05-11 17:28:33 UTC (rev 88656)
@@ -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.microcontainer.beans.test;
+
+import org.jboss.test.aop.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.beans.POJO;
+import org.jboss.test.microcontainer.beans.POJO2;
+import org.jboss.test.microcontainer.beans.ScopedFactoryAspect;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ScopedAspectFactoryPerVmAopTestCase extends AOPMicrocontainerTest
+{
+
+   public ScopedAspectFactoryPerVmAopTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testPerVm() throws Exception
+   {
+      POJO pojo = (POJO)getBean("POJO1A");
+      POJO2 pojo2 = (POJO2)getBean("POJO2");
+   
+      ScopedFactoryAspect.last = null;
+      pojo.method();
+      ScopedFactoryAspect a1 = ScopedFactoryAspect.last;
+      assertNotNull(a1);
+      
+      ScopedFactoryAspect.last = null;
+      pojo2.method();
+      ScopedFactoryAspect a2 = ScopedFactoryAspect.last;
+      assertNotNull(a2);
+      assertSame(a1, a2);
+      
+      ScopedFactoryAspect.last = null;
+      pojo.method(3);
+      ScopedFactoryAspect a3 = ScopedFactoryAspect.last;
+      assertNotNull(a3);
+      assertSame(a1, a3);
+   }
+
+}
\ No newline at end of file

Added: projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassAopTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassAopTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassAopTestCase.xml	2009-05-11 17:28:33 UTC (rev 88656)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+   
+   <aspect xmlns="urn:jboss:aop-beans:1.0" factory="org.jboss.test.microcontainer.beans.ScopedAspectFactory" scope="PER_CLASS"/>
+
+   <bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(* org.jboss.test.microcontainer.beans.POJO*->*(..))">
+      <advice aspect="org.jboss.test.microcontainer.beans.ScopedAspectFactory" name="advice"/>
+   </bind>
+   
+   <bean name="POJO1A" class="org.jboss.test.microcontainer.beans.POJO"/>
+
+   <bean name="POJO1B" class="org.jboss.test.microcontainer.beans.POJO"/>
+   
+   <bean name="POJO2" class="org.jboss.test.microcontainer.beans.POJO2"/>
+   
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassJoinpointAopTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassJoinpointAopTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerClassJoinpointAopTestCase.xml	2009-05-11 17:28:33 UTC (rev 88656)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+   
+   <aspect xmlns="urn:jboss:aop-beans:1.0" factory="org.jboss.test.microcontainer.beans.ScopedAspectFactory" scope="PER_CLASS_JOINPOINT"/>
+
+	<bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(* org.jboss.test.microcontainer.beans.POJO*->*(..))">
+      <advice aspect="org.jboss.test.microcontainer.beans.ScopedAspectFactory" name="advice"/>
+	</bind>
+   
+   <bean name="POJO1A" class="org.jboss.test.microcontainer.beans.POJO"/>
+
+   <bean name="POJO1B" class="org.jboss.test.microcontainer.beans.POJO"/>
+   
+   <bean name="POJO2" class="org.jboss.test.microcontainer.beans.POJO2"/>
+   
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerInstanceAopTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerInstanceAopTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerInstanceAopTestCase.xml	2009-05-11 17:28:33 UTC (rev 88656)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+   
+   <aspect xmlns="urn:jboss:aop-beans:1.0" factory="org.jboss.test.microcontainer.beans.ScopedAspectFactory" scope="PER_INSTANCE"/>
+
+   <bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(* org.jboss.test.microcontainer.beans.POJO*->*(..))">
+      <advice aspect="org.jboss.test.microcontainer.beans.ScopedAspectFactory" name="advice"/>
+   </bind>
+   
+   <bean name="POJO1A" class="org.jboss.test.microcontainer.beans.POJO"/>
+
+   <bean name="POJO1B" class="org.jboss.test.microcontainer.beans.POJO"/>
+   
+   <bean name="POJO2" class="org.jboss.test.microcontainer.beans.POJO2"/>
+   
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerJoinpointAopTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerJoinpointAopTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerJoinpointAopTestCase.xml	2009-05-11 17:28:33 UTC (rev 88656)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+   
+   <aspect xmlns="urn:jboss:aop-beans:1.0" factory="org.jboss.test.microcontainer.beans.ScopedAspectFactory" scope="PER_JOINPOINT"/>
+
+   <bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(* org.jboss.test.microcontainer.beans.POJO*->*(..))">
+      <advice aspect="org.jboss.test.microcontainer.beans.ScopedAspectFactory" name="advice"/>
+   </bind>
+   
+   <bean name="POJO1A" class="org.jboss.test.microcontainer.beans.POJO"/>
+
+   <bean name="POJO1B" class="org.jboss.test.microcontainer.beans.POJO"/>
+   
+   <bean name="POJO2" class="org.jboss.test.microcontainer.beans.POJO2"/>
+   
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerVmAopTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerVmAopTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/test/resources/org/jboss/test/microcontainer/beans/test/ScopedAspectFactoryPerVmAopTestCase.xml	2009-05-11 17:28:33 UTC (rev 88656)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+   
+   <aspect xmlns="urn:jboss:aop-beans:1.0" factory="org.jboss.test.microcontainer.beans.ScopedAspectFactory" scope="PER_VM"/>
+
+   <bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(* org.jboss.test.microcontainer.beans.POJO*->*(..))">
+      <advice aspect="org.jboss.test.microcontainer.beans.ScopedAspectFactory" name="advice"/>
+   </bind>
+   
+   <bean name="POJO1A" class="org.jboss.test.microcontainer.beans.POJO"/>
+
+   <bean name="POJO1B" class="org.jboss.test.microcontainer.beans.POJO"/>
+   
+   <bean name="POJO2" class="org.jboss.test.microcontainer.beans.POJO2"/>
+   
+</deployment>




More information about the jboss-cvs-commits mailing list