001: /**************************************************************************************
002: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
003: * http://aspectwerkz.codehaus.org *
004: * ---------------------------------------------------------------------------------- *
005: * The software in this package is published under the terms of the LGPL license *
006: * a copy of which has been included with this distribution in the license.txt file. *
007: **************************************************************************************/package test.enclosingsjp;
008:
009: import org.codehaus.aspectwerkz.definition.Pointcut;
010: import org.codehaus.aspectwerkz.joinpoint.ConstructorSignature;
011: import org.codehaus.aspectwerkz.joinpoint.EnclosingStaticJoinPoint;
012: import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
013: import org.codehaus.aspectwerkz.joinpoint.Signature;
014: import org.codehaus.aspectwerkz.joinpoint.StaticJoinPoint;
015:
016: /**
017: * @Aspect("perClass")
018: */
019: public class EnclosingStaticJoinPointAspect {
020:
021: /**
022: * @Before call(test.enclosingsjp.PointcutTarget.new()) && within(test.enclosingsjp..*)
023: */
024: public void ctorCtorCall(StaticJoinPoint sjp) {
025: //System.out.println(".ctorCtorCall");
026: EnclosingStaticJoinPoint esjp = sjp
027: .getEnclosingStaticJoinPoint();
028: EnclosingSJPTest.registerEnclosingSJP(esjp);
029: }
030:
031: /**
032: * @Before call(* test.enclosingsjp.PointcutTarget.method1()) && within(test.enclosingsjp..*)
033: */
034: public void ctorMethodCall(StaticJoinPoint sjp) {
035: //System.out.println(".ctorMethodCall");
036: EnclosingSJPTest.registerEnclosingSJP(sjp
037: .getEnclosingStaticJoinPoint());
038: }
039:
040: /**
041: * @Before call(test.enclosingsjp.PointcutTarget.new()) && within(test.enclosingsjp.EnclosingTarget)
042: * @param sjp
043: */
044: public void ctorCtorWithinCall(StaticJoinPoint sjp) {
045: //System.out.println(".ctorCtorWithinCall");
046: EnclosingSJPTest.registerEnclosingSJP(sjp
047: .getEnclosingStaticJoinPoint());
048: }
049:
050: /**
051: * @Before call(test.enclosingsjp.PointcutTarget.new()) && withincode(test.enclosingsjp.EnclosingTarget.new())
052: * @param sjp
053: */
054: public void ctorCtorWithincodeCall(StaticJoinPoint sjp) {
055: //System.out.println(".ctorCtorWithincodeCall");
056: EnclosingSJPTest.registerEnclosingSJP(sjp
057: .getEnclosingStaticJoinPoint());
058: }
059:
060: /**
061: * @Before call(test.enclosingsjp.PointcutTarget.new()) && within(test.enclosingsjp..*) && cflow(execution(test.enclosingsjp.EnclosingTarget.new()))
062: * @param sjp
063: */
064: public void ctorCtorCflow(StaticJoinPoint sjp) {
065: //System.out.println(".ctorCtorCflow");
066: EnclosingSJPTest.registerEnclosingSJP(sjp
067: .getEnclosingStaticJoinPoint());
068: }
069:
070: /**
071: * @Before call(test.enclosingsjp.PointcutTarget.new()) && within(test.enclosingsjp..*) && cflowbelow(execution(test.enclosingsjp.EnclosingTarget.new()))
072: * @param sjp
073: */
074: public void ctorCtorCflowbelowExecution(StaticJoinPoint sjp) {
075: //System.out.println(".ctorCtorCflowbelowExecution");
076: EnclosingSJPTest.registerEnclosingSJP(sjp
077: .getEnclosingStaticJoinPoint());
078: }
079:
080: /**
081: * @Before within(test.enclosingsjp..*) && call(test.enclosingsjp.PointcutTarget.new()) && cflowbelow(call(test.enclosingsjp.EnclosingTarget.new()) && within(test.enclosingsjp..*))
082: * @param sjp
083: */
084: public void ctorCtorCflowbelowCall(StaticJoinPoint sjp) {
085: //System.out.println(".ctorCtorCflowbelowCall");
086: EnclosingSJPTest.registerEnclosingSJP(sjp
087: .getEnclosingStaticJoinPoint());
088: }
089:
090: /**
091: * @Before within(test.enclosingsjp..*) && call(test.enclosingsjp.PointcutTarget.new()) && cflowbelow(execution(* test.enclosingsjp.EnclosingSJPTest.testConstructorEnclosing()))
092: * @param sjp
093: */
094: public void testCtorCflowbelow(StaticJoinPoint sjp) {
095: //System.out.println(".testCtorCflowbelow");
096: EnclosingSJPTest.registerEnclosingSJP(sjp
097: .getEnclosingStaticJoinPoint());
098: }
099:
100: /**
101: * @Before handler(java.lang.IllegalAccessException) AND within(test.enclosingsjp.*)
102: */
103: public void simpleHandler(StaticJoinPoint sjp) {
104: //System.out.println(".simpleHandler");
105: EnclosingSJPTest.registerEnclosingSJP(sjp
106: .getEnclosingStaticJoinPoint());
107: }
108:
109: /**
110: * @Before handler(java.lang.IllegalAccessException) AND within(test.enclosingsjp.*) AND args(iae)
111: */
112: public void parameterHandler(StaticJoinPoint sjp,
113: IllegalAccessException iae) {
114: //System.out.println(".parameterHandler");
115: EnclosingSJPTest.registerEnclosingSJP(sjp
116: .getEnclosingStaticJoinPoint());
117: }
118:
119: /**
120: * @Expression set(java.lang.Object test.enclosingsjp.EnclosingTarget.m_field) && within(test.enclosingsjp..*)
121: */
122: private Pointcut enclosingSet;
123:
124: /**
125: * @Before enclosingSet
126: */
127: public void enclosingConstructorSet(StaticJoinPoint sjp) {
128: //System.out.println(".enclosingConstructorSet");
129: EnclosingSJPTest.registerEnclosingSJP(sjp
130: .getEnclosingStaticJoinPoint());
131: }
132:
133: /**
134: * @Before enclosingSet && cflow(call(test.enclosingsjp.EnclosingTarget.new(java.lang.Object)) && within(test.enclosingsjp..*))
135: * @param sjp
136: */
137: public void cflowCallSet(StaticJoinPoint sjp) {
138: //System.out.println(".cflowCallSet");
139: EnclosingSJPTest.registerEnclosingSJP(sjp
140: .getEnclosingStaticJoinPoint());
141: }
142:
143: /**
144: * @Before enclosingSet && cflow(execution(test.enclosingsjp.EnclosingTarget.new(java.lang.Object)))
145: * @param sjp
146: */
147: public void cflowExecuteSet(StaticJoinPoint sjp) {
148: //System.out.println(".cflowExecuteSet");
149: EnclosingSJPTest.registerEnclosingSJP(sjp
150: .getEnclosingStaticJoinPoint());
151: }
152:
153: /**
154: * @Expression("(set(java.lang.Object test.enclosingsjp.PointcutTarget.m_field) || get(java.lang.Object test.enclosingsjp.PointcutTarget.m_field)) && within(test.enclosingsjp..*)")
155: */
156: private Pointcut getset;
157:
158: /**
159: * @Before getset
160: */
161: public void methodGetSet(StaticJoinPoint sjp) {
162: //System.out.println(".methodGetSet");
163: EnclosingSJPTest.registerEnclosingSJP(sjp
164: .getEnclosingStaticJoinPoint());
165: }
166:
167: /**
168: * @Before getset && cflow(execution(test.enclosingsjp.EnclosingTarget.new(*)))
169: */
170: public void methodCflowGetSet(StaticJoinPoint sjp) {
171: //System.out.println(".methodCflowGetSet");
172: EnclosingSJPTest.registerEnclosingSJP(sjp
173: .getEnclosingStaticJoinPoint());
174: }
175:
176: /**
177: * @Before getset && cflowbelow(call(test.enclosingsjp.EnclosingTarget.new(*)) && within(test.enclosingsjp..*))
178: */
179: public void methodCflowbelowGetSet(StaticJoinPoint sjp) {
180: //System.out.println(".methodCflowbelowGetSet");
181: EnclosingSJPTest.registerEnclosingSJP(sjp
182: .getEnclosingStaticJoinPoint());
183: }
184:
185: }
|