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.hierarchicalpattern;
9
10 import test.Loggable;
11 import org.codehaus.aspectwerkz.Pointcut;
12 import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
13
14 /***
15 * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a>
16 * @Aspect
17 */
18 public class TestAspect {
19 /***
20 * @Expression execution(* test.hierarchicalpattern.DummyInterface1+.declaringType1(..))
21 */
22 Pointcut pc1;
23
24 /***
25 * @Expression execution(* test.hierarchicalpattern.DummyInterface2+.declaringType2(..))
26 */
27 Pointcut pc2;
28
29 /***
30 * @Expression execution(test.hierarchicalpattern.DummyInterface2+
31 * test.hierarchicalpattern.HierachicalPatternTest.returnType*(..))
32 */
33 Pointcut pc3;
34
35 /***
36 * @Expression execution(*
37 * test.hierarchicalpattern.HierachicalPatternTest.parameterTypes(test.hierarchicalpattern.DummyInterface1+,
38 * test.hierarchicalpattern.DummyInterface2+))
39 */
40 Pointcut pc4;
41
42 /***
43 * @Around pc1 || pc2 || pc3 || pc4
44 */
45 public Object advice(final JoinPoint joinPoint) throws Throwable {
46 ((Loggable) joinPoint.getTarget()).log("before1 ");
47 final Object result = joinPoint.proceed();
48 ((Loggable) joinPoint.getTarget()).log("after1 ");
49 return result;
50 }
51 }