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.enclosingsjp;
9   
10  
11  import org.codehaus.aspectwerkz.definition.Pointcut;
12  import org.codehaus.aspectwerkz.joinpoint.ConstructorSignature;
13  import org.codehaus.aspectwerkz.joinpoint.EnclosingStaticJoinPoint;
14  import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
15  import org.codehaus.aspectwerkz.joinpoint.Signature;
16  import org.codehaus.aspectwerkz.joinpoint.StaticJoinPoint;
17  
18  
19  /***
20   * @Aspect("perClass")
21   */
22  public class EnclosingStaticJoinPointAspect {
23  
24  	/***
25  	 * @Before call(test.enclosingsjp.PointcutTarget.new()) && within(test.enclosingsjp..*)
26  	 */
27  	public void ctorCtorCall(StaticJoinPoint sjp) {
28  		//System.out.println(".ctorCtorCall");
29  		EnclosingStaticJoinPoint esjp = sjp.getEnclosingStaticJoinPoint();
30  		EnclosingSJPTest.registerEnclosingSJP(esjp);
31  	}
32  	
33  	/***
34  	 * @Before call(* test.enclosingsjp.PointcutTarget.method1()) && within(test.enclosingsjp..*)
35  	 */
36  	public void ctorMethodCall(StaticJoinPoint sjp) {
37  		//System.out.println(".ctorMethodCall");
38  		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
39  	}
40  	
41  	/***
42  	 * @Before call(test.enclosingsjp.PointcutTarget.new()) && within(test.enclosingsjp.EnclosingTarget)
43  	 * @param sjp
44  	 */
45  	public void ctorCtorWithinCall(StaticJoinPoint sjp) {
46  		//System.out.println(".ctorCtorWithinCall");
47  		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
48  	}
49  	
50  	/***
51  	 * @Before call(test.enclosingsjp.PointcutTarget.new()) && withincode(test.enclosingsjp.EnclosingTarget.new())
52  	 * @param sjp
53  	 */
54  	public void ctorCtorWithincodeCall(StaticJoinPoint sjp) {
55  		//System.out.println(".ctorCtorWithincodeCall");
56  		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
57  	}
58  	
59  	/***
60  	 * @Before call(test.enclosingsjp.PointcutTarget.new()) && within(test.enclosingsjp..*) && cflow(execution(test.enclosingsjp.EnclosingTarget.new()))
61  	 * @param sjp
62  	 */
63  	public void ctorCtorCflow(StaticJoinPoint sjp) {
64  		//System.out.println(".ctorCtorCflow");
65  		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
66  	}
67  	
68  	/***
69  	 * @Before call(test.enclosingsjp.PointcutTarget.new()) && within(test.enclosingsjp..*) && cflowbelow(execution(test.enclosingsjp.EnclosingTarget.new()))
70  	 * @param sjp
71  	 */
72  	public void ctorCtorCflowbelowExecution(StaticJoinPoint sjp) {
73  		//System.out.println(".ctorCtorCflowbelowExecution");
74  		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
75  	}
76  	
77  	/***
78  	 * @Before within(test.enclosingsjp..*) && call(test.enclosingsjp.PointcutTarget.new()) && cflowbelow(call(test.enclosingsjp.EnclosingTarget.new()) && within(test.enclosingsjp..*))
79  	 * @param sjp
80  	 */
81  	public void ctorCtorCflowbelowCall(StaticJoinPoint sjp) {
82  		//System.out.println(".ctorCtorCflowbelowCall");
83  		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
84  	}
85  	
86  	/***
87  	 * @Before within(test.enclosingsjp..*) && call(test.enclosingsjp.PointcutTarget.new()) && cflowbelow(execution(* test.enclosingsjp.EnclosingSJPTest.testConstructorEnclosing()))
88  	 * @param sjp
89  	 */
90  	public void testCtorCflowbelow(StaticJoinPoint sjp) {
91  		//System.out.println(".testCtorCflowbelow");
92  		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
93  	}
94  	
95  	/***
96  	 * @Before handler(java.lang.IllegalAccessException) AND within(test.enclosingsjp.*)
97  	 */
98  	public void simpleHandler(StaticJoinPoint sjp) {
99  		//System.out.println(".simpleHandler");
100 		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
101 	}
102 	
103 	/***
104 	 * @Before handler(java.lang.IllegalAccessException) AND within(test.enclosingsjp.*) AND args(iae)
105 	 */
106 	public void parameterHandler(StaticJoinPoint sjp, IllegalAccessException iae) {
107 		//System.out.println(".parameterHandler");
108 		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
109 	}
110 	
111 	/***
112 	 * @Expression set(java.lang.Object test.enclosingsjp.EnclosingTarget.m_field) && within(test.enclosingsjp..*)
113 	 */
114 	private Pointcut enclosingSet;
115 	
116 	/***
117 	 * @Before enclosingSet 
118 	 */
119 	public void enclosingConstructorSet(StaticJoinPoint sjp) {
120 		//System.out.println(".enclosingConstructorSet");
121 		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
122 	}
123 	
124 	/***
125 	 * @Before enclosingSet && cflow(call(test.enclosingsjp.EnclosingTarget.new(java.lang.Object)) && within(test.enclosingsjp..*))
126 	 * @param sjp
127 	 */
128 	public void cflowCallSet(StaticJoinPoint sjp) {
129 		//System.out.println(".cflowCallSet");
130 		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
131 	}
132 
133 	/***
134 	 * @Before enclosingSet && cflow(execution(test.enclosingsjp.EnclosingTarget.new(java.lang.Object)))
135 	 * @param sjp
136 	 */
137 	public void cflowExecuteSet(StaticJoinPoint sjp) {
138 		//System.out.println(".cflowExecuteSet");
139 		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
140 	}
141 
142 	/***
143 	 * @Expression("(set(java.lang.Object test.enclosingsjp.PointcutTarget.m_field) || get(java.lang.Object test.enclosingsjp.PointcutTarget.m_field)) && within(test.enclosingsjp..*)")
144 	 */
145 	private Pointcut getset;
146 	
147 	/***
148 	 * @Before getset
149 	 */
150 	public void  methodGetSet(StaticJoinPoint sjp) {
151 		//System.out.println(".methodGetSet");
152 		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
153 	}
154 
155 	/***
156 	 * @Before getset && cflow(execution(test.enclosingsjp.EnclosingTarget.new(*)))
157 	 */
158 	public void methodCflowGetSet(StaticJoinPoint sjp) {
159 		//System.out.println(".methodCflowGetSet");
160 		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
161 	}
162 
163 	/***
164 	 * @Before getset && cflowbelow(call(test.enclosingsjp.EnclosingTarget.new(*)) && within(test.enclosingsjp..*))
165 	 */
166 	public void methodCflowbelowGetSet(StaticJoinPoint sjp) {
167 		//System.out.println(".methodCflowbelowGetSet");
168 		EnclosingSJPTest.registerEnclosingSJP(sjp.getEnclosingStaticJoinPoint());
169 	}
170 
171 }