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.afterxxx;
008:
009: import org.codehaus.aspectwerkz.joinpoint.StaticJoinPoint;
010: import org.codehaus.aspectwerkz.definition.Pointcut;
011:
012: /**
013: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
014: */
015: public class Aspect {
016:
017: /**
018: * @Expression execution(* test.afterxxx.Test.all(..))
019: */
020: Pointcut all;
021:
022: /**
023: * @Expression execution(* test.afterxxx.Test.aroundFinally(..))
024: */
025: Pointcut aroundFinally;
026:
027: /**
028: * @Expression execution(* test.afterxxx.Test.aroundReturning(..))
029: */
030: Pointcut aroundReturning;
031:
032: /**
033: * @Expression execution(* test.afterxxx.Test.aroundFinallyReturning(..))
034: */
035: Pointcut aroundFinallyReturning;
036:
037: /**
038: * @Expression execution(* test.afterxxx.Test.aroundFinallyReturningThrowing(..))
039: */
040: Pointcut aroundFinallyReturningThrowing;
041:
042: /**
043: * @Expression execution(* test.afterxxx.Test.aroundReturningThrowing(..))
044: */
045: Pointcut aroundReturningThrowing;
046:
047: /**
048: * @Expression execution(* test.afterxxx.Test._finally(..))
049: */
050: Pointcut _finally;
051:
052: /**
053: * @Expression execution(* test.afterxxx.Test.finallyReturning(..))
054: */
055: Pointcut finallyReturning;
056:
057: /**
058: * @Expression execution(* test.afterxxx.Test.finallyReturningThrowing(..))
059: */
060: Pointcut finallyReturningThrowing;
061:
062: /**
063: * @Expression execution(* test.afterxxx.Test.returning(..))
064: */
065: Pointcut returning;
066:
067: /**
068: * @Expression execution(* test.afterxxx.Test.returningThrowing(..))
069: */
070: Pointcut returningThrowing;
071:
072: /**
073: * @Around all || aroundFinally || aroundFinallyReturning ||
074: * aroundFinallyReturningThrowing || aroundReturningThrowing || aroundReturning
075: */
076: public Object logAround(StaticJoinPoint joinPoint) throws Throwable {
077: Test.log("logAround ");
078: final Object result = joinPoint.proceed();
079: return result;
080: }
081:
082: /**
083: * @AfterReturning aroundFinallyReturning || aroundFinallyReturningThrowing ||
084: * aroundReturningThrowing || finallyReturning || finallyReturningThrowing ||
085: * returningThrowing || aroundReturning || returning
086: */
087: public void logAfterReturning(final StaticJoinPoint joinPoint)
088: throws Throwable {
089: Test.log("logAfterReturning ");
090: }
091:
092: /**
093: * @AfterReturning(type="java.lang.String", pointcut="aroundFinallyReturning || aroundFinallyReturningThrowing ||
094: * aroundReturningThrowing || finallyReturning || finallyReturningThrowing ||
095: * returningThrowing || aroundReturning || returning")
096: */
097: public void logAfterReturningString(final StaticJoinPoint joinPoint)
098: throws Throwable {
099: Test.log("logAfterReturningString ");
100: }
101:
102: /**
103: * @AfterThrowing(type="java.lang.RuntimeException", pointcut="aroundFinallyReturningThrowing ||
104: * aroundReturningThrowing ||
105: * finallyReturningThrowing || returningThrowing")
106: */
107: public void logAfterThrowingRTE(final StaticJoinPoint joinPoint)
108: throws Throwable {
109: Test.log("logAfterThrowingRTE ");
110: }
111:
112: /**
113: * @AfterThrowing(type="java.lang.IllegalArgumentException", pointcut="
114: * aroundFinallyReturningThrowing || aroundReturningThrowing ||
115: * finallyReturningThrowing || returningThrowing")
116: */
117: public void logAfterThrowing(final StaticJoinPoint joinPoint)
118: throws Throwable {
119: Test.log("logAfterThrowing ");
120: }
121:
122: /**
123: * @AfterFinally aroundFinally || aroundFinallyReturning || aroundFinallyReturningThrowing ||
124: * _finally || finallyReturning || finallyReturningThrowing
125: */
126: public void logAfterFinally(final StaticJoinPoint joinPoint)
127: throws Throwable {
128: Test.log("logAfterFinally ");
129: }
130:
131: /**
132: * @After finallyReturning
133: */
134: public void logAfter(final StaticJoinPoint joinPoint)
135: throws Throwable {
136: Test.log("logAfter ");
137: }
138:
139: /**
140: * @AfterReturning(type="i", pointcut="execution(* test.afterxxx.TestBinding.returnInt(..))")
141: */
142: public void logAfterBinding(int i) {
143: TestBinding.log("afterReturningInt " + i);
144: }
145:
146: /**
147: * @AfterReturning(type="s", pointcut="execution(* test.afterxxx.TestBinding.returnString(..))")
148: */
149: public void logAfterBinding(String s) {
150: TestBinding.log("afterReturningString " + s);
151: }
152:
153: /**
154: * @AfterThrowing(type="e", pointcut="execution(* test.afterxxx.TestBinding.throwChecked(..))")
155: */
156: public void logAfterBindingExact(ClassNotFoundException e) {
157: TestBinding.log("afterThrowingExact " + e.getClass().getName());
158: }
159:
160: /**
161: * @AfterThrowing(type="e", pointcut="execution(* test.afterxxx.TestBinding.throwChecked(..))")
162: */
163: public void logAfterBindingParentClass(Exception e) {
164: TestBinding.log(" afterThrowingParentClass "
165: + e.getClass().getName());
166: }
167: }
|