From: Kabir K. <kk...@jb...> - 2006-07-10 15:00:32
|
User: kkhan Date: 06/07/10 11:00:23 Added: src/test/org/jboss/test/aop/jdk15annotated CFlowAspect.java AnotherPOJO.java Interceptions.java PrecedenceAspect1.java CountingInterceptorFactory.java SimpleDynamicCFlow.java PrecedenceInterceptor2.java AnnotatedTestCase.java PreparePOJO.java AspectPerVM.java NoInterfacesPOJO2.java IntroducedAnnotationPOJO.java CountingInterceptor.java EmptyInterface.java AspectPerInstance.java VariaPOJO.java IntroducedAnnotationInterceptor.java PrecedenceInterceptor1.java TypedefAspect.java AspectFromFactory.java Precedence1.java ExternalizableMixin.java Precedence2.java PreparedPOJO.java POJO2.java AspectPerClass.java AnnotatedAspectFactory.java POJO.java MyAnnotation.java NoInterfacesPOJO.java IntroductionAspect.java Log: Make a start migrating to jboss retro Revision Changes Path 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/CFlowAspect.java Index: CFlowAspect.java =================================================================== /* * 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.jdk15annotated; import org.jboss.aop.*; import org.jboss.aop.advice.Scope; import org.jboss.aop.joinpoint.*; import org.jboss.aop.pointcut.CFlowStack; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ * */ @Aspect(scope = Scope.PER_VM) public class CFlowAspect { public static int cflowAccess; @CFlowStackDef (cflows={@CFlowDef(expr = "void org.jboss.test.aop.jdk15annotated.VariaPOJO->cflowMethod1()", called=true), @CFlowDef(expr = "void org.jboss.test.aop.jdk15annotated.VariaPOJO->cflowMethod2()", called=true)}) public static CFlowStack cf1And2Stack; @CFlowStackDef (cflows={@CFlowDef(expr = "void org.jboss.test.aop.jdk15annotated.VariaPOJO->cflowMethod1()", called=false), @CFlowDef(expr = "void org.jboss.test.aop.jdk15annotated.VariaPOJO->cflowMethod2()", called=true)}) public static CFlowStack cfNot1And2Stack; @org.jboss.aop.Bind (pointcut="execution(void org.jboss.test.aop.jdk15annotated.VariaPOJO*->privateMethod())", cflow="(org.jboss.test.aop.jdk15annotated.CFlowAspect.cf1And2Stack OR org.jboss.test.aop.jdk15annotated.CFlowAspect.cfNot1And2Stack)") public Object cflowAdvice(Invocation invocation) throws Throwable { System.out.println("CFlowAspect.cflowAdvice"); cflowAccess++; return invocation.invokeNext(); } @org.jboss.aop.Bind (pointcut="execution(void org.jboss.test.aop.jdk15annotated.VariaPOJO*->dynamicCFlowMethod())", cflow="org.jboss.test.aop.jdk15annotated.SimpleDynamicCFlow") public Object dynamicCFlowAdvice(Invocation invocation) throws Throwable { System.out.println("CFlowAspect.dynamicCFlowAdvice"); cflowAccess++; return invocation.invokeNext(); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/AnotherPOJO.java Index: AnotherPOJO.java =================================================================== /* * 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.jdk15annotated; /** * Created by IntelliJ IDEA. * User: Kab * Date: 15-Sep-2004 * Time: 21:18:26 * To change this template use File | Settings | File Templates. */ public class AnotherPOJO { public AnotherPOJO() { System.out.println("AnotherPOJO someMethod()"); } public int field; public void someMethod() { System.out.println("AnotherPOJO someMethod()"); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/Interceptions.java Index: Interceptions.java =================================================================== /* * 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.jdk15annotated; import java.util.ArrayList; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ public class Interceptions { static ArrayList intercepted = new ArrayList(); public static void add(String name) { System.out.println("Adding (a) " + name); intercepted.add(name); } public static ArrayList getIntercepted() { return intercepted; } public static void reset() { intercepted = new ArrayList(); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/PrecedenceAspect1.java Index: PrecedenceAspect1.java =================================================================== /* * 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.jdk15annotated; import org.jboss.aop.Aspect; import org.jboss.aop.Bind; import org.jboss.aop.joinpoint.Invocation; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ @Aspect (scope=org.jboss.aop.advice.Scope.PER_VM) public class PrecedenceAspect1 { @Bind (pointcut="execution(* org.jboss.test.aop.jdk15annotated.VariaPOJO->precedenceMethod())") public Object advice1(Invocation invocation) throws Throwable { Interceptions.add("PrecedenceAspect1.advice1"); System.out.println("PrecedenceAspect1.advice1"); return invocation.invokeNext(); } @Bind (pointcut="execution(* org.jboss.test.aop.jdk15annotated.VariaPOJO->precedenceMethod())") public Object advice2(Invocation invocation) throws Throwable { Interceptions.add("PrecedenceAspect1.advice2"); System.out.println("PrecedenceAspect1.advice2"); return invocation.invokeNext(); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/CountingInterceptorFactory.java Index: CountingInterceptorFactory.java =================================================================== /* * 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.jdk15annotated; import org.jboss.aop.Advisor; import org.jboss.aop.InstanceAdvisor; import org.jboss.aop.advice.AspectFactory; import org.jboss.aop.joinpoint.Joinpoint; /** * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ @org.jboss.aop.InterceptorDef (scope=org.jboss.aop.advice.Scope.PER_VM) @org.jboss.aop.Bind (pointcut="execution(* org.jboss.test.aop.jdk15annotated.VariaPOJO*->methodWithInterceptorFactory())") public class CountingInterceptorFactory implements AspectFactory { public Object createPerVM() { return new CountingInterceptor(); } public Object createPerClass(Advisor advisor) { return new CountingInterceptor(); } public Object createPerInstance(Advisor advisor, InstanceAdvisor instanceAdvisor) { return new CountingInterceptor(); } public Object createPerJoinpoint(Advisor advisor, Joinpoint jp) { return new CountingInterceptor(); } public Object createPerJoinpoint(Advisor advisor, InstanceAdvisor instanceAdvisor, Joinpoint jp) { return new CountingInterceptor(); } public String getName() { return getClass().getName(); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/SimpleDynamicCFlow.java Index: SimpleDynamicCFlow.java =================================================================== /* * 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.jdk15annotated; import org.jboss.aop.DynamicCFlowDef; import org.jboss.aop.joinpoint.Invocation; import org.jboss.aop.pointcut.DynamicCFlow; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ @DynamicCFlowDef public class SimpleDynamicCFlow implements DynamicCFlow { public static boolean execute = false; public boolean shouldExecute(Invocation invocation) { return execute; } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/PrecedenceInterceptor2.java Index: PrecedenceInterceptor2.java =================================================================== /* * 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.jdk15annotated; import org.jboss.aop.Bind; import org.jboss.aop.InterceptorDef; import org.jboss.aop.advice.Interceptor; import org.jboss.aop.joinpoint.Invocation; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ @InterceptorDef (scope=org.jboss.aop.advice.Scope.PER_VM) @Bind (pointcut="execution(* org.jboss.test.aop.jdk15annotated.VariaPOJO->precedenceMethod())") public class PrecedenceInterceptor2 implements Interceptor { public String getName() { return "PrecedenceInterceptor2"; } public Object invoke(Invocation invocation) throws Throwable { Interceptions.add("PrecedenceInterceptor2"); System.out.println("PrecedenceInterceptor2"); return invocation.invokeNext(); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/AnnotatedTestCase.java Index: AnnotatedTestCase.java =================================================================== /* * 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.jdk15annotated; import junit.framework.Test; import junit.framework.TestSuite; import junit.textui.TestRunner; import org.jboss.aop.Advised; import org.jboss.aop.Advisor; import org.jboss.aop.AspectManager; import org.jboss.aop.InstanceAdvisor; import org.jboss.aop.advice.AdviceBinding; import org.jboss.aop.advice.AdviceFactory; import org.jboss.aop.advice.AspectDefinition; import org.jboss.test.aop.AOPTestWithSetup; /** * @author <a href="mailto:bi...@jb...">Bill Burke</a> * @version $Revision: 1.1 $ */ public class AnnotatedTestCase extends AOPTestWithSetup { public static void main(String[] args) { TestRunner.run(suite()); } public static Test suite() { TestSuite suite = new TestSuite("AnnotatedTester"); suite.addTestSuite(AnnotatedTestCase.class); return suite; } public AnnotatedTestCase(String name) { super(name); } protected void setUp() throws Exception { super.setUp(); //This should go in the startService() method of the injboss testsuite // testBinding(); // testCompostition(); // testMixin(); // testIntroduction(); // testInterceptorDef(); // testTypedef(); // testCFlow(); // testPrepare(); // testPrepareAtClassLevel(); // testDynamicCFlow(); // testAnnotationIntroduction(); // testAspectFactory(); } public void testBinding() throws Exception { System.out.println("***** testBinding() ****"); AspectPerVM vm = null; AspectPerClass perClass = null; AspectPerClass perClass2 = null; try { System.out.println("---- POJO ---"); POJO pojo = new POJO(); pojo.field++; pojo.someMethod(); System.out.println("---- POJO2 ---"); POJO2 pojo2 = new POJO2(); pojo2.field++; pojo2.someMethod(); System.out.println("-- get stats --"); vm = (AspectPerVM) AspectManager.instance().getPerVMAspect("org.jboss.test.aop.jdk15annotated.AspectPerVM"); System.out.println("perVM stats: " + vm.constructorCalled + " " + vm.methodCalled + " " + vm.fieldRead + " " + vm.fieldWrite); assertEquals(2, vm.constructorCalled); assertEquals(2, vm.methodCalled); assertEquals(2, vm.fieldRead); assertEquals(2, vm.fieldWrite); Advisor advisor = ((Advised) pojo)._getAdvisor(); perClass = (AspectPerClass) advisor.getPerClassAspect("org.jboss.test.aop.jdk15annotated.AspectPerClass"); System.out.println("POJO perClass stats: " + perClass.constructorCalled + " " + perClass.methodCalled + " " + perClass.fieldRead + " " + perClass.fieldWrite); assertEquals(1, perClass.constructorCalled); assertEquals(1, perClass.methodCalled); assertEquals(1, perClass.fieldRead); assertEquals(1, perClass.fieldWrite); advisor = ((Advised) pojo2)._getAdvisor(); perClass2 = (AspectPerClass) advisor.getPerClassAspect("org.jboss.test.aop.jdk15annotated.AspectPerClass"); System.out.println("POJO2 perClass stats: " + perClass.constructorCalled + " " + perClass.methodCalled + " " + perClass.fieldRead + " " + perClass.fieldWrite); assertEquals(1, perClass2.constructorCalled); assertEquals(1, perClass2.methodCalled); assertEquals(1, perClass2.fieldRead); assertEquals(1, perClass2.fieldWrite); InstanceAdvisor ia = ((Advised) pojo)._getInstanceAdvisor(); AspectPerInstance perInstance = (AspectPerInstance) ia.getPerInstanceAspect("org.jboss.test.aop.jdk15annotated.AspectPerInstance"); System.out.println("pojo perInstance stats: " + perInstance.methodCalled + " " + perInstance.fieldRead + " " + perInstance.fieldWrite); assertEquals(1, perInstance.methodCalled); assertEquals(1, perInstance.fieldRead); assertEquals(1, perInstance.fieldWrite); ia = ((Advised) pojo2)._getInstanceAdvisor(); perInstance = (AspectPerInstance) ia.getPerInstanceAspect("org.jboss.test.aop.jdk15annotated.AspectPerInstance"); System.out.println("pojo2 perInstance stats: " + perInstance.methodCalled + " " + perInstance.fieldRead + " " + perInstance.fieldWrite); assertEquals(1, perInstance.methodCalled); assertEquals(1, perInstance.fieldRead); assertEquals(1, perInstance.fieldWrite); } finally { if (vm != null) vm.reset(); if (perClass != null) perClass.reset(); if (perClass2 != null) perClass2.reset(); } } public void testCompostition() throws Exception { AspectPerVM vm = null; try { System.out.println("***** testCompostition() ****"); System.out.println("---- AnotherPOJO ---"); AnotherPOJO apojo = new AnotherPOJO(); apojo.field++; apojo.someMethod(); vm = (AspectPerVM) AspectManager.instance().getPerVMAspect("org.jboss.test.aop.jdk15annotated.AspectPerVM"); assertEquals(4, vm.anotherPOJOAccess); } finally { if (vm != null) vm.reset(); } } public void testMixin() throws Exception { System.out.println("***** testMixin() ****"); ExternalizableMixin.write = false; ExternalizableMixin.read = false; NoInterfacesPOJO pojo = new NoInterfacesPOJO(); pojo.stuff = "hello world"; java.rmi.MarshalledObject mo = new java.rmi.MarshalledObject(pojo); pojo = (NoInterfacesPOJO)mo.get(); System.out.println("deserialized pojo2.stuff2: " + pojo.stuff); assertTrue("writeExternal was not called", ExternalizableMixin.write); assertTrue("readExternal was not called", ExternalizableMixin.read); ExternalizableMixin.write = false; ExternalizableMixin.read = false; NoInterfacesPOJO2 pojo2 = new NoInterfacesPOJO2(); pojo2.stuff = "whatever"; java.rmi.MarshalledObject mo2 = new java.rmi.MarshalledObject(pojo2); pojo2 = (NoInterfacesPOJO2)mo2.get(); System.out.println("deserialized pojo2.stuff2: " + pojo2.stuff); assertTrue("writeExternal was not called for pojo2", ExternalizableMixin.write); assertTrue("readExternal was not called for pojo2", ExternalizableMixin.read); } public void testIntroduction() throws Exception { System.out.println("***** testIntroduction() ****"); NoInterfacesPOJO pojo = new NoInterfacesPOJO(); try { EmptyInterface eif = (EmptyInterface)pojo; } catch(Exception e) { throw new RuntimeException("pojo does not implement EmptyInterface"); } NoInterfacesPOJO2 pojo2 = new NoInterfacesPOJO2(); try { EmptyInterface eif = (EmptyInterface)pojo2; } catch(Exception e) { throw new RuntimeException("pojo2 does not implement EmptyInterface"); } } public void testInterceptorDef()throws Exception { System.out.println("***** testInterceptorDef() ****"); CountingInterceptor.count = 0; VariaPOJO pojo = new VariaPOJO(); pojo.methodWithInterceptor(); System.out.println("Count: " + CountingInterceptor.count); assertEquals("execution of POJO.methodWithInterceptor() was not intercepted", 1, CountingInterceptor.count); CountingInterceptor.count = 0; pojo.methodWithInterceptorFactory(); System.out.println("Count: " + CountingInterceptor.count); assertEquals("execution of POJO.methodWithInterceptorFactory() was not intercepted", 1, CountingInterceptor.count); } public void testTypedef()throws Exception { System.out.println("***** testTypedef() ****"); VariaPOJO pojo = new VariaPOJO(); pojo.methodWithTypedef(); System.out.println("Intercepted: " + TypedefAspect.intercepted); assertTrue("execution of POJO.methodWithTypedef() was not intercepted", TypedefAspect.intercepted); } public void testCFlow()throws Exception { System.out.println("***** testCFlow() ****"); CFlowAspect.cflowAccess = 0; VariaPOJO pojo = new VariaPOJO(); pojo.cflowMethod1(); assertEquals("Wrong number of interceptions 1) for cflow Advice", 1, CFlowAspect.cflowAccess); CFlowAspect.cflowAccess = 0; pojo.cflowMethod2(); System.out.println("ints: " + CFlowAspect.cflowAccess); assertEquals("Wrong number of interceptions 2) for cflow Advice", 1, CFlowAspect.cflowAccess ); } public void testPrepare()throws Exception { System.out.println("***** testPrepare() ****"); PreparePOJO pojo = new PreparePOJO(); pojo.someMethod(); Advised advised = (Advised)pojo; Advisor advisor = advised._getAdvisor(); } public void testPrepareAtClassLevel() throws Exception { System.out.println("***** testPrepareAtClassLevel() ****"); PreparedPOJO pojo = new PreparedPOJO(); pojo.someMethod(); Advised advised = (Advised)pojo; Advisor advisor = advised._getAdvisor(); } public void testDynamicCFlow()throws Exception { System.out.println("***** testDynamicCFlow() ****"); CFlowAspect.cflowAccess = 0; VariaPOJO pojo = new VariaPOJO(); pojo.dynamicCFlowMethod(); assertEquals("Wrong number of interceptions for dynamic cflow Advice", 0, CFlowAspect.cflowAccess); SimpleDynamicCFlow.execute = true; pojo.dynamicCFlowMethod(); assertEquals("Wrong number of interceptions for dynamic cflow Advice", 1, CFlowAspect.cflowAccess); SimpleDynamicCFlow.execute = false; pojo.dynamicCFlowMethod(); assertEquals("Wrong number of interceptions for dynamic cflow Advice (2)", 1, CFlowAspect.cflowAccess); } public void testAnnotationIntroduction() throws Exception { System.out.println("***** testAnnotationIntroduction() ****"); IntroducedAnnotationPOJO pojo = new IntroducedAnnotationPOJO(); assertNull("IntroducedAnnotationPOJO should not have had a constructor annotation", IntroducedAnnotationInterceptor.lastMyAnnotation); pojo.annotationIntroductionMethod(); MyAnnotation annotation = IntroducedAnnotationInterceptor.lastMyAnnotation; assertNotNull("IntroducedAnnotationPOJO.annotationIntroductionMethod() should have had a method annotation", annotation); assertEquals("Wrong value for MyAnnotation.string()", "hello", annotation.string()); assertEquals("Wrong value for MyAnnotation.integer()", 5, annotation.integer()); assertEquals("Wrong value for MyAnnotation.bool()", true, annotation.bool()); pojo.noAnnotationIntroductionMethod(); assertNull("IntroducedAnnotationPOJO.noAnnotationIntroductionMethod() should not have had a method annotation", IntroducedAnnotationInterceptor.lastMyAnnotation); } public void testPrecedence() throws Exception { System.out.println("***** testPrecedence() ****"); VariaPOJO pojo = new VariaPOJO(); pojo.precedenceMethod(); String[] expected = {"PrecedenceInterceptor1", "PrecedenceAspect1.advice1", "PrecedenceAspect1.advice2", "PrecedenceInterceptor2"}; java.util.ArrayList intercepted = Interceptions.intercepted; assertEquals("Wrong number of interceptions", expected.length ,intercepted.size()); for (int i = 0 ; i < expected.length ; i++) { assertEquals("Wrong interception at index " + i, expected[i], (String)intercepted.get(i)); } } /** * Tests the annotation of an aspect factory as @Aspect. */ public void testAspectFactory() throws Exception { AdviceBinding binding = new AdviceBinding( "execution(void *PreparedPOJO->someMethod(..))", null); AspectDefinition aspectDefinition = AspectManager.instance() .getAspectDefinition(AnnotatedAspectFactory.class.getName()); assertNotNull(aspectDefinition); binding.addInterceptorFactory(new AdviceFactory(aspectDefinition, "advice")); AspectManager.instance().addBinding(binding); PreparedPOJO pojo = new PreparedPOJO(); pojo.someMethod(); assertTrue(AnnotatedAspectFactory.isAspectCreated()); assertTrue(AnnotatedAspectFactory.getAspectCreated().isAdvised()); AspectManager.instance().removeBinding(binding.getName()); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/PreparePOJO.java Index: PreparePOJO.java =================================================================== /* * 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.jdk15annotated; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ public class PreparePOJO { public void someMethod() { System.out.println("PreparePOJO someMethod()"); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/AspectPerVM.java Index: AspectPerVM.java =================================================================== /* * 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.jdk15annotated; import org.jboss.aop.*; import org.jboss.aop.Prepare; import org.jboss.aop.pointcut.Pointcut; import org.jboss.aop.pointcut.CFlowStack; import org.jboss.aop.advice.Scope; import org.jboss.aop.joinpoint.*; /** * @author <a href="mailto:bi...@jb...">Bill Burke</a> * @version $Revision: 1.1 $ */ @Aspect(scope = Scope.PER_VM) public class AspectPerVM { public int constructorCalled; public int methodCalled; public int fieldRead; public int fieldWrite; public int anotherPOJOAccess; @PointcutDef("execution(org.jboss.test.aop.jdk15annotated.AnotherPOJO->new(..))") public static Pointcut anotherPOJOConstructors; @PointcutDef("get(* org.jboss.test.aop.jdk15annotated.AnotherPOJO->field)") public static Pointcut anotherPOJOFieldReads; @PointcutDef("set(* org.jboss.test.aop.jdk15annotated.AnotherPOJO->field)") public static Pointcut anotherPOJOFieldWrites; @PointcutDef("execution(* org.jboss.test.aop.jdk15annotated.AnotherPOJO->*(..))") public static Pointcut anotherPOJOPublicMethods; @PointcutDef("org.jboss.test.aop.jdk15annotated.AspectPerVM.anotherPOJOFieldWrites OR org.jboss.test.aop.jdk15annotated.AspectPerVM.anotherPOJOFieldReads") public static Pointcut anotherPOJOFields; @Prepare ("all(org.jboss.test.aop.jdk15annotated.PreparePOJO)") public static Pointcut preparePOJO; @Bind(pointcut = "execution(org.jboss.test.aop.jdk15annotated.POJO*->new())") public Object constructorAdvice(ConstructorInvocation invocation) throws Throwable { System.out.println("AspectPerVM.constructorAdvice accessing: " + invocation.getConstructor().toString()); constructorCalled++; return invocation.invokeNext(); } @Bind(pointcut = "execution(void org.jboss.test.aop.jdk15annotated.POJO*->someMethod())") public Object methodAdvice(MethodInvocation invocation) throws Throwable { System.out.println("AspectPerVM.methodAdvice accessing: " + invocation.getMethod().toString()); methodCalled++; return invocation.invokeNext(); } @Bind(pointcut = "set(* org.jboss.test.aop.jdk15annotated.POJO*->field)") public Object fieldAdvice(FieldWriteInvocation invocation) throws Throwable { System.out.println("AspectPerVM.fieldAdvice writing to field: " + invocation.getField().getName()); fieldWrite++; return invocation.invokeNext(); } @Bind(pointcut = "get(* org.jboss.test.aop.jdk15annotated.POJO*->field)") public Object fieldAdvice(FieldReadInvocation invocation) throws Throwable { System.out.println("AspectPerVM.fieldAdvice reading field: " + invocation.getField().getName()); fieldRead++; return invocation.invokeNext(); } @Bind(pointcut = "org.jboss.test.aop.jdk15annotated.AspectPerVM.anotherPOJOFields OR org.jboss.test.aop.jdk15annotated.AspectPerVM.anotherPOJOConstructors OR org.jboss.test.aop.jdk15annotated.AspectPerVM.anotherPOJOPublicMethods") public Object anotherPOJOAdvice(Invocation invocation) throws Throwable { System.out.println("AspectPerVM.anotherPOJOAdvice"); anotherPOJOAccess++; return invocation.invokeNext(); } public void reset() { constructorCalled = 0; methodCalled = 0; fieldRead = 0; fieldWrite = 0; anotherPOJOAccess = 0; } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/NoInterfacesPOJO2.java Index: NoInterfacesPOJO2.java =================================================================== /* * 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.jdk15annotated; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ public class NoInterfacesPOJO2 extends NoInterfacesPOJO { public void pojoInterfaces2Method() { } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/IntroducedAnnotationPOJO.java Index: IntroducedAnnotationPOJO.java =================================================================== /* * 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.jdk15annotated; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ public class IntroducedAnnotationPOJO { public IntroducedAnnotationPOJO() { System.out.println("IntroducedAnnotationPOJO constructor"); } public void annotationIntroductionMethod() { System.out.println("IntroducedAnnotationPOJO annotationIntroductionMethod"); } public void noAnnotationIntroductionMethod() { System.out.println("IntroducedAnnotationPOJO noAnnotationIntroductionMethod"); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/CountingInterceptor.java Index: CountingInterceptor.java =================================================================== /* * 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.jdk15annotated; import java.lang.reflect.Field; import java.lang.reflect.Method; import org.jboss.aop.joinpoint.FieldReadInvocation; import org.jboss.aop.joinpoint.FieldWriteInvocation; import org.jboss.aop.joinpoint.MethodInvocation; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ @org.jboss.aop.InterceptorDef (scope=org.jboss.aop.advice.Scope.PER_VM) @org.jboss.aop.Bind (pointcut="execution(* org.jboss.test.aop.jdk15annotated.VariaPOJO*->methodWithInterceptor())") public class CountingInterceptor implements org.jboss.aop.advice.Interceptor { public String getName() { return "CountingInterceptor"; } public Object invoke(org.jboss.aop.joinpoint.Invocation invocation) throws Throwable { System.out.println("CountingInterceptor interception: " + invocation.getClass().getName()); count++; System.out.println("CountingInterceptor.count:" + count); return invocation.invokeNext(); } public static int count; } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/EmptyInterface.java Index: EmptyInterface.java =================================================================== /* * 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.jdk15annotated; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ public interface EmptyInterface { } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/AspectPerInstance.java Index: AspectPerInstance.java =================================================================== /* * 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.jdk15annotated; import org.jboss.aop.Aspect; import org.jboss.aop.Bind; import org.jboss.aop.advice.Scope; import org.jboss.aop.joinpoint.FieldReadInvocation; import org.jboss.aop.joinpoint.FieldWriteInvocation; import org.jboss.aop.joinpoint.MethodInvocation; /** * @author <a href="mailto:bi...@jb...">Bill Burke</a> * @version $Revision: 1.1 $ */ @Aspect(scope = Scope.PER_INSTANCE) public class AspectPerInstance { public int methodCalled; public int fieldRead; public int fieldWrite; @Bind(pointcut = "execution(void org.jboss.test.aop.jdk15annotated.POJO*->someMethod())") public Object methodAdvice(MethodInvocation invocation) throws Throwable { System.out.println("AspectPerInstance.methodAdvice accessing: " + invocation.getMethod().toString()); methodCalled++; return invocation.invokeNext(); } @Bind(pointcut = "set(* org.jboss.test.aop.jdk15annotated.POJO*->field)") public Object fieldAdvice(FieldWriteInvocation invocation) throws Throwable { System.out.println("AspectPerInstance.fieldAdvice writing to field: " + invocation.getField().getName()); fieldWrite++; return invocation.invokeNext(); } @Bind(pointcut = "get(* org.jboss.test.aop.jdk15annotated.POJO*->field)") public Object fieldAdvice(FieldReadInvocation invocation) throws Throwable { System.out.println("AspectPerInstance.fieldAdvice reading field: " + invocation.getField().getName()); fieldRead++; return invocation.invokeNext(); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/VariaPOJO.java Index: VariaPOJO.java =================================================================== /* * 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.jdk15annotated; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ public class VariaPOJO { public void methodWithInterceptor() { System.out.println("POJO methodWithInterceptor"); } public void methodWithInterceptorFactory() { System.out.println("POJO methodWithInterceptorFactory"); } public void methodWithTypedef() { System.out.println("POJO methodWithTypedef"); } public void cflowMethod1() { System.out.println("POJO cflowMethod1"); cflowMethod2(); } public void cflowMethod2() { System.out.println("POJO cflowMethod2"); privateMethod(); } public void dynamicCFlowMethod() { System.out.println("POJO dynamicCFlowMethod"); } private void privateMethod() { System.out.println("POJO privateMethod"); } public void precedenceMethod() { System.out.println("POJO precedenceMethod"); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/IntroducedAnnotationInterceptor.java Index: IntroducedAnnotationInterceptor.java =================================================================== /* * 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.jdk15annotated; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import org.jboss.aop.AnnotationIntroductionDef; import org.jboss.aop.Bind; import org.jboss.aop.InterceptorDef; import org.jboss.aop.advice.Interceptor; import org.jboss.aop.annotation.AnnotationElement; import org.jboss.aop.introduction.AnnotationIntroduction; import org.jboss.aop.joinpoint.ConstructorInvocation; import org.jboss.aop.joinpoint.Invocation; import org.jboss.aop.joinpoint.MethodInvocation; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ @InterceptorDef (scope=org.jboss.aop.advice.Scope.PER_VM) @Bind (pointcut="all(org.jboss.test.aop.jdk15annotated.IntroducedAnnotationPOJO)") public class IntroducedAnnotationInterceptor implements Interceptor { @AnnotationIntroductionDef (expr="method(* org.jboss.test.aop.jdk15annotated.IntroducedAnnotationPOJO->annotationIntroductionMethod())", invisible=false, annotation="@org.jboss.test.aop.jdk15annotated.MyAnnotation (string='hello', integer=5, bool=true)") public static AnnotationIntroduction annotationIntroduction; public static MyAnnotation lastMyAnnotation; public String getName() { return "TestAnnotationInterceptor"; } public Object invoke(Invocation invocation) throws Throwable { System.out.println("IntroducedInterceptor"); if (invocation instanceof MethodInvocation) { Method method = ((MethodInvocation)invocation).getMethod(); System.out.println("executing method " + method.toString()); MyAnnotation myAnn = (MyAnnotation)AnnotationElement.getAnyAnnotation(method, MyAnnotation.class); lastMyAnnotation = myAnn; } else if (invocation instanceof ConstructorInvocation) { Constructor constructor = ((ConstructorInvocation)invocation).getConstructor(); System.out.println("executing constructor " + constructor); MyAnnotation myAnn = (MyAnnotation)AnnotationElement.getAnyAnnotation(constructor, MyAnnotation.class); lastMyAnnotation = myAnn; } return invocation.invokeNext(); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/PrecedenceInterceptor1.java Index: PrecedenceInterceptor1.java =================================================================== /* * 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.jdk15annotated; import org.jboss.aop.Bind; import org.jboss.aop.InterceptorDef; import org.jboss.aop.advice.Interceptor; import org.jboss.aop.joinpoint.Invocation; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ @InterceptorDef (scope=org.jboss.aop.advice.Scope.PER_VM) @Bind (pointcut="execution(* org.jboss.test.aop.jdk15annotated.VariaPOJO->precedenceMethod())") public class PrecedenceInterceptor1 implements Interceptor { public String getName() { return "PrecedenceInterceptor1"; } public Object invoke(Invocation invocation) throws Throwable { Interceptions.add("PrecedenceInterceptor1"); System.out.println("PrecedenceInterceptor1"); return invocation.invokeNext(); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/TypedefAspect.java Index: TypedefAspect.java =================================================================== /* * 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.jdk15annotated; import org.jboss.aop.Aspect; import org.jboss.aop.Bind; import org.jboss.aop.TypeDef; import org.jboss.aop.pointcut.Typedef; import org.jboss.aop.joinpoint.Invocation; /** * * @author <a href="mailto:kab...@jb...">Kabir Khan</a> * @version $Revision: 1.1 $ */ @Aspect (scope=org.jboss.aop.advice.Scope.PER_VM) public class TypedefAspect { public static boolean intercepted; @TypeDef ("class(org.jboss.test.aop.jdk15annotated.VariaPOJO)") public static Typedef myTypedef; @Bind (pointcut="execution(* $typedef{org.jboss.test.aop.jdk15annotated.TypedefAspect.myTypedef}->methodWithTypedef())") public Object typedefAdvice(Invocation invocation) throws Throwable { intercepted = true; return invocation.invokeNext(); } } 1.1 date: 2006/07/10 15:00:23; author: kkhan; state: Exp;jboss-aop/src/test/org/jboss/test/aop/jdk15annotated/AspectFromFactory.java Index: AspectFromFactory.java =================================================================== /* * 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.jdk15annotated; import org.jboss.aop.joinpoint.Invocation; /** * Aspect generated by AnnotatedAspectFactory. * @author Flavia Rainone *... [truncated message content] |