[jboss-cvs] JBossAS SVN: r57821 - in projects/aop/trunk/aop/src: main/org/jboss/aop resources/test/extender test/org/jboss/test/aop/extender
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 25 08:51:42 EDT 2006
Author: kabir.khan at jboss.com
Date: 2006-10-25 08:51:31 -0400 (Wed, 25 Oct 2006)
New Revision: 57821
Added:
projects/aop/trunk/aop/src/test/org/jboss/test/aop/extender/ConstructionInterceptor.java
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
projects/aop/trunk/aop/src/resources/test/extender/jboss-aop.xml
projects/aop/trunk/aop/src/test/org/jboss/test/aop/extender/ExtenderTestCase.java
Log:
[JBAOP-298] Fix and test for all construction bindings not being applied when using generated advisors
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java 2006-10-25 12:50:58 UTC (rev 57820)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/Advisor.java 2006-10-25 12:51:31 UTC (rev 57821)
@@ -33,6 +33,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -914,16 +915,19 @@
protected void resolveConstructionPointcut(ArrayList newConstructionInfos, AdviceBinding binding)
{
- for (int i = 0; i < constructors.length; i++)
+ if (newConstructionInfos.size() > 0)
{
- Constructor constructor = constructors[i];
- if (binding.getPointcut().matchesConstruction(this, constructor))
+ for (Iterator it = newConstructionInfos.iterator() ; it.hasNext() ; )
{
- if (AspectManager.verbose) System.err.println(constructor + " matched binding " + binding.getName() + " " + binding.getPointcut().getExpr());
- adviceBindings.add(binding);
- binding.addAdvisor(this);
- ConstructionInfo info = (ConstructionInfo) newConstructionInfos.get(i);
- pointcutResolved(info, binding, new ConstructorJoinpoint(constructor));
+ ConstructionInfo info = (ConstructionInfo)it.next();
+ Constructor constructor = info.getConstructor();
+ if (binding.getPointcut().matchesConstruction(this, constructor))
+ {
+ if (AspectManager.verbose) System.err.println(constructor + " matched binding " + binding.getName() + " " + binding.getPointcut().getExpr());
+ adviceBindings.add(binding);
+ binding.addAdvisor(this);
+ pointcutResolved(info, binding, new ConstructorJoinpoint(constructor));
+ }
}
}
}
Modified: projects/aop/trunk/aop/src/resources/test/extender/jboss-aop.xml
===================================================================
--- projects/aop/trunk/aop/src/resources/test/extender/jboss-aop.xml 2006-10-25 12:50:58 UTC (rev 57820)
+++ projects/aop/trunk/aop/src/resources/test/extender/jboss-aop.xml 2006-10-25 12:51:31 UTC (rev 57821)
@@ -7,6 +7,7 @@
<aop>
<aspect class="org.jboss.test.aop.extender.SuperCallAspect"/>
+ <interceptor class="org.jboss.test.aop.extender.ConstructionInterceptor"/>
<prepare expr="all(org.jboss.test.aop.extender.Base)"/>
<prepare expr="all(org.jboss.test.aop.extender.Extender)"/>
<bind pointcut="execution(* org.jboss.test.aop.extender.ChildBase->updateBase())">
@@ -31,4 +32,10 @@
<bind pointcut="execution(* org.jboss.test.aop.extender.Base->superCall())">
<advice aspect="org.jboss.test.aop.extender.SuperCallAspect" name="invoke"/>
</bind>
+ <bind pointcut="construction(org.jboss.test.aop.extender.Base->new())">
+ <interceptor-ref name="org.jboss.test.aop.extender.ConstructionInterceptor"/>
+ </bind>
+ <bind pointcut="construction(org.jboss.test.aop.extender.SubBase->new())">
+ <interceptor-ref name="org.jboss.test.aop.extender.ConstructionInterceptor"/>
+ </bind>
</aop>
Added: projects/aop/trunk/aop/src/test/org/jboss/test/aop/extender/ConstructionInterceptor.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/extender/ConstructionInterceptor.java 2006-10-25 12:50:58 UTC (rev 57820)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/extender/ConstructionInterceptor.java 2006-10-25 12:51:31 UTC (rev 57821)
@@ -0,0 +1,54 @@
+/*
+* 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.extender;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.ConstructionInvocation;
+import org.jboss.aop.joinpoint.Invocation;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class ConstructionInterceptor implements Interceptor
+{
+ public static ArrayList interceptions = new ArrayList();
+ public String getName()
+ {
+ return this.getClass().getName();
+ }
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ ConstructionInvocation ci = (ConstructionInvocation)invocation;
+ Constructor ctor = ci.getConstructor();
+ Class clazz = ctor.getDeclaringClass();
+ interceptions.add(clazz);
+
+ return ci.invokeNext();
+ }
+
+}
Modified: projects/aop/trunk/aop/src/test/org/jboss/test/aop/extender/ExtenderTestCase.java
===================================================================
--- projects/aop/trunk/aop/src/test/org/jboss/test/aop/extender/ExtenderTestCase.java 2006-10-25 12:50:58 UTC (rev 57820)
+++ projects/aop/trunk/aop/src/test/org/jboss/test/aop/extender/ExtenderTestCase.java 2006-10-25 12:51:31 UTC (rev 57821)
@@ -83,4 +83,13 @@
assertEquals(Base.class, SuperCallAspect.methodClasses.get(1));
assertEquals(Base.class, SuperCallAspect.methodClasses.get(2));
}
+
+ public void testConstruction() throws Exception
+ {
+ ConstructionInterceptor.interceptions.clear();
+ SubBase child = new SubBase();
+ assertEquals(2, ConstructionInterceptor.interceptions.size());
+ assertEquals(Base.class, ConstructionInterceptor.interceptions.get(0));
+ assertEquals(SubBase.class, ConstructionInterceptor.interceptions.get(1));
+ }
}
More information about the jboss-cvs-commits
mailing list