01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package test.callAndExecution;
08:
09: import org.codehaus.aspectwerkz.definition.Pointcut;
10: import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
11:
12: /**
13: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
14: */
15: public class TestAspect {
16: // ============ Pointcuts ============
17:
18: /**
19: * @Expression call(void test.callAndExecution.CallExecutionTest.privateMethod()) &&
20: * within(test.callAndExecution.*)
21: */
22: Pointcut call1;
23:
24: /**
25: * @Expression call(void test.callAndExecution.CallExecutionTest.publicMethod()) &&
26: * within(test.callAndExecution.*)
27: */
28: Pointcut call2;
29:
30: /**
31: * @Expression call(void test.callAndExecution.Intf+.called()) &&
32: * within(test.callAndExecution.*)
33: */
34: Pointcut callIntf;
35:
36: /**
37: * @Expression call(void test.callAndExecution.Abstract+.called()) &&
38: * within(test.callAndExecution.*)
39: */
40: Pointcut callAbstract;
41:
42: /**
43: * @Expression execution(void test.callAndExecution.CallExecutionTest.privateMethod())
44: */
45: Pointcut execution1;
46:
47: /**
48: * @Expression execution(void test.callAndExecution.CallExecutionTest.publicMethod())
49: */
50: Pointcut execution2;
51:
52: /**
53: * @Expression execution(void test.callAndExecution.Intf+.called())
54: */
55: Pointcut executionIntf;
56:
57: /**
58: * @Expression execution(void test.callAndExecution.Abstract+.called())
59: */
60: Pointcut executionAbstract;
61:
62: // ============ Advices ============
63:
64: /**
65: * @Around call1 || call2 || callIntf || callAbstract
66: */
67: public Object advice1(final JoinPoint joinPoint) throws Throwable {
68: CallExecutionTest.log("call1 ");
69: Object result = joinPoint.proceed();
70: CallExecutionTest.log("call2 ");
71: return result;
72: }
73:
74: /**
75: * @Around execution1 || execution2 || executionIntf || executionAbstract
76: */
77: public Object advice2(final JoinPoint joinPoint) throws Throwable {
78: CallExecutionTest.log("execution1 ");
79: Object result = joinPoint.proceed();
80: CallExecutionTest.log("execution2 ");
81: return result;
82: }
83: }
|