[jboss-dev-forums] [Design of AOP on JBoss (Aspects/JBoss)] - Re: Reimplementing AspectManager/Domains to understand jboss
kabir.khan@jboss.com
do-not-reply at jboss.com
Mon Mar 23 11:59:20 EDT 2009
The problem I am trying to solve is not really to do with the classes being woven, rather with being able to load up bound aspects when invoking the woven class. If the aspects are part of the the target deployment it is not an issue. There will be a problem if the aspects are in other deployments and the aspect classes are not found by the target deployment's classloader.
For example if I have a deployment A.jar using importAll=false containing
| package pkga;
|
| @Marker
| public class ClassA{
| public void method(){}
| }
|
| |
| | In same the classloading domain I have a B.aop archive containing pkgb.InterceptorB.class:
| |
| | | <aop>
| | | <interceptor class="pkgb.InterceptorB"/>
| | | <bind pointcut="execution(* @Marker->*(..))">
| | | <interceptor-ref name="pkgb.InterceptorB"/>
| | | </aspect>
| | | </aop>
| | |
| | and a C.aop archive containing pkgc.InterceptorC.class:
| |
| | | <aop>
| | | <interceptor class="pkgc.InterceptorC"/>
| | | <bind pointcut="execution(* @Marker->*(..))">
| | | <interceptor-ref name="pkgc.InterceptorC"/>
| | | </aspect>
| | | </aop>
| | |
| |
| | When the class is loaded/woven we don't care about what is bound, so we can weave the class no problem.
| |
| | When we come to invoking pkga.ClassA.method(), we need to populate the interceptor chains. Since A.jar's loader is not set up to see pkgb.InterceptorB or pkgc.InterceptorC we can't invoke those interceptors. Currently AOP will throw an error, the purpose of this thread is to figure out a better way to handle this.
| |
| | "adrian at jboss.org" wrote :
| | | e.g. In your final comment where you want a "global" aspect definition then
| | | the deployments that want to use it would need to "import" the classloader
| | | where those aspects are deployed.
| |
| | I think you are saying just ignore InterceptorB and InterceptorC unless A.jar is set up to import the packages/modules of the interceptors? I think that will be pretty simple to do.
| |
| | My suggestion regarding global visibility is to make the classes from the loaders for B.aop and C.aop magically visible from A.jar somehow. But that means we don't get versioning of modules packages, so maybe an explicit import is the best thing. At the same time, I don't know if whoever writes A.jar should need to know that InterceptorB or InterceptorB might be applied later?
| |
| | When generating the invocation class for pkga.ClassA.method() we create something like:
| |
| | | public class ClassA_method extends MethodInvocation
| | | {
| | | ClassA target;
| | |
| | | public ClassA_method(POJO target)
| | | {
| | | this.target = target;
| | | }
| | |
| | | public void dispatchJoinPoint()
| | | {
| | | target.method();
| | | }
| | | }
| | |
| | | public class ClassA_method_1 extends ClassA_method
| | | {
| | | pkgb.InterceptorB aspect1;
| | | pkgc.InterceptorC aspect2;
| | |
| | | int current;
| | | public Object invokeNext() throws Throwable
| | | {
| | | try
| | | {
| | | switch (current++)
| | | {
| | | case 0:
| | | return aspect1.invoke(this);
| | | break;
| | | case 1:
| | | return aspect2.invoke(this);
| | | break;
| | | default:
| | | dispatchJoinPoint();
| | | return null;
| | | }
| | | }
| | | finally
| | | {
| | | current--;
| | | }
| | | }
| | | }
| | |
| | If go with ignoring the aspects that cannot be found we would need to generate this instead:
| |
| | | public class ClassA_method_1 extends ClassA_method
| | | {
| | | int current;
| | | public Object invokeNext() throws Throwable
| | | {
| | | switch (current++)
| | | {
| | | case 0:
| | | return aspect1.invoke(this);
| | | break;
| | | case 1:
| | | return aspect2.invoke(this);
| | | break;
| | | default:
| | | dispatchJoinPoint();
| | | return null;
| | | }
| | | }
| | | }
| | |
| |
| |
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4220313#4220313
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4220313
More information about the jboss-dev-forums
mailing list