KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > annotation > Target


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 examples.annotation;
9
10 import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
11
12 /**
13  * @author <a HREF="mailto:alex@gnilux.com">Alexandre Vasseur</a>
14  */

15 public class Target {
16
17     public static void main(String JavaDoc args[]) throws Throwable JavaDoc {
18         System.out.println("examples.annotation.Target.main");
19         Target me = new Target();
20         me.targetAB();
21         me.targetA();
22         me.target();
23     }
24
25     /**
26      * @examples.annotation.AnnotationA(some)
27      * @examples.annotation.AnnotationB
28      */

29     public void targetAB() {
30         System.out.println("Target.target AB ");
31     }
32
33     /**
34      * @examples.annotation.AnnotationA
35      */

36     public void targetA() {
37         System.out.println("Target.target A");
38     }
39
40     public void target() {
41         System.out.println("Target.target");
42     }
43
44     public static class AnnotationMatchAspect {
45
46         /**
47          * @param jp
48          * @Before execution(@examples.annotation.AnnotationA * examples.annotation.Target.*(..))
49          */

50         public void beforeA(JoinPoint jp) {
51             System.out.println("Target$AnnotationMatchAspect.beforeA : " + jp.toString() );
52
53         }
54
55         /**
56          * @param jp
57          * @Before execution(@examples.annotation.AnnotationB * examples.annotation.Target.*(..))
58          */

59         public void beforeB(JoinPoint jp) {
60             System.out.println("Target$AnnotationMatchAspect.beforeB");
61
62
63         }
64     }
65
66 }
67
Popular Tags