[jboss-cvs] JBossAS SVN: r59703 - in branches/Branch_AOP_1_5/aop: src/main/org/jboss/aop and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 17 12:03:31 EST 2007


Author: kabir.khan at jboss.com
Date: 2007-01-17 12:03:31 -0500 (Wed, 17 Jan 2007)
New Revision: 59703

Added:
   branches/Branch_AOP_1_5/aop/src/resources/test/container/
   branches/Branch_AOP_1_5/aop/src/resources/test/container/jboss-aop.xml
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/Annotation.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/Child.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/ContainerTestCase.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/Parent.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/TestInterceptor.java
Modified:
   branches/Branch_AOP_1_5/aop/build.xml
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/Advisor.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassContainer.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/container/ClassProxyContainer.java
Log:
[JBAOP-340] Chain overriding for ClassContainer, port over changes from trunk

Modified: branches/Branch_AOP_1_5/aop/build.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/build.xml	2007-01-17 16:43:50 UTC (rev 59702)
+++ branches/Branch_AOP_1_5/aop/build.xml	2007-01-17 17:03:31 UTC (rev 59703)
@@ -1118,6 +1118,14 @@
    <!-- ==================================================================================== -->
 
    <target name="proxy-test" depends="compile-test-classes">
+      <taskdef name="annotationc" classname="org.jboss.aop.ant.AnnotationC" classpathref="jboss.aop.classpath"/>
+      <mkdir dir="${build.reports}"/>
+      <annotationc compilerclasspathref="aop.task.classpath" bytecode="true">
+         <classpath refid="aop.task.classpath"/>
+         <classpath path="${build.tests.classes}"/>
+         <src path="${source.tests.java}"/>
+         <include name="org/jboss/test/aop/container/*.java"/>
+      </annotationc>
       <junit printsummary="yes" fork="no" haltonfailure="no" >
          <classpath>
             <path refid="test.classpath"/>
@@ -1128,6 +1136,17 @@
          <formatter type="xml"/>
          <test fork="yes" name="org.jboss.test.aop.proxy.ProxyTestCase" todir="${build.reports}"/>
       </junit>
+	   <junit printsummary="yes" fork="yes" haltonfailure="no">
+		   <sysproperty key="jboss.aop.path" value="${source.res}/test/container/jboss-aop.xml"/>
+		   <classpath>
+		      <path refid="test.classpath"/>
+		      <pathelement location="${build.tests.classes}"/>
+		      <pathelement location="docs"/>
+		   </classpath>
+		   <sysproperty key="jboss-junit-configuration" value="jdk50"/>
+		   <formatter type="plain" extension="-jdk50.txt"/>
+	      <test name="org.jboss.test.aop.container.ContainerTestCase" todir="${build.reports}"/>
+	   </junit>
    </target>
 
    <!-- ==================================================================================== -->

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/Advisor.java	2007-01-17 16:43:50 UTC (rev 59702)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/Advisor.java	2007-01-17 17:03:31 UTC (rev 59703)
@@ -65,6 +65,7 @@
 import org.jboss.aop.metadata.FieldMetaData;
 import org.jboss.aop.metadata.MethodMetaData;
 import org.jboss.aop.metadata.SimpleMetaData;
+import org.jboss.util.NotImplementedException;
 
 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
 import EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArraySet;
@@ -896,7 +897,7 @@
     * public class Super {<BR/>
     * &nbsp;&nbsp;void method(){}<BR/>
     * }<BR/>
-    * <BR/>    
+    * <BR/>
     * public class Sub etxends Super {<BR/>
     * }<BR/>
     * </code>
@@ -911,10 +912,20 @@
     * </code><BR/>
     * Super.method() will be intercepted by A only<BR/>
     * Sub.method() will be intercepted by A and B
-    *  
+    *
     */
-   protected boolean chainOverridingForInheritedMethods()
+   public boolean chainOverridingForInheritedMethods()
    {
       return false;
    }
+
+   /**
+    * @param overriding the new value of chainOverridingForInheritedMethods
+    * @see Advisor#chainOverridingForInheritedMethods()
+    */
+   protected void setChainOverridingForInheritedMethods(boolean overriding)
+   {
+      //Implemented by base-classes
+      throw new NotImplementedException("Not a legal operation for Advisor");
+   }
 }
\ No newline at end of file

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassContainer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassContainer.java	2007-01-17 16:43:50 UTC (rev 59702)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassContainer.java	2007-01-17 17:03:31 UTC (rev 59703)
@@ -45,6 +45,8 @@
  */
 public class ClassContainer extends Advisor
 {
+   private boolean chainOverridingForInheritedMethods;
+
    public ClassContainer(String name, AspectManager manager)
    {
       super(name, manager);
@@ -259,4 +261,22 @@
       
       doesHaveAspects = adviceBindings.size() > 0;
    }
+   
+   /**
+    * @return the value of chainOverridingForInheritedMethods
+    * @see Advisor#chainOverridingForInheritedMethods()
+    */
+   public boolean chainOverridingForInheritedMethods()
+   {
+      return chainOverridingForInheritedMethods;
+   }
+
+   /**
+    * @param overriding the new value of chainOverridingForInheritedMethods
+    * @see Advisor#chainOverridingForInheritedMethods()
+    */
+   protected void setChainOverridingForInheritedMethods(boolean overriding)
+   {
+      this.chainOverridingForInheritedMethods = overriding;
+   }
 }

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java	2007-01-17 16:43:50 UTC (rev 59702)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/GeneratedClassAdvisor.java	2007-01-17 17:03:31 UTC (rev 59703)
@@ -580,7 +580,7 @@
    /**
     * @see Advisor#chainOverridingForInheritedMethods() 
     */
-   protected boolean chainOverridingForInheritedMethods()
+   public boolean chainOverridingForInheritedMethods()
    {
       return true;
    }

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/container/ClassProxyContainer.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/container/ClassProxyContainer.java	2007-01-17 16:43:50 UTC (rev 59702)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/proxy/container/ClassProxyContainer.java	2007-01-17 17:03:31 UTC (rev 59703)
@@ -144,7 +144,7 @@
       super.initializeClassContainer();
    }
 
-   protected boolean chainOverridingForInheritedMethods()
+   public boolean chainOverridingForInheritedMethods()
    {
       return true;
    }

Added: branches/Branch_AOP_1_5/aop/src/resources/test/container/jboss-aop.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/src/resources/test/container/jboss-aop.xml	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/resources/test/container/jboss-aop.xml	2007-01-17 17:03:31 UTC (rev 59703)
@@ -0,0 +1,6 @@
+<aop>
+   <interceptor class="org.jboss.test.aop.container.TestInterceptor"/>
+   <bind pointcut="execution(* @org.jboss.test.aop.container.Annotation->*(..))">
+   	<interceptor-ref name="org.jboss.test.aop.container.TestInterceptor"/>
+   </bind>
+</aop>
\ No newline at end of file

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/Annotation.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/Annotation.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/Annotation.java	2007-01-17 17:03:31 UTC (rev 59703)
@@ -0,0 +1,31 @@
+/*
+* 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.container;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface Annotation {
+
+}

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

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/ContainerTestCase.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/ContainerTestCase.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/ContainerTestCase.java	2007-01-17 17:03:31 UTC (rev 59703)
@@ -0,0 +1,112 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.aop.container;
+
+import java.lang.reflect.Method;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.ClassContainer;
+import org.jboss.aop.MethodInfo;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.aop.util.MethodHashing;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+*
+* @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+* @version $Revision: 45977 $
+*/
+public class ContainerTestCase extends TestCase
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("ContainerTestCase");
+      suite.addTestSuite(ContainerTestCase.class);
+      return suite;
+   }
+
+   public ContainerTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testContainerWithNoChainOverriding() throws Throwable
+   {
+      invokeContainer(false);
+   }
+
+   public void testContainerWithChainOverriding() throws Throwable
+   {
+      invokeContainer(true);
+   }
+
+   public void invokeContainer(boolean overriding) throws Throwable
+   {
+         AspectManager manager = AspectManager.instance();
+         ClassContainer container = (overriding ) ? new ContainerWithChainOverriding("X", manager) : new ClassContainer("X", manager);
+         container.setClass(Child.class);
+         container.initializeClassContainer();
+         Child child = new Child();
+         
+         MethodInvocation invocation = getMethodInvocation(container, "childMethod", child);
+         TestInterceptor.invoked = false;
+         container.dynamicInvoke(child, invocation);
+         assertTrue(TestInterceptor.invoked);
+         
+         invocation = getMethodInvocation(container, "parentMethod", child);
+         TestInterceptor.invoked = false;
+         container.dynamicInvoke(child, invocation);
+         assertEquals(overriding, TestInterceptor.invoked);
+   }
+   
+   private MethodInvocation getMethodInvocation(ClassContainer advisor, String methodName, Object target) throws Exception
+   {
+      Method method = target.getClass().getMethod(methodName, new Class[0]);
+      long hash = MethodHashing.calculateHash(method);
+      MethodInfo info = advisor.getMethodInfo(hash);
+      Interceptor[] interceptors = info.getInterceptors();
+      MethodInvocation invocation = new MethodInvocation(interceptors, hash, method, method, advisor);
+      invocation.setTargetObject(target);
+      invocation.setArguments(new Object[0]);
+      return invocation;
+   }
+   
+   static class ContainerWithChainOverriding extends ClassContainer
+   {
+      public ContainerWithChainOverriding(String name, AspectManager manager)
+      {
+         super(name, manager);
+         super.setChainOverridingForInheritedMethods(true);
+      }
+   }
+}
+

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

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/TestInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/TestInterceptor.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/container/TestInterceptor.java	2007-01-17 17:03:31 UTC (rev 59703)
@@ -0,0 +1,47 @@
+/*
+* 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.container;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestInterceptor implements Interceptor
+{
+   public static boolean invoked = true;
+   
+   public String getName()
+   {
+      return TestInterceptor.class.getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      invoked = true;
+      return invocation.invokeNext();
+   }
+
+}




More information about the jboss-cvs-commits mailing list