[jboss-user] [JBoss AOP] - Re: Question regarding Dynamic AOP

flavia.rainone@jboss.com do-not-reply at jboss.com
Tue May 13 16:59:22 EDT 2008


Unfortunately we don't provide this functionality yet. It is planned to be included in JBoss AOP in a future version.

Currently, what you could do is to add an aspect to an AOP Domain. This domain (org.jboss.aop.Domain), extends the AspectManager class, and also provides the functionality of binding addition and removal. But, differently from the AspectManager singleton instance, those operations will take effect only inside a scope, defined by the Domain.

The limitation of this feature is that there is no Domain with a per-thread scope. There is, however, a domain per instance. So, all aspects applied to it will affect only the single instance managed by that domain. There is also a domain per class. Aspects added to this domain will affect only instances of that class. Finally, there is a domain per deployment scope (available only in the AS).

I am not sure if the domains would be useful for you. Another possibility is to implement a DynamicCFlow for each client profile:


  | public class Client1CFlow implements DynamicCFlow
  | {
  |    public boolean shouldExecute(Invocation invocation)
  |    {
  |        // check if client credentials follow a specific profile
  |       if (...) { return true;}
  |       return false;
  |     }
  | }
  | ------
  | <aop>
  | 
  | <dynamic-cflow name="Client1" class="Client1CFlow>
  | 
  | <binding pointcut="execution(* MyService->serveClient(..))" cflow="Client1">
  | <!-- insert interceptors and advices to be applied to client1 profile here -->
  | </binding>
  | 
  | </aop>
  | 

Notice that, if your class implements org.jboss.util.xml.XmlLoadable:


  | public interface XmlLoadable
  | {
  |    public void importXml(org.w3c.dom.Element xmlElement);
  | }
  | 

You can insert whatever xml elements you want inside your dynamic-cflow declaration, and then you can proccess those elements inside your DynamicCFlow, for extra configuration.

Examples of dynamic cflow are available here:
http://www.jboss.org/jbossaop/docs/1.5.0.GA/docs/aspect-framework/examples/dynamic_cflow/cflow.html
http://www.jboss.org/jbossaop/docs/1.5.0.GA/docs/aspect-framework/examples/annotated-dynamic-cflow/annotated-dynamic-cflow.html

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

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



More information about the jboss-user mailing list