[Design of AOP on JBoss (Aspects/JBoss)] - Re: Reimplementing AspectManager/Domains to understand jboss
by adrian@jboss.org
"kabir.khan(a)jboss.com" wrote :
| "adrian(a)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.
|
It depends what you are talking about. If the aspect definition is in A.jar
but the class is invisible then I think it should be an error.
I don't see why aspects shouldn't follow the same rules as normal class imports?
The fact that AOP is weaving the class reference into bytecode
(either literally or dynamically via interceptors) shouldn't make any difference.
anonymous wrote :
| 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?
|
Magically adding a random version of the class is clearly not in sympathy with
the modularization rules of OSGi style classloading.
The issue that I said was upto you is whether InterceptorB defined in B.aop really applies
to A.jar when everything else from B.aop is not visible to it.
I'd say the rule should be that the aop config only applies when A.jar chooses
to import the relevant aspect classes defined in B.aop.
The part I said you might ignore would be where B.aop contains aspect
configuration for other classes that A.jar chooses NOT to import or just isn't relevant.
I don't know whether that helps you resolve the problem, but you certainly shouldn't
be trying to break the class visbility rules in any way. That could be a potential
security hole if nothing else. :-)
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4220320#4220320
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4220320
17 years
[Design of AOP on JBoss (Aspects/JBoss)] - Re: Reimplementing AspectManager/Domains to understand jboss
by kabir.khan@jboss.com
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(a)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
17 years