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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 22 19:28:19 EST 2007


Author: kabir.khan at jboss.com
Date: 2007-02-22 19:28:19 -0500 (Thu, 22 Feb 2007)
New Revision: 60810

Added:
   branches/Branch_AOP_1_5/aop/src/resources/test/postweavingmixins/
   branches/Branch_AOP_1_5/aop/src/resources/test/postweavingmixins/jboss-aop.xml
   branches/Branch_AOP_1_5/aop/src/resources/test/postweavingmixins/mixins-aop.xml
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/MarkerInterface.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/Mixin.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/MixinInterface.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/PostWeavingMixinsTestCase.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/SanityInterceptor.java
   branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/WovenPOJO.java
Modified:
   branches/Branch_AOP_1_5/aop/build.xml
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassAdvisor.java
Log:
[JBAOP-365] Fix error populating mixin methods when intitialising the advisor for an already woven class, that has extra mixin information available at runtime

Modified: branches/Branch_AOP_1_5/aop/build.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/build.xml	2007-02-22 22:02:33 UTC (rev 60809)
+++ branches/Branch_AOP_1_5/aop/build.xml	2007-02-23 00:28:19 UTC (rev 60810)
@@ -944,6 +944,9 @@
       </annotationc>
 
       <antcall target="_run-precompiled-test" inheritRefs="true">
+         <param name="test" value="postweavingmixins"/>
+      </antcall>
+      <antcall target="_run-precompiled-test" inheritRefs="true">
          <param name="test" value="field"/>
       </antcall>
       <antcall target="_run-precompiled-test" inheritRefs="true">

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassAdvisor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassAdvisor.java	2007-02-22 22:02:33 UTC (rev 60809)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/ClassAdvisor.java	2007-02-23 00:28:19 UTC (rev 60810)
@@ -385,15 +385,18 @@
             for (int j = 0; j < interfaces.length; j++)
             {
                Class intf = Thread.currentThread().getContextClassLoader().loadClass(interfaces[j]);
-               Method[] methods = intf.getMethods();
-               for (int k = 0; k < methods.length; k++)
+               if (intf.isAssignableFrom(clazz))//This is a fix for JBAOP-365. Class may have been woven, with the extra mixin information only available at init time 
                {
-                  //Put wrapped method in the class itself into the unadvisedMethods map
-                  //   String wrappedName = ClassAdvisor.notAdvisedMethodName(clazz.getName(), methods[k].getName());
-                  //   Method method = clazz.getMethod(wrappedName, methods[k].getParameterTypes());
-                  Method method = getMethod(clazz, methods[k]);
-                  long hash = MethodHashing.methodHash(method);
-                  unadvisedMethods.put(hash, method);
+                  Method[] methods = intf.getMethods();
+                  for (int k = 0; k < methods.length; k++)
+                  {
+                     //Put wrapped method in the class itself into the unadvisedMethods map
+                     //   String wrappedName = ClassAdvisor.notAdvisedMethodName(clazz.getName(), methods[k].getName());
+                     //   Method method = clazz.getMethod(wrappedName, methods[k].getParameterTypes());
+                     Method method = getMethod(clazz, methods[k]);
+                     long hash = MethodHashing.methodHash(method);
+                     unadvisedMethods.put(hash, method);
+                  }
                }
             }
          }

Added: branches/Branch_AOP_1_5/aop/src/resources/test/postweavingmixins/jboss-aop.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/src/resources/test/postweavingmixins/jboss-aop.xml	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/resources/test/postweavingmixins/jboss-aop.xml	2007-02-23 00:28:19 UTC (rev 60810)
@@ -0,0 +1,5 @@
+<aop>
+   <bind pointcut="execution(* org.jboss.test.aop.postweavingmixins.WovenPOJO->method())">
+      <interceptor class="org.jboss.test.aop.postweavingmixins.SanityInterceptor"/>
+   </bind>
+</aop>
\ No newline at end of file

Added: branches/Branch_AOP_1_5/aop/src/resources/test/postweavingmixins/mixins-aop.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/src/resources/test/postweavingmixins/mixins-aop.xml	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/resources/test/postweavingmixins/mixins-aop.xml	2007-02-23 00:28:19 UTC (rev 60810)
@@ -0,0 +1,16 @@
+<aop>
+   <introduction class="org.jboss.test.aop.postweavingmixins.WovenPOJO">
+      <mixin>
+         <interfaces>
+            org.jboss.test.aop.postweavingmixins.MixinInterface
+         </interfaces>
+         <class>org.jboss.test.aop.postweavingmixins.Mixin</class>
+      </mixin>
+   </introduction>
+   
+   <introduction class="org.jboss.test.aop.postweavingmixins.WovenPOJO">
+      <interfaces>
+         org.jboss.test.aop.postweavingmixins.MarkerInterface
+      </interfaces>
+   </introduction>
+</aop>
\ No newline at end of file

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/MarkerInterface.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/MarkerInterface.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/MarkerInterface.java	2007-02-23 00:28:19 UTC (rev 60810)
@@ -0,0 +1,32 @@
+/*
+* 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.postweavingmixins;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MarkerInterface
+{
+
+}

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/Mixin.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/Mixin.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/Mixin.java	2007-02-23 00:28:19 UTC (rev 60810)
@@ -0,0 +1,40 @@
+/*
+* 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.postweavingmixins;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class Mixin implements MixinInterface
+{
+   public Mixin(WovenPOJO pojo)
+   {
+      
+   }
+   
+   public void mixinMethod()
+   {
+   }
+
+}

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/MixinInterface.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/MixinInterface.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/MixinInterface.java	2007-02-23 00:28:19 UTC (rev 60810)
@@ -0,0 +1,32 @@
+/*
+* 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.postweavingmixins;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface MixinInterface
+{
+   void mixinMethod();
+}

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/PostWeavingMixinsTestCase.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/PostWeavingMixinsTestCase.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/PostWeavingMixinsTestCase.java	2007-02-23 00:28:19 UTC (rev 60810)
@@ -0,0 +1,108 @@
+/*
+* 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.postweavingmixins;
+
+import java.net.URL;
+
+import org.jboss.aop.AspectXmlLoader;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Test for JBAOP-365. Only for use with compile-time weaving, and then checking that when making 
+ * mixins/introductions available at runtime we do not fail
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class PostWeavingMixinsTestCase extends TestCase
+{
+   public static void main(String[] args)
+   {
+      junit.textui.TestRunner.run(PostWeavingMixinsTestCase.class);
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("PostWeavingMixinsTestCase");
+      suite.addTestSuite(PostWeavingMixinsTestCase.class);
+      return suite;
+   }
+   // Constants ----------------------------------------------------
+   // Attributes ---------------------------------------------------
+
+   // Static -------------------------------------------------------
+
+   // Constructors -------------------------------------------------
+   public PostWeavingMixinsTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testMixinsInRuntimeConfig() throws Exception
+   {
+      //Deploy the mixins-aop.xml file before loading our woven pojo classs
+      //we deploy it programatically simply to keep the build.xml tidy
+      URL url = getUrl();
+      AspectXmlLoader.deployXML(url);
+      
+      WovenPOJO pojo;
+      try
+      {
+         pojo = new WovenPOJO();
+      }
+      catch (Throwable e)
+      {
+         throw new RuntimeException("CLass could not be loaded", e);
+      }
+      
+      SanityInterceptor.invoked = false;
+      pojo.method();
+      assertTrue(SanityInterceptor.invoked);
+      
+      if (pojo instanceof MarkerInterface)
+      {
+         fail("WovenPOJO should not implement MarkerInterface. This test should ONLY be run with compile time weaving");
+      }
+      
+      if (pojo instanceof MixinInterface)
+      {
+         fail("WovenPOJO should not implement MarkerInterface. This test should ONLY be run with compile time weaving");
+      }
+   }
+   
+   private URL getUrl() throws Exception
+   {
+      URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
+      System.out.println("class url: " + url);
+      String location = url.toString();
+      int index = location.indexOf("/output/tests.classes");
+      location = location.substring(0, index);
+      
+      location = location + "/src/resources/test/postweavingmixins/mixins-aop.xml";
+      url = new URL(location);
+      System.out.println("xml url:   " + url);
+      return url;
+   }
+
+}
\ No newline at end of file

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/SanityInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/SanityInterceptor.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/SanityInterceptor.java	2007-02-23 00:28:19 UTC (rev 60810)
@@ -0,0 +1,46 @@
+/*
+* 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.postweavingmixins;
+
+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 SanityInterceptor implements Interceptor
+{
+   public static boolean invoked;
+   public String getName()
+   {
+      return null;
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      invoked = true;
+      return invocation.invokeNext();
+   }
+
+}

Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/WovenPOJO.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/WovenPOJO.java	                        (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/postweavingmixins/WovenPOJO.java	2007-02-23 00:28:19 UTC (rev 60810)
@@ -0,0 +1,33 @@
+/*
+* 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.postweavingmixins;
+
+/**
+ * This is a POJO that has been woven, but with no introductions/mixins
+ * We will make the mixins/introductions available at runtime to test JBAOP-365
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class WovenPOJO
+{
+   public void method() {}
+}




More information about the jboss-cvs-commits mailing list