KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > afterxxx > Aspect


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.afterxxx;
9
10 import org.codehaus.aspectwerkz.joinpoint.StaticJoinPoint;
11 import org.codehaus.aspectwerkz.definition.Pointcut;
12
13 /**
14  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
15  */

16 public class Aspect {
17
18     /**
19      * @Expression execution(* test.afterxxx.Test.all(..))
20      */

21     Pointcut all;
22
23     /**
24      * @Expression execution(* test.afterxxx.Test.aroundFinally(..))
25      */

26     Pointcut aroundFinally;
27
28     /**
29      * @Expression execution(* test.afterxxx.Test.aroundReturning(..))
30      */

31     Pointcut aroundReturning;
32
33     /**
34      * @Expression execution(* test.afterxxx.Test.aroundFinallyReturning(..))
35      */

36     Pointcut aroundFinallyReturning;
37
38     /**
39      * @Expression execution(* test.afterxxx.Test.aroundFinallyReturningThrowing(..))
40      */

41     Pointcut aroundFinallyReturningThrowing;
42
43     /**
44      * @Expression execution(* test.afterxxx.Test.aroundReturningThrowing(..))
45      */

46     Pointcut aroundReturningThrowing;
47
48     /**
49      * @Expression execution(* test.afterxxx.Test._finally(..))
50      */

51     Pointcut _finally;
52
53     /**
54      * @Expression execution(* test.afterxxx.Test.finallyReturning(..))
55      */

56     Pointcut finallyReturning;
57
58     /**
59      * @Expression execution(* test.afterxxx.Test.finallyReturningThrowing(..))
60      */

61     Pointcut finallyReturningThrowing;
62
63     /**
64      * @Expression execution(* test.afterxxx.Test.returning(..))
65      */

66     Pointcut returning;
67
68     /**
69      * @Expression execution(* test.afterxxx.Test.returningThrowing(..))
70      */

71     Pointcut returningThrowing;
72
73     /**
74      * @Around all || aroundFinally || aroundFinallyReturning ||
75      * aroundFinallyReturningThrowing || aroundReturningThrowing || aroundReturning
76      */

77     public Object JavaDoc logAround(StaticJoinPoint joinPoint) throws Throwable JavaDoc {
78         Test.log("logAround ");
79         final Object JavaDoc result = joinPoint.proceed();
80         return result;
81     }
82
83     /**
84      * @AfterReturning aroundFinallyReturning || aroundFinallyReturningThrowing ||
85      * aroundReturningThrowing || finallyReturning || finallyReturningThrowing ||
86      * returningThrowing || aroundReturning || returning
87      */

88     public void logAfterReturning(final StaticJoinPoint joinPoint) throws Throwable JavaDoc {
89         Test.log("logAfterReturning ");
90     }
91
92     /**
93      * @AfterReturning(type="java.lang.String", pointcut="aroundFinallyReturning || aroundFinallyReturningThrowing ||
94      * aroundReturningThrowing || finallyReturning || finallyReturningThrowing ||
95      * returningThrowing || aroundReturning || returning")
96      */

97     public void logAfterReturningString(final StaticJoinPoint joinPoint) throws Throwable JavaDoc {
98         Test.log("logAfterReturningString ");
99     }
100
101     /**
102      * @AfterThrowing(type="java.lang.RuntimeException", pointcut="aroundFinallyReturningThrowing ||
103      * aroundReturningThrowing ||
104      * finallyReturningThrowing || returningThrowing")
105      */

106     public void logAfterThrowingRTE(final StaticJoinPoint joinPoint) throws Throwable JavaDoc {
107         Test.log("logAfterThrowingRTE ");
108     }
109
110     /**
111      * @AfterThrowing(type="java.lang.IllegalArgumentException", pointcut="
112      * aroundFinallyReturningThrowing || aroundReturningThrowing ||
113      * finallyReturningThrowing || returningThrowing")
114      */

115     public void logAfterThrowing(final StaticJoinPoint joinPoint) throws Throwable JavaDoc {
116         Test.log("logAfterThrowing ");
117     }
118
119     /**
120      * @AfterFinally aroundFinally || aroundFinallyReturning || aroundFinallyReturningThrowing ||
121      * _finally || finallyReturning || finallyReturningThrowing
122      */

123     public void logAfterFinally(final StaticJoinPoint joinPoint) throws Throwable JavaDoc {
124         Test.log("logAfterFinally ");
125     }
126
127     /**
128      * @After finallyReturning
129      */

130     public void logAfter(final StaticJoinPoint joinPoint) throws Throwable JavaDoc {
131         Test.log("logAfter ");
132     }
133
134     /**
135      * @AfterReturning(type="i", pointcut="execution(* test.afterxxx.TestBinding.returnInt(..))")
136      */

137     public void logAfterBinding(int i) {
138         TestBinding.log("afterReturningInt " + i);
139     }
140
141     /**
142      * @AfterReturning(type="s", pointcut="execution(* test.afterxxx.TestBinding.returnString(..))")
143      */

144     public void logAfterBinding(String JavaDoc s) {
145         TestBinding.log("afterReturningString " + s);
146     }
147
148     /**
149      * @AfterThrowing(type="e", pointcut="execution(* test.afterxxx.TestBinding.throwChecked(..))")
150      */

151     public void logAfterBindingExact(ClassNotFoundException JavaDoc e) {
152         TestBinding.log("afterThrowingExact " + e.getClass().getName());
153     }
154
155     /**
156      * @AfterThrowing(type="e", pointcut="execution(* test.afterxxx.TestBinding.throwChecked(..))")
157      */

158     public void logAfterBindingParentClass(Exception JavaDoc e) {
159         TestBinding.log(" afterThrowingParentClass " + e.getClass().getName());
160     }
161 }
Popular Tags