KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > introduction > IntroductionAspect


1 package examples.introduction;
2
3 import org.codehaus.aspectwerkz.AspectContext;
4
5 import java.io.Serializable JavaDoc;
6
7 /**
8  * @Aspect perClass
9  */

10 public class IntroductionAspect extends AbstractIntroductionAspect {
11
12     /**
13      * @Introduce within(examples.introduction.Target)
14      */

15     public Serializable JavaDoc serializable;
16
17     /**
18      * @Mixin(pointcut="within(@Annotation *..*)", deploymentModel="perInstance")
19      */

20     public static class MyConcreteImpl extends MyImpl {
21
22         /**
23          * The instance we are introduced to since we are perInstance
24          */

25         private final Object JavaDoc m_target;
26
27         /**
28          * @param target
29          */

30         public MyConcreteImpl(final Object JavaDoc target) {
31             m_target = target;
32             System.out.println("--Accessing mixin target instance from the mixin <init>...");
33             System.out.println("-- I am introduced to " + target);
34             sayHello2();
35             System.out.println("--..<init> done");
36         }
37
38         public String JavaDoc sayHello2() {
39             return "Hello World! Hello World!";
40         }
41     }
42 }
Popular Tags