This content has been marked as final.
Show 2 replies
-
1. Re: How to get the PER_VM instance?
hjames Jan 4, 2005 11:55 AM (in response to hjames)"Hjames" wrote:
Hello,
I wonder if there are any API methods to get the aspect instances like the "aspectOf()" method of AspectJ?
In particular, I'd like to get the PER_VM instance of a specific aspect class (which implements the Interceptor interface.)
Thanks. -
2. Re: How to get the PER_VM instance?
kabirkhan Jan 4, 2005 12:19 PM (in response to hjames)Yep,
To get the PER_VM instance, you would do:MyAspect myAspect = (MyAspect) AspectManager.instance().getPerVMAspect("org.blah.MyAspect");
Note that all instrumented classes implement the org.jboss.aop.Advised interface. So for other scopes you would cast an instance to Advised.
Advised has the following two methods:InstanceAdvisor _getInstanceAdvisor(); Advisor _getAdvisor();
Advisor allows you to get PER_CLASS scoped aspect instances via the getPerClassAspect() method. (It takes the aspect class name as its parameter)
InstanceAdvisor allows you to get PER_INSTANCE scoped aspect instances via the getPerInstanceAspect() method. (It takes the aspect class name as its parameter)
Kabir