[jboss-user] [JBoss AOP] - Re: How to avoid intercepting recursive calls

kabir.khan@jboss.com do-not-reply at jboss.com
Mon Jun 11 06:12:08 EDT 2007


1) Incorrect


  | <aop>
  |    <cflow-stack name="NotRecursivePOJO">
  |       <not-called expr="* POJO->prepare(..)"/>
  |    </cflow-stack>
  | 
  |    <bind pointcut="execution(public * POJO->prepare(..))" cflow="NotRecursivePOJO">
  |       <interceptor class="Blah"/>
  |    </bind>
  | </aop>
  | 	

Will allow the method to be called. The not-called part makes sure it has not been called *previously*. Take a look at the "cflow" tutorial that comes with the dist.

2) I updated our tests and you can use wildcards so the following is valid

  | <aop>
  |    <cflow-stack name="NotRecursivePOJO">
  |       <not-called expr="* org.blah.POJO->*(..)"/>
  |    </cflow-stack>
  | 
  |    <bind pointcut="execution(public * org.blah.POJO->*(..))" cflow="NotRecursivePOJO">
  |       <interceptor class="Blah"/>
  |    </bind>
  | </aop>
  | 

You can also do more advanced things with the classname such as

  | <aop>
  |    <cflow-stack name="NotRecursivePOJO">
  |       <not-called expr="* @org.blah.SomeAnnotation->*(..)"/>
  |       <not-called expr="* $instanceof(org.blah.Base}->get*(..)"/>
  |       <not-called expr="* $typedef(someDef}->*(..)"/>
  |       <not-called expr="* org.blah.Value*->*(..)"/>
  |    </cflow-stack>
  | 

Note that the access specifiers, return type and parameters are not used during the matching stage since this info is not avialble in StackTraceElement, all we have are the class and the method name.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StackTraceElement.html

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

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



More information about the jboss-user mailing list