Yupiii! 

And once more, I reply to my own post :)

So here is the solution with new TYPE_DEF feature:

jboss-aop.xml:
<aop>
  | <typedef name="rootable" expr="class(@root)" />
  | 
  | <bind pointcut="all($typedef{rootable})">
  |     <interceptor class="RootInterceptor"/>
  | </bind>
  | 
  | <!-- If you annotated class with "@@root" you don't need this
  | <annotation tag="root" class="MyRoot">
  |     <class/>
  | </annotation>
  | -->
  | </aop>
  | 

Interceptor:
public class RootInterceptor
  |        implements Interceptor
  | {   
  |     public Object invoke(Invocation invocation) throws Throwable
  |     {
  |         if (invocation instanceof ConstructorInvocation)
  |         {
  |             ...put logic here for Constructor joinpoints..
  |          }
  |           ....
  |     }   
  | } 
  | 

and core code:
/** @@root */
  | public class MyRoot
  | {
  |     public void method1(){}
  |     public static void main(String[] args)
  |     {
  |         System.out.println("------START");
  |         MyRoot root = new MyRoot();
  |         root.method1();
  |         System.out.println("------END");
  |     }
  | }   
  | 

There is only default constructor here. But the logic from
RootInterceptor will be applied. That's great.

Output:
     [java] ------START
  |      [java] ==O==[main] RootInterceptor: 23: [EMAIL PROTECTED]
  |      [java] ==O==[main] RootInterceptor: 25: I'm in ConstructorInterceptor
  |      [java] ==O==[main] RootInterceptor: 23: MyRoot_method1_N4778546224999628736_
  | [EMAIL PROTECTED] 
  |      [java] ------END
  | 

--Tomasz



View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3848988#3848988

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3848988


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to