This content has been marked as final. Show 2 replies
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.)
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)