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.aspect;
9
10 import test.FieldAdviceTest;
11 import org.codehaus.aspectwerkz.definition.Pointcut;
12 import org.codehaus.aspectwerkz.definition.Pointcut;
13 import org.codehaus.aspectwerkz.joinpoint.FieldRtti;
14 import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
15
16 /***
17 * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
18 * @Aspect perJVM
19 */
20 public class FieldTestAspect {
21
22
23 /***
24 * @Expression set(* test.FieldAdviceTest.m_setFieldPreAdvice*)
25 */
26 Pointcut pc1;
27
28 /***
29 * @Expression set(int test.FieldAdviceTest.m_setFieldPreAdvi*)
30 */
31 Pointcut pc2;
32
33 /***
34 * @Expression set(* test.FieldAdviceTest.m_setFie*dPostAdviced)
35 */
36 Pointcut pc3;
37
38 /***
39 * @Expression set(* test.FieldAdviceTest.m_se*FieldPostAdviced)
40 */
41 Pointcut pc4;
42
43 /***
44 * @Expression set(* test.FieldAdviceTest.m_setFieldPrePostAdviced)
45 */
46 Pointcut pc5;
47
48 /***
49 * @Expression get(* test.FieldAdviceTest.m_getFieldPreAdvic*)
50 */
51 Pointcut pc6;
52
53 /***
54 * @Expression get(* test.FieldAdviceTest.m_getFieldPreAdvice*)
55 */
56 Pointcut pc7;
57
58 /***
59 * @Expression get(* test.FieldAdviceTest.m_getFieldPostAdviced)
60 */
61 Pointcut pc8;
62
63 /***
64 * @Expression get(* test.FieldAdviceTest.m_getFieldPrePostAdviced)
65 */
66 Pointcut pc9;
67
68 /***
69 * @Expression set(* test.FieldAdviceTest.s_setStaticFieldPreAdvic*)
70 */
71 Pointcut pc10;
72
73 /***
74 * @Expression set(* test.FieldAdviceTest.s_setStaticFieldPreAdvice*)
75 */
76 Pointcut pc11;
77
78 /***
79 * @Expression set(* test.FieldAdviceTest.s_setStaticFieldPostAdviced)
80 */
81 Pointcut pc12;
82
83 /***
84 * @Expression set(* test.FieldAdviceTest.s_setStaticFieldPrePostAdviced)
85 */
86 Pointcut pc13;
87
88 /***
89 * @Expression get(* test.FieldAdviceTest.s_getStaticFieldPreAdvice*)
90 */
91 Pointcut pc14;
92
93 /***
94 * @Expression get(* test.FieldAdviceTest.s_getStaticFieldPreAdvic*)
95 */
96 Pointcut pc15;
97
98 /***
99 * @Expression get(* test.FieldAdviceTest.s_getStaticFieldPostAdviced)
100 */
101 Pointcut pc16;
102
103 /***
104 * @Expression get(* test.FieldAdviceTest.s_getStaticFieldPrePostAdviced)
105 */
106 Pointcut pc17;
107
108 /***
109 * @Expression set(* test.FieldAdviceTest.m_setFieldAroundAdviced)
110 */
111 Pointcut pc18;
112
113 /***
114 * @Expression set(* test.FieldAdviceTest.s_setStaticFieldAroundAdviced)
115 */
116 Pointcut pc19;
117
118 /***
119 * @Expression get(* test.FieldAdviceTest.m_getFieldAroundAdviced)
120 */
121 Pointcut pc20;
122
123 /***
124 * @Expression get(* test.FieldAdviceTest.s_getStaticFieldAroundAdviced)
125 */
126 Pointcut pc21;
127
128 /***
129 * @Expression set(* test.FieldAdviceTest.m_setFieldAroundAdviced*WithNullAdvice)
130 */
131 Pointcut pc22;
132
133 /***
134 * @Expression get(* test.FieldAdviceTest.m_getFieldAroundAdvicedWithNullAdvice)
135 */
136 Pointcut pc23;
137
138 /***
139 * @Expression set(* test.FieldAdviceTest.m_setFieldAroundAdvicedObjectWithAPI)
140 */
141 Pointcut pc24;
142
143 /***
144 * @Expression set(* test.FieldAdviceTest.m_setFieldAroundAdvicedWithAPI)
145 */
146 Pointcut pc25;
147
148 /***
149 * @Expression within(test.FieldAdviceTest)
150 */
151 Pointcut filter;
152
153
154
155 /***
156 * @Before filter && (pc2 || pc5 || pc10 || pc13 || pc6 || pc9 || pc14 || pc17)
157 */
158 public void preAdvice1(final JoinPoint joinPoint) throws Throwable {
159 FieldAdviceTest.log("pre1 ");
160 }
161
162 /***
163 * @Before filter && (pc1 || pc5 || pc11 || pc13 || pc7 || pc9 || pc15 || pc17)
164 */
165 public void preAdvice2(final JoinPoint joinPoint) throws Throwable {
166 FieldAdviceTest.log("pre2 ");
167 }
168
169 /***
170 * @After filter && (pc4 || pc5 || pc12 || pc13 || pc8 || pc9 || pc16 || pc17)
171 */
172 public void postAdvice1(final JoinPoint joinPoint) throws Throwable {
173 FieldAdviceTest.log("post1 ");
174 }
175
176 /***
177 * @After filter && (pc3 || pc5 || pc12 || pc13 || pc8 || pc9 || pc16 || pc17)
178 */
179 public void postAdvice2(final JoinPoint joinPoint) throws Throwable {
180 FieldAdviceTest.log("post2 ");
181 }
182
183 /***
184 * @Around filter && (pc18 || pc19 || pc20 || pc21)
185 */
186 public Object around(final JoinPoint joinPoint) throws Throwable {
187 FieldAdviceTest.log("before ");
188 final Object result = joinPoint.proceed();
189 FieldAdviceTest.log("after ");
190 return result;
191 }
192
193 /***
194 * @Around filter && (pc22 || pc23)
195 */
196 public Object aroundNullAdvice(final JoinPoint joinPoint) throws Throwable {
197 FieldAdviceTest.log("before ");
198 final Object result = joinPoint.proceed();
199 FieldAdviceTest.log("after ");
200 return null;
201 }
202
203 /***
204 * @Before get(java.io.PrintStream out) && withincode(* test.FieldAdviceTest.testPublicFieldOutOfWeaverScope())
205 */
206 public void beforePublicFieldOutOfWeaverScope() {
207 FieldAdviceTest.log("adviceOnPublicField ");
208 }
209
210
211
212
213
214 /***
215 // * @Around pc24
216 // */
217
218
219
220
221
222
223
224
225
226 /***
227 // * @Around pc25
228 // */
229
230
231
232
233
234
235
236
237 }