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.pointcutexpression;
9   
10  import org.codehaus.aspectwerkz.Pointcut;
11  import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
12  
13  /***
14   * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a>
15   * @Aspect
16   */
17  public class TestAspect {
18      /***
19       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.A())
20       */
21      Pointcut A;
22  
23      /***
24       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.B())
25       */
26      Pointcut B;
27  
28      /***
29       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.C())
30       */
31      Pointcut C;
32  
33      /***
34       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.D())
35       */
36      Pointcut D;
37  
38      /***
39       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.E())
40       */
41      Pointcut E;
42  
43      /***
44       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.F())
45       */
46      Pointcut F;
47  
48      /***
49       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.G())
50       */
51      Pointcut G;
52  
53      /***
54       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.H())
55       */
56      Pointcut H;
57  
58      /***
59       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.I())
60       */
61      Pointcut I;
62  
63      /***
64       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.J())
65       */
66      Pointcut J;
67  
68      /***
69       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.K())
70       */
71      Pointcut K;
72  
73      /***
74       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.L())
75       */
76      Pointcut L;
77  
78      /***
79       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.M())
80       */
81      Pointcut M;
82  
83      /***
84       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.N())
85       */
86      Pointcut N;
87  
88      /***
89       * @Expression execution(void test.pointcutexpression.PointcutExpressionTest.O())
90       */
91      Pointcut O;
92  
93      /***
94       * @Around B || C
95       */
96      public Object advice1(final JoinPoint joinPoint) throws Throwable {
97          PointcutExpressionTest.log("before1 ");
98          final Object result = joinPoint.proceed();
99          PointcutExpressionTest.log("after1 ");
100         return result;
101     }
102 
103     /***
104      * @Around D && !E
105      */
106     public Object advice2(final JoinPoint joinPoint) throws Throwable {
107         PointcutExpressionTest.log("before1 ");
108         final Object result = joinPoint.proceed();
109         PointcutExpressionTest.log("after1 ");
110         return result;
111     }
112 
113     /***
114      * @Around (F || G) && H
115      */
116     public Object advice3(final JoinPoint joinPoint) throws Throwable {
117         PointcutExpressionTest.log("before1 ");
118         final Object result = joinPoint.proceed();
119         PointcutExpressionTest.log("after1 ");
120         return result;
121     }
122 
123     /***
124      * @Around (I || J)
125      */
126     public Object advice4(final JoinPoint joinPoint) throws Throwable {
127         PointcutExpressionTest.log("before1 ");
128         final Object result = joinPoint.proceed();
129         PointcutExpressionTest.log("after1 ");
130         return result;
131     }
132 
133     /***
134      * @Around !K && !(L || M) && N
135      */
136     public Object advice5(final JoinPoint joinPoint) throws Throwable {
137         PointcutExpressionTest.log("before1 ");
138         final Object result = joinPoint.proceed();
139         PointcutExpressionTest.log("after1 ");
140         return result;
141     }
142 
143     /***
144      * @Around O
145      */
146     public Object advice6(final JoinPoint joinPoint) throws Throwable {
147         PointcutExpressionTest.log("before1 ");
148         final Object result = joinPoint.proceed();
149         PointcutExpressionTest.log("after1 ");
150         return result;
151     }
152 }