KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > reflection > TestAspect


1 /**************************************************************************************
2  * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package test.reflection;
9
10 import org.codehaus.aspectwerkz.definition.Pointcut;
11 import org.codehaus.aspectwerkz.definition.Pointcut;
12 import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
13
14 /**
15  * @author <a HREF="mailto:jboner@codehaus.org">Jonas Bonér </a>
16  * @Aspect
17  */

18 public class TestAspect {
19     /**
20      * @Expression execution(* test.reflection.*2.*(..))
21      */

22     Pointcut test1_exclude;
23
24     /**
25      * @Expression execution(* test.reflection.*.incr(..))
26      */

27     Pointcut test1;
28
29     /**
30      * @Expression execution(* test.reflection.*.incrStatic(..))
31      */

32     Pointcut test1Static;
33
34     /**
35      * @Expression execution(* test.reflection.Super2.incr(..))
36      */

37     Pointcut test2;
38
39     /**
40      * @Expression execution(* test.reflection.Super2.incrStatic(..))
41      */

42     Pointcut test2Static;
43
44     /**
45      * @Expression execution(* test.reflection.*.do*(..))
46      */

47     Pointcut test3;
48
49     /**
50      * @Around test1 && !test1_exclude
51      */

52     public Object JavaDoc execute1(final JoinPoint jp) throws Throwable JavaDoc {
53         Integer JavaDoc result = (Integer JavaDoc) jp.proceed();
54         return new Integer JavaDoc(-1 * result.intValue());
55     }
56
57     /**
58      * @Around test1Static && !test1_exclude
59      */

60     public Object JavaDoc execute2(final JoinPoint jp) throws Throwable JavaDoc {
61         Integer JavaDoc result = (Integer JavaDoc) jp.proceed();
62         return new Integer JavaDoc(-1 * result.intValue());
63     }
64
65     /**
66      * @Around test2
67      */

68     public Object JavaDoc execute3(final JoinPoint jp) throws Throwable JavaDoc {
69         Integer JavaDoc result = (Integer JavaDoc) jp.proceed();
70         return new Integer JavaDoc(-1 * result.intValue());
71     }
72
73     /**
74      * @Around test2Static
75      */

76     public Object JavaDoc execute4(final JoinPoint jp) throws Throwable JavaDoc {
77         Integer JavaDoc result = (Integer JavaDoc) jp.proceed();
78         return new Integer JavaDoc(-1 * result.intValue());
79     }
80
81     /**
82      * @Around test3
83      */

84     public Object JavaDoc execute5(final JoinPoint jp) throws Throwable JavaDoc {
85         Integer JavaDoc result = (Integer JavaDoc) jp.proceed();
86         return new Integer JavaDoc(-1 * result.intValue());
87     }
88 }
Popular Tags