KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > staticinitialization > StaticInitializationAspect


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.staticinitialization;
9
10 import org.codehaus.aspectwerkz.definition.Pointcut;
11 import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
12 import org.codehaus.aspectwerkz.joinpoint.StaticJoinPoint;
13
14
15 /**
16  * Aspect on staticinitialization pointcut.
17  *
18  * @author <a HREF="mailto:the_mindstorm@evolva.ro">Alex Popescu</a>
19  *
20  * @Aspect("perClass")
21  */

22 public class StaticInitializationAspect {
23     /**
24      * @Expression staticinitialization(test.staticinitialization.ClinitTarget)
25      */

26     Pointcut staticInitialization;
27     
28     /**
29      * @Expression staticinitialization(@StaticInitializationService)
30      */

31     Pointcut staticServiceInitialization;
32     
33     /**
34      * @Expression staticinitialization(@StaticInitializationService test.staticinitialization.*)
35      */

36     Pointcut staticPatternInitialization;
37     
38     /**
39      * @Before staticInitialization
40      */

41     public void beforeStaticInitializer() {
42         StaticInitializationTest.s_messages.add(StaticInitializationTest.BEFORE_EXPECTED_MESSAGES[0]);
43     }
44     
45     /**
46      * @Before staticServiceInitialization
47      */

48     public void beforeStaticServiceInitialization() {
49         StaticInitializationTest.s_messages.add(StaticInitializationTest.BEFORE_EXPECTED_MESSAGES[0]);
50     }
51     
52     /**
53      * @Before staticPatternInitialization
54      */

55     public void beforeStaticPatternInitialization() {
56         StaticInitializationTest.s_messages.add(StaticInitializationTest.BEFORE_EXPECTED_MESSAGES[0]);
57     }
58     
59     /**
60      * @Before staticInitialization
61      */

62     public void beforeStaticInitialization(StaticJoinPoint sjp) {
63         StaticInitializationTest.s_staticJoinPoints.add(sjp);
64     }
65     
66     /**
67      * @Before staticServiceInitialization
68      */

69     public void beforeStaticServiceInitialization(StaticJoinPoint sjp) {
70         StaticInitializationTest.s_staticJoinPoints.add(sjp);
71     }
72     
73     /**
74      * @Before staticPatternInitialization
75      */

76     public void beforeStaticPatternInitialization(StaticJoinPoint sjp) {
77         StaticInitializationTest.s_staticJoinPoints.add(sjp);
78     }
79     
80     /**
81      * @Before staticInitialization
82      */

83     public void beforeStaticInitialization(JoinPoint jp) {
84         StaticInitializationTest.s_joinPoints.add(jp);
85     }
86     
87     /**
88      * @Before staticServiceInitialization
89      */

90     public void beforeStaticServiceInitialization(JoinPoint jp) {
91         StaticInitializationTest.s_joinPoints.add(jp);
92     }
93     
94     /**
95      * @Before staticPatternInitialization
96      */

97     public void beforeStaticPatternInitialization(JoinPoint jp) {
98         StaticInitializationTest.s_joinPoints.add(jp);
99     }
100     
101     /**
102      * @Around staticInitialization
103      */

104     public Object JavaDoc aroundStaticInitialization(StaticJoinPoint sjp) throws Throwable JavaDoc {
105         StaticInitializationTest.s_messages.add(StaticInitializationTest.BEFORE_EXPECTED_MESSAGES[1]);
106         StaticInitializationTest.s_staticJoinPoints.add(sjp);
107         
108         return sjp.proceed();
109     }
110     
111     /**
112      * @Around staticServiceInitialization
113      */

114     public Object JavaDoc aroundStaticServiceInitialization(StaticJoinPoint sjp) throws Throwable JavaDoc {
115         StaticInitializationTest.s_messages.add(StaticInitializationTest.BEFORE_EXPECTED_MESSAGES[1]);
116         StaticInitializationTest.s_staticJoinPoints.add(sjp);
117         
118         return sjp.proceed();
119     }
120     
121     /**
122      * @Around staticPatternInitialization
123      */

124     public Object JavaDoc aroundStaticPatternInitialization(StaticJoinPoint sjp) throws Throwable JavaDoc {
125         StaticInitializationTest.s_messages.add(StaticInitializationTest.BEFORE_EXPECTED_MESSAGES[1]);
126         StaticInitializationTest.s_staticJoinPoints.add(sjp);
127         
128         return sjp.proceed();
129     }
130     
131     /**
132      * @Around staticInitialization
133      */

134     public Object JavaDoc aroundStaticInitialization(JoinPoint jp) throws Throwable JavaDoc {
135         StaticInitializationTest.s_messages.add(StaticInitializationTest.BEFORE_EXPECTED_MESSAGES[2]);
136         StaticInitializationTest.s_joinPoints.add(jp);
137         
138         return jp.proceed();
139     }
140     
141     /**
142      * @Around staticServiceInitialization
143      */

144     public Object JavaDoc aroundStaticServiceInitialization(JoinPoint jp) throws Throwable JavaDoc {
145         StaticInitializationTest.s_messages.add(StaticInitializationTest.BEFORE_EXPECTED_MESSAGES[2]);
146         StaticInitializationTest.s_joinPoints.add(jp);
147         
148         return jp.proceed();
149     }
150     
151     /**
152      * @Around staticPatternInitialization
153      */

154     public Object JavaDoc aroundStaticPatternInitialization(JoinPoint jp) throws Throwable JavaDoc {
155         StaticInitializationTest.s_messages.add(StaticInitializationTest.BEFORE_EXPECTED_MESSAGES[2]);
156         StaticInitializationTest.s_joinPoints.add(jp);
157         
158         return jp.proceed();
159     }
160     
161     /**
162      * @AfterReturning staticInitialization
163      */

164     public void afterReturningStaticInitializer() {
165         StaticInitializationTest.s_messages.add(StaticInitializationTest.AFTER_EXPECTED_MESSAGES[0]);
166     }
167
168     /**
169      * @AfterReturning staticServiceInitialization
170      */

171     public void afterReturningServiceInitializer() {
172         StaticInitializationTest.s_messages.add(StaticInitializationTest.AFTER_EXPECTED_MESSAGES[0]);
173     }
174     
175     /**
176      * @AfterReturning staticPatternInitialization
177      */

178     public void afterReturningPatternInitializer() {
179         StaticInitializationTest.s_messages.add(StaticInitializationTest.AFTER_EXPECTED_MESSAGES[0]);
180     }
181     
182     /**
183      * @AfterReturning staticInitialization
184      */

185     public void afterReturningStaticInitializer(StaticJoinPoint sjp) {
186         StaticInitializationTest.s_staticJoinPoints.add(sjp);
187     }
188     
189     /**
190      * @AfterReturning staticServiceInitialization
191      */

192     public void afterReturningServiceInitializer(StaticJoinPoint sjp) {
193         StaticInitializationTest.s_staticJoinPoints.add(sjp);
194     }
195     
196     /**
197      * @AfterReturning staticPatternInitialization
198      */

199     public void afterReturningPatternInitializer(StaticJoinPoint sjp) {
200         StaticInitializationTest.s_staticJoinPoints.add(sjp);
201     }
202     
203     /**
204      * @AfterReturning staticInitialization
205      */

206     public void afterReturningStaticInitializer(JoinPoint jp) {
207         StaticInitializationTest.s_joinPoints.add(jp);
208     }
209     
210     /**
211      * @AfterReturning staticServiceInitialization
212      */

213     public void afterReturningServiceInitializer(JoinPoint jp) {
214         StaticInitializationTest.s_joinPoints.add(jp);
215     }
216     
217     /**
218      * @AfterReturning staticPatternInitialization
219      */

220     public void afterReturningPatternInitializer(JoinPoint jp) {
221         StaticInitializationTest.s_joinPoints.add(jp);
222     }
223     
224     /**
225      * @After staticInitialization
226      */

227     public void afterStaticInitializer() {
228         StaticInitializationTest.s_messages.add(StaticInitializationTest.AFTER_EXPECTED_MESSAGES[1]);
229     }
230     
231     /**
232      * @After staticServiceInitialization
233      */

234     public void afterServiceInitializer() {
235         StaticInitializationTest.s_messages.add(StaticInitializationTest.AFTER_EXPECTED_MESSAGES[1]);
236     }
237     
238     /**
239      * @After staticPatternInitialization
240      */

241     public void afterPatternInitializer() {
242         StaticInitializationTest.s_messages.add(StaticInitializationTest.AFTER_EXPECTED_MESSAGES[1]);
243     }
244     
245     /**
246      * @After staticInitialization
247      */

248     public void afterStaticInitializer(StaticJoinPoint sjp) {
249         StaticInitializationTest.s_staticJoinPoints.add(sjp);
250     }
251     
252     /**
253      * @After staticServiceInitialization
254      */

255     public void afterServiceInitializer(StaticJoinPoint sjp) {
256         StaticInitializationTest.s_staticJoinPoints.add(sjp);
257     }
258     
259     /**
260      * @After staticPatternInitialization
261      */

262     public void afterPatternInitializer(StaticJoinPoint sjp) {
263         StaticInitializationTest.s_staticJoinPoints.add(sjp);
264     }
265     
266     /**
267      * @After staticInitialization
268      */

269     public void afterStaticInitializer(JoinPoint jp) {
270         StaticInitializationTest.s_joinPoints.add(jp);
271     }
272     
273     /**
274      * @After staticServiceInitialization
275      */

276     public void afterServiceInitializer(JoinPoint jp) {
277         StaticInitializationTest.s_joinPoints.add(jp);
278     }
279     
280     /**
281      * @After staticPatternInitialization
282      */

283     public void afterPatternInitializer(JoinPoint jp) {
284         StaticInitializationTest.s_joinPoints.add(jp);
285     }
286 }
287
Popular Tags