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.modifier;
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 perJVM
16 */
17 public class TestAspect {
18
19
20 /***
21 * @Expression call(private * test.modifier.*.*Method(..)) && within(test.modifier.*)
22 */
23 Pointcut call_privateMethod;
24
25 /***
26 * @Expression call(protected * test.modifier.*.*Method(..)) && within(test.modifier.*)
27 */
28 Pointcut call_protectedMethod;
29
30 /***
31 * @Expression call(public * test.modifier.*.*Method(..)) && within(test.modifier.*)
32 */
33 Pointcut call_publicMethod;
34
35 /***
36 * @Expression call(static final * test.modifier.*.*Method(..)) && within(test.modifier.*)
37 */
38 Pointcut call_staticFinalMethod;
39
40 /***
41 * @Expression execution(private * test.modifier.*.*Method(..))
42 */
43 Pointcut execution_privateMethod;
44
45 /***
46 * @Expression execution(protected * test.modifier.*.*Method(..))
47 */
48 Pointcut execution_protectedMethod;
49
50 /***
51 * @Expression execution(public * test.modifier.*.*Method(..))
52 */
53 Pointcut execution_publicMethod;
54
55 /***
56 * @Expression get(private * test.modifier.*.*Field)
57 */
58 Pointcut get_privateField;
59
60 /***
61 * @Expression get(protected * test.modifier.*.*Field)
62 */
63 Pointcut get_protectedField;
64
65 /***
66 * @Expression get(public * test.modifier.*.*Field)
67 */
68 Pointcut get_publicField;
69
70 /***
71 * @Expression set(private * test.modifier.*.*Field)
72 */
73 Pointcut set_privateField;
74
75 /***
76 * @Expression set(protected * test.modifier.*.*Field)
77 */
78 Pointcut set_protectedField;
79
80 /***
81 * @Expression set(public * test.modifier.*.*Field)
82 */
83 Pointcut set_publicField;
84
85
86
87 /***
88 * @Around call_privateMethod || call_publicMethod || call_protectedMethod ||
89 * call_staticFinalMethod
90 */
91 public Object advice_CALL(final JoinPoint joinPoint) throws Throwable {
92 ModifierTest.log("call ");
93 Object result = joinPoint.proceed();
94 ModifierTest.log("call ");
95 return result;
96 }
97
98 /***
99 * @Around execution_privateMethod || execution_protectedMethod || execution_publicMethod
100 */
101 public Object advice_EXECUTION(final JoinPoint joinPoint) throws Throwable {
102 ModifierTest.log("execution ");
103 Object result = joinPoint.proceed();
104 ModifierTest.log("execution ");
105 return result;
106 }
107
108 /***
109 * @Around set_privateField || set_protectedField || set_publicField
110 */
111 public Object advice_SET(final JoinPoint joinPoint) throws Throwable {
112 ModifierTest.log("set ");
113 Object result = joinPoint.proceed();
114 ModifierTest.log("set ");
115 return result;
116 }
117
118 /***
119 * @Around get_privateField || get_protectedField || get_publicField
120 */
121 public Object advice_GET(final JoinPoint joinPoint) throws Throwable {
122 ModifierTest.log("get ");
123 Object result = joinPoint.proceed();
124 ModifierTest.log("get ");
125 return result;
126 }
127 }