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