[jboss-cvs] JBossAS SVN: r60735 - in projects/aop/trunk/aop/src: resources/test/introduction and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 20 16:32:05 EST 2007


Author: flavia.rainone at jboss.com
Date: 2007-02-20 16:32:05 -0500 (Tue, 20 Feb 2007)
New Revision: 60735

Added:
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJOSubClass.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJOSuperClass.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/SubClassHandlerInterceptor.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/SuperClassHandlerInterceptor.java
Modified:
   projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
   projects/aop/trunk/aop/src/resources/test/introduction/introduction-aop.xml
   projects/aop/trunk/aop/src/resources/test/introduction/jboss-aop.xml
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/HandlerInterceptor.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/IntroductionTester.java
   projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJO.java
Log:
[JBAOP-362] Bug fixed and tested on trunk.

Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java	2007-02-20 21:15:38 UTC (rev 60734)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/instrument/Instrumentor.java	2007-02-20 21:32:05 UTC (rev 60735)
@@ -114,7 +114,7 @@
    
    /**
     * Constructs new instrumentor.
-    * @joinpointClassifier algorithm of joinpoint classification to be used.
+    * @param joinpointClassifier algorithm of joinpoint classification to be used.
     * @param observer need be notified of every joinpoint wrapping caused only
     * by pointcuts dynamicaly added.
     */
@@ -333,11 +333,11 @@
    private void addIntroductionPointcutInterface(CtClass clazz, Advisor advisor, String intf, HashMap baseMethods) throws Exception
    {
       CtClass iface = classPool.get(intf);
-      if (clazz.subtypeOf(iface)) return;
-      if (clazz.subclassOf(iface)) return;
+      if (!clazz.subtypeOf(iface) && !clazz.subclassOf(iface))
+      {
+         clazz.addInterface(iface);
+      }
 
-      clazz.addInterface(iface);
-
       CtMethod mixinInvokeMethod = createInvokeMethod(clazz);
       HashMap intfMap = JavassistMethodHashing.getMethodMap(iface);
       Iterator entries = intfMap.entrySet().iterator();
@@ -358,7 +358,7 @@
       ArrayList pointcuts = advisor.getInterfaceIntroductions();
       
       if (pointcuts.size() == 0) return;
-      HashMap baseMethods = JavassistMethodHashing.getMethodMap(clazz);
+      HashMap baseMethods = JavassistMethodHashing.getDeclaredMethodMap(clazz);
       Iterator it = pointcuts.iterator();
       if (it.hasNext()) setupBasics(clazz);
       while (it.hasNext())
@@ -1001,7 +1001,9 @@
     * class has just been loaded and one or more of its joinpoints were wrapped due
     * only to bindings added dynamicaly; in this case, the previously loaded classes
     * may not call the wrappers of this joinpoints, and need to be instrumented).
-    * @param hostSwapper
+    * 
+    * @param hotSwapper responsible for performing any hot swapping operations when
+    *                   needed.
     * @param clazz the clazz whose transformation involved dynamic wrapping.
     * @param fieldReads collection of fields whose read joinpoit was dynamicaly wrapped.
     * @param fieldWrites collection of fields whose read joinpoit was dynamicaly wrapped.

Modified: projects/aop/trunk/aop/src/resources/test/introduction/introduction-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/introduction/introduction-aop.xml	2007-02-20 21:15:38 UTC (rev 60734)
+++ projects/aop/trunk/aop/src/resources/test/introduction/introduction-aop.xml	2007-02-20 21:32:05 UTC (rev 60735)
@@ -15,15 +15,35 @@
          <class>org.jboss.test.aop.introduction.NonSerializableMixin</class>
       </mixin>
    </introduction>
+   
+   <introduction class="org.jboss.test.aop.introduction.POJOSuperClass">
+      <interfaces>
+         org.jboss.test.aop.introduction.InterceptorHandledIntroduction
+      </interfaces>
+   </introduction>
    <introduction class="org.jboss.test.aop.introduction.POJO">
-         <interfaces>
-            org.jboss.test.aop.introduction.InterceptorHandledIntroduction
-         </interfaces>
+      <interfaces>
+         org.jboss.test.aop.introduction.InterceptorHandledIntroduction
+      </interfaces>
    </introduction>
+   <introduction class="org.jboss.test.aop.introduction.POJOSubClass">
+      <interfaces>
+         org.jboss.test.aop.introduction.InterceptorHandledIntroduction
+      </interfaces>
+   </introduction>
+   <interceptor class="org.jboss.test.aop.introduction.SuperClassHandlerInterceptor"/>
+   <bind pointcut="execution(* org.jboss.test.aop.introduction.POJOSuperClass->handledByIntroduction())">
+      <interceptor-ref name="org.jboss.test.aop.introduction.SuperClassHandlerInterceptor"/>
+   </bind>
    <interceptor class="org.jboss.test.aop.introduction.HandlerInterceptor"/>
-   <bind pointcut="execution(* $instanceof{org.jboss.test.aop.introduction.InterceptorHandledIntroduction}->handledByIntroduction())">
+   <bind pointcut="execution(* org.jboss.test.aop.introduction.POJO->handledByIntroduction())">
       <interceptor-ref name="org.jboss.test.aop.introduction.HandlerInterceptor"/>
    </bind>
+   <interceptor class="org.jboss.test.aop.introduction.SubClassHandlerInterceptor"/>
+   <bind pointcut="execution(* org.jboss.test.aop.introduction.POJOSubClass->handledByIntroduction())">
+      <interceptor-ref name="org.jboss.test.aop.introduction.SubClassHandlerInterceptor"/>
+   </bind>
+   
    <introduction class="org.jboss.test.aop.introduction.SubClass">
       <mixin>
          <interfaces>

Modified: projects/aop/trunk/aop/src/resources/test/introduction/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/introduction/jboss-aop.xml	2007-02-20 21:15:38 UTC (rev 60734)
+++ projects/aop/trunk/aop/src/resources/test/introduction/jboss-aop.xml	2007-02-20 21:32:05 UTC (rev 60735)
@@ -15,15 +15,35 @@
          <class>org.jboss.test.aop.introduction.NonSerializableMixin</class>
       </mixin>
    </introduction>
+   
+   <introduction class="org.jboss.test.aop.introduction.POJOSuperClass">
+      <interfaces>
+         org.jboss.test.aop.introduction.InterceptorHandledIntroduction
+      </interfaces>
+   </introduction>
    <introduction class="org.jboss.test.aop.introduction.POJO">
-         <interfaces>
-            org.jboss.test.aop.introduction.InterceptorHandledIntroduction
-         </interfaces>
+      <interfaces>
+         org.jboss.test.aop.introduction.InterceptorHandledIntroduction
+      </interfaces>
    </introduction>
+   <introduction class="org.jboss.test.aop.introduction.POJOSubClass">
+      <interfaces>
+         org.jboss.test.aop.introduction.InterceptorHandledIntroduction
+      </interfaces>
+   </introduction>
+   <interceptor class="org.jboss.test.aop.introduction.SuperClassHandlerInterceptor"/>
+   <bind pointcut="execution(* org.jboss.test.aop.introduction.POJOSuperClass->handledByIntroduction())">
+      <interceptor-ref name="org.jboss.test.aop.introduction.SuperClassHandlerInterceptor"/>
+   </bind>
    <interceptor class="org.jboss.test.aop.introduction.HandlerInterceptor"/>
-   <bind pointcut="execution(* $instanceof{org.jboss.test.aop.introduction.InterceptorHandledIntroduction}->handledByIntroduction())">
+   <bind pointcut="execution(* org.jboss.test.aop.introduction.POJO->handledByIntroduction())">
       <interceptor-ref name="org.jboss.test.aop.introduction.HandlerInterceptor"/>
    </bind>
+   <interceptor class="org.jboss.test.aop.introduction.SubClassHandlerInterceptor"/>
+   <bind pointcut="execution(* org.jboss.test.aop.introduction.POJOSubClass->handledByIntroduction())">
+      <interceptor-ref name="org.jboss.test.aop.introduction.SubClassHandlerInterceptor"/>
+   </bind>
+   
    <introduction class="org.jboss.test.aop.introduction.SubClass">
       <mixin>
          <interfaces>

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/HandlerInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/HandlerInterceptor.java	2007-02-20 21:15:38 UTC (rev 60734)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/HandlerInterceptor.java	2007-02-20 21:32:05 UTC (rev 60735)
@@ -25,6 +25,12 @@
 import org.jboss.aop.joinpoint.Invocation;
 
 /**
+ * Handles calls to <code>InterceptorHandledIntroduction.handledByIntroduction()
+ * </code> method on <code>POJO</code>.
+ * <br>
+ * This class is used on introduction handler tests.
+ * 
+ * 
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
  * @version $Revision$
  */

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/IntroductionTester.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/IntroductionTester.java	2007-02-20 21:15:38 UTC (rev 60734)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/IntroductionTester.java	2007-02-20 21:32:05 UTC (rev 60735)
@@ -78,9 +78,23 @@
 
    public void testHandledByInterceptor() throws Exception
    {
+      // load first POJO
       POJO pojo = new POJO();
       int ret = ((InterceptorHandledIntroduction) pojo).handledByIntroduction();
+      // is it being intercepted by HandlerInterceptor?
       assertEquals(5, ret);
+      
+      // then, test on its subclass...
+      POJOSubClass pojoSubClass = new POJOSubClass();
+      ret = ((InterceptorHandledIntroduction) pojoSubClass).handledByIntroduction();
+      // is it being intercepted by SubClassHandlerInterceptor?
+      assertEquals(25, ret);
+   
+      // finally, test on its superclass...
+      POJOSuperClass pojoSuperClass = new POJOSuperClass();
+      // is it being intercepted by SuperClassHandlerInterceptor?
+      ret = ((InterceptorHandledIntroduction) pojoSuperClass).handledByIntroduction();
+      assertEquals(1, ret);
    }   
    
    public void testOverrideBaseclassMethodsWithMixin() throws Exception

Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJO.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJO.java	2007-02-20 21:15:38 UTC (rev 60734)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJO.java	2007-02-20 21:32:05 UTC (rev 60735)
@@ -25,7 +25,7 @@
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
  * @version $Revision$
  */
-public class POJO
+public class POJO extends POJOSuperClass
 {
 
 }

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJOSubClass.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJOSubClass.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJOSubClass.java	2007-02-20 21:32:05 UTC (rev 60735)
@@ -0,0 +1,32 @@
+/*
+ * 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.introduction;
+
+/**
+ * This class is used on introduction handler tests.
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class POJOSubClass extends POJO
+{
+
+}
\ No newline at end of file

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJOSuperClass.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJOSuperClass.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/POJOSuperClass.java	2007-02-20 21:32:05 UTC (rev 60735)
@@ -0,0 +1,32 @@
+/*
+ * 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.introduction;
+
+/**
+ * This class is used on introduction handler tests.
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class POJOSuperClass
+{
+
+}
\ No newline at end of file

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/SubClassHandlerInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/SubClassHandlerInterceptor.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/SubClassHandlerInterceptor.java	2007-02-20 21:32:05 UTC (rev 60735)
@@ -0,0 +1,46 @@
+/*
+ * 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.introduction;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * Handles calls to <code>InterceptorHandledIntroduction.handledByIntroduction()
+ * </code> method on <code>POJOSubClass</code>.
+ * <br>
+ * This class is used on introduction handler tests.
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class SubClassHandlerInterceptor implements Interceptor
+{
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      return Integer.valueOf(25);
+   }
+
+   public String getName()
+   {
+      return "SubClassHandlerInterceptor";
+   }
+}
\ No newline at end of file

Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/SuperClassHandlerInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/SuperClassHandlerInterceptor.java	                        (rev 0)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/introduction/SuperClassHandlerInterceptor.java	2007-02-20 21:32:05 UTC (rev 60735)
@@ -0,0 +1,46 @@
+/*
+ * 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.introduction;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ * Handles calls to <code>InterceptorHandledIntroduction.handledByIntroduction()
+ * </code> method on <code>POJOSuperClass</code>.
+ * <br>
+ * This class is used on introduction handler tests.
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ */
+public class SuperClassHandlerInterceptor implements Interceptor
+{
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      return Integer.valueOf(1);
+   }
+
+   public String getName()
+   {
+      return "SuperClassHandlerInterceptor";
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list