[jboss-cvs] JBossAS SVN: r58775 - in projects/aop/trunk/aop: . src/main/org/jboss/aop/instrument src/resources/test/regression src/test/org/jboss/test/aop/regression src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 30 11:36:51 EST 2006


Author: kabir.khan at jboss.com
Date: 2006-11-30 11:36:45 -0500 (Thu, 30 Nov 2006)
New Revision: 58775

Added:
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnly.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/TestAnnotation.java
Modified:
   projects/aop/trunk/aop/build.xml
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java
   projects/aop/trunk/aop/src/resources/test/regression/jboss-aop.xml
Log:
[JBAOP-316] When intercepting method execution, only the wrapper method with the original name should have the annotations. The "internal" method containing the original method body should not have the annotations

Modified: projects/aop/trunk/aop/build.xml
===================================================================
--- projects/aop/trunk/aop/build.xml	2006-11-30 16:19:07 UTC (rev 58774)
+++ projects/aop/trunk/aop/build.xml	2006-11-30 16:36:45 UTC (rev 58775)
@@ -364,7 +364,7 @@
          </fileset>
          <fileset file="docs/jboss-aop_1_0.dtd"/>
       </jar>
-      <jar jarfile="${build.lib}/pluggable-instrumentor.jar"
+     <jar jarfile="${build.lib}/pluggable-instrumentor.jar"
          manifest="${build.etc}/pluggable-instrumentor.mf">
          <fileset dir="${build.classes}">
             <!-- Include everything else -->
@@ -592,4 +592,13 @@
          </fileset>
       </copy>
    </target>
+	<target name="array-agent" depends="init">
+      <jar jarfile="${build.lib}/jboss-arraytestagent.jar"
+         manifest="${source.res}/test/array/MANIFEST.MF">
+         <fileset dir="C:/cygwin/home/Kabir/sourcecontrol/jboss-aop/aop/output/eclipse-classes">
+            <include name="org/jboss/test/aop/array/Agent.class"/>
+            <include name="org/jboss/test/aop/array/AOPTransformer.class"/>
+         </fileset>
+      </jar>
+	</target>
 </project>

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java	2006-11-30 16:19:07 UTC (rev 58774)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/GeneratedAdvisorMethodExecutionTransformer.java	2006-11-30 16:36:45 UTC (rev 58775)
@@ -124,14 +124,14 @@
             clazz);
       clazz.addMethod(original);
       long hash = JavassistMethodHashing.methodHash(original);
-      copyAnnotations(mixinMethod, original);
+      moveAnnotations(mixinMethod, original);
 
       String wrappedName = ClassAdvisor.notAdvisedMethodName(clazz.getName(), originalName);
       CtMethod wmethod = CtNewMethod.copy(original, clazz, null);
 
       wmethod.setName(wrappedName);
       clazz.addMethod(wmethod);
-      copyAnnotations(original, wmethod);
+      moveAnnotations(original, wmethod);
 
       original.setName(wrappedName);
       wmethod.setName(originalName);
@@ -164,7 +164,7 @@
       String originalName = trans.getOriginalName();
       wmethod.setName(wrappedName);
       trans.getClazz().addMethod(wmethod);
-      copyAnnotations(trans.getMethod(), wmethod);
+      moveAnnotations(trans.getMethod(), wmethod);
       trans.getMethod().setName(wrappedName);
       wmethod.setName(originalName);
 

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java	2006-11-30 16:19:07 UTC (rev 58774)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/MethodExecutionTransformer.java	2006-11-30 16:36:45 UTC (rev 58775)
@@ -235,7 +235,7 @@
       }
    }
 
-   protected void copyAnnotations(CtMethod src, CtMethod dest)
+   protected void moveAnnotations(CtMethod src, CtMethod dest)
    {
       MethodInfo mi = src.getMethodInfo2();
       MethodInfo wmi = dest.getMethodInfo2();
@@ -249,7 +249,10 @@
       {
          wmi.addAttribute(visible.copy(wmi.getConstPool(), new HashMap()));
       }
+      mi.addAttribute(new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.invisibleTag));
+      mi.addAttribute(new AnnotationsAttribute(mi.getConstPool(), AnnotationsAttribute.visibleTag));
    }
+   
 
    protected static String getAopReturnStr(CtMethod method)throws NotFoundException
    {

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java	2006-11-30 16:19:07 UTC (rev 58774)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/NonOptimizedMethodExecutionTransformer.java	2006-11-30 16:36:45 UTC (rev 58775)
@@ -53,7 +53,7 @@
       String originalName = trans.getOriginalName();
       wmethod.setName(wrappedName);
       trans.getClazz().addMethod(wmethod);
-      copyAnnotations(trans.getMethod(), wmethod);
+      moveAnnotations(trans.getMethod(), wmethod);
       trans.getMethod().setName(wrappedName);
       wmethod.setName(originalName);
       

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java	2006-11-30 16:19:07 UTC (rev 58774)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/OptimizedMethodExecutionTransformer.java	2006-11-30 16:36:45 UTC (rev 58775)
@@ -55,7 +55,7 @@
       String originalName = trans.getOriginalName();
       wmethod.setName(wrappedName);
       trans.getClazz().addMethod(wmethod);
-      copyAnnotations(trans.getMethod(), wmethod);
+      moveAnnotations(trans.getMethod(), wmethod);
       String optimizedInvocation = OptimizedMethodInvocations.createOptimizedInvocationClass(trans.getInstrumentor(), trans.getClazz(), trans.getMethod());
       trans.getMethod().setName(wrappedName);
       wmethod.setName(originalName);

Modified: projects/aop/trunk/aop/src/resources/test/regression/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/regression/jboss-aop.xml	2006-11-30 16:19:07 UTC (rev 58774)
+++ projects/aop/trunk/aop/src/resources/test/regression/jboss-aop.xml	2006-11-30 16:36:45 UTC (rev 58775)
@@ -153,4 +153,6 @@
    <bind pointcut="execution(* org.jboss.test.aop.regression.jbaop279native.POJO->nativeMethod())">
       <interceptor class="org.jboss.test.aop.regression.jbaop279native.ReturningInterceptor"/>
    </bind>
+   
+   <prepare expr="all(org.jboss.test.aop.regression.jbaop316annotationsinwrapperonly.POJO)"/>
 </aop>

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnly.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnly.java	2006-11-30 16:19:07 UTC (rev 58774)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/AnnotationsInWrapperMethodOnly.java	2006-11-30 16:36:45 UTC (rev 58775)
@@ -0,0 +1,79 @@
+/*
+  * 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.regression.jbaop316annotationsinwrapperonly;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+
+import org.jboss.aop.Advised;
+import org.jboss.test.aop.AOPTestWithSetup;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+
+/**
+ * http://jira.jboss.com/jira/browse/JBAOP-316
+ * 
+ * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
+ * @version $Revision: 45977 $
+ */
+public class AnnotationsInWrapperMethodOnly extends AOPTestWithSetup
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("AnnotationsInWrapperMethodOnly");
+      suite.addTestSuite(AnnotationsInWrapperMethodOnly.class);
+      return suite;
+   }
+
+   public AnnotationsInWrapperMethodOnly(String name)
+   {
+      super(name);
+   }
+
+   public void testAnnotationNotInInternalCopy()throws Exception
+   {
+      Method[] methods = POJO.class.getMethods();
+      
+      ArrayList hasAnnotation = new ArrayList();
+      for (int i = 0 ; i < methods.length ; i++)
+      {
+         if (methods[i].isAnnotationPresent(TestAnnotation.class))
+         {
+            hasAnnotation.add(methods[i].getName());
+         }
+      }
+      
+      assertFalse("Expected to find annotation for 'method'", hasAnnotation.size() == 0);
+      assertTrue("Expected to find annotation for 'method' only, it was found for " + hasAnnotation, hasAnnotation.size() == 1);
+      assertEquals("method", hasAnnotation.get(0));
+      assertTrue("Class was not woven", Advised.class.isAssignableFrom(POJO.class));
+   }
+
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java	2006-11-30 16:19:07 UTC (rev 58774)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/POJO.java	2006-11-30 16:36:45 UTC (rev 58775)
@@ -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.regression.jbaop316annotationsinwrapperonly;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class POJO
+{
+   @TestAnnotation
+   public void method()
+   {
+      
+   }
+}

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/TestAnnotation.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/TestAnnotation.java	2006-11-30 16:19:07 UTC (rev 58774)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/regression/jbaop316annotationsinwrapperonly/TestAnnotation.java	2006-11-30 16:36:45 UTC (rev 58775)
@@ -0,0 +1,35 @@
+/*
+* 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.regression.jbaop316annotationsinwrapperonly;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+public @interface TestAnnotation {
+
+}




More information about the jboss-cvs-commits mailing list