Hi!
Yes, you can add an interceptor at runtime through dynamic AOP.
For that, the classes you want to affect dynamically must be prepared through
"prepare" expressions, like this:
<prepare expr="all(org.mypackage.Pojo)"/>
| <prepare expr="execution(* org.mypackage.Pojo2->method()))/>
|
This must be done inside a jboss-aop.xml file. Alternativaly, you can annotate classes and
methods you want to prepare with @Prepare.
After that, you can either use aopc or loadtime weaving to transform your classes. This
will basically prepare all joinpoints matched by the prepare expressions so that, at
runtime, you can add an interceptor to them, and remove interceptors as well.
Now, to add this interceptor at runtime, you must perform a call to
AspectManager.addBinding() method. To take a better look at how this is done, you can look
for calls to this method that are made inside org.jboss.aop.AspectXMLLoader class.
I am planning to write a tutorial on this at our blog in a few weeks
(
http://jbossaop.blogspot.com/). There are also plans for writing a more user-friendly
interface to add interceptors and aspects at runtime. So, stay tuned!
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147313#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...