[jboss-cvs] JBossAS SVN: r60723 - in branches/Branch_AOP_1_5/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 14:01:59 EST 2007
Author: flavia.rainone at jboss.com
Date: 2007-02-20 14:01:58 -0500 (Tue, 20 Feb 2007)
New Revision: 60723
Added:
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/POJOSubClass.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/POJOSuperClass.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/SubClassHandlerInterceptor.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/SuperClassHandlerInterceptor.java
Modified:
branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
branches/Branch_AOP_1_5/aop/src/resources/test/introduction/introduction-aop.xml
branches/Branch_AOP_1_5/aop/src/resources/test/introduction/jboss-aop.xml
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/HandlerInterceptor.java
branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/IntroductionTester.java
Log:
[JBAOP-362] Bug fixed and tested.
Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/Instrumentor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/Instrumentor.java 2007-02-20 18:47:14 UTC (rev 60722)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/Instrumentor.java 2007-02-20 19:01:58 UTC (rev 60723)
@@ -112,7 +112,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.
*/
@@ -337,11 +337,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();
@@ -361,7 +361,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())
@@ -994,7 +994,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: branches/Branch_AOP_1_5/aop/src/resources/test/introduction/introduction-aop.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/src/resources/test/introduction/introduction-aop.xml 2007-02-20 18:47:14 UTC (rev 60722)
+++ branches/Branch_AOP_1_5/aop/src/resources/test/introduction/introduction-aop.xml 2007-02-20 19:01:58 UTC (rev 60723)
@@ -15,15 +15,36 @@
<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: branches/Branch_AOP_1_5/aop/src/resources/test/introduction/jboss-aop.xml
===================================================================
--- branches/Branch_AOP_1_5/aop/src/resources/test/introduction/jboss-aop.xml 2007-02-20 18:47:14 UTC (rev 60722)
+++ branches/Branch_AOP_1_5/aop/src/resources/test/introduction/jboss-aop.xml 2007-02-20 19:01:58 UTC (rev 60723)
@@ -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: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/HandlerInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/HandlerInterceptor.java 2007-02-20 18:47:14 UTC (rev 60722)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/HandlerInterceptor.java 2007-02-20 19:01:58 UTC (rev 60723)
@@ -25,6 +25,11 @@
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: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/IntroductionTester.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/IntroductionTester.java 2007-02-20 18:47:14 UTC (rev 60722)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/IntroductionTester.java 2007-02-20 19:01:58 UTC (rev 60723)
@@ -77,11 +77,25 @@
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
{
BaseClass base = new BaseClass();
@@ -90,5 +104,5 @@
SubClass sub = new SubClass();
NonSerializedIntroduction intro = (NonSerializedIntroduction)sub;
assertEquals("original", intro.getNonMessage());
- }
-}
+ }
+}
\ No newline at end of file
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/POJOSubClass.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/POJOSubClass.java (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/POJOSubClass.java 2007-02-20 19:01:58 UTC (rev 60723)
@@ -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
+{
+
+}
\ No newline at end of file
Added: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/POJOSuperClass.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/POJOSuperClass.java (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/POJOSuperClass.java 2007-02-20 19:01:58 UTC (rev 60723)
@@ -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: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/SubClassHandlerInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/SubClassHandlerInterceptor.java (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/SubClassHandlerInterceptor.java 2007-02-20 19:01:58 UTC (rev 60723)
@@ -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: branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/SuperClassHandlerInterceptor.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/SuperClassHandlerInterceptor.java (rev 0)
+++ branches/Branch_AOP_1_5/aop/src/test/org/jboss/test/aop/introduction/SuperClassHandlerInterceptor.java 2007-02-20 19:01:58 UTC (rev 60723)
@@ -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