-
Jan 31st, 2013, 10:27 AM
#1
AspectJ Question
I have a question on spring aspectj lTW integration.
If an app has two application contexts (one loaded by the context listener and one for the dispatcher servlet) , if I specify <context:load-time-weaver> tag in the main context file , will it do load time weaving for the beans loaded by the context file that is passed to the dispatcher servlet.
Looks like that since even though I dont specify this tag in the web context file , my controllers are getting weaved at load time . Any comments?
-
Jan 31st, 2013, 02:26 PM
#2
Loadtimeweaving works by chancing the classloader (registering classfiletransformers on it) and as the same classloader is used the advices apply to both contexts. This in contrast to the default spring spring aop mechanism.
-
Feb 1st, 2013, 12:06 AM
#3
AspectJ Question
Thanks Marten .
How does LTW work in the context of multiple class loaders.
Having a look at the load time weaver class (say WebSphereLoadTimeWeaver ) and also AspectJWeavingEnabler it looks like the transformation is done only to the default class loader which is the web class loader. But what if I have an application which has 2 class loaders one for the app and its dependent libraries and one for the web module.
-
Feb 1st, 2013, 02:32 AM
#4
It only changes the current classloader, so only classes loaded by same classloader will be modified. Unless you enable LTW for the whole/server or app.
-
Feb 1st, 2013, 03:53 AM
#5
Thanks Marten . I understand that only classes loaded by same class loader will be modified.
But what if my app itself runs in 2 class loaders. Even though I switch on spring ltw, it seems to only transform the class loader of the thread in which the spring context is running. Not the other class loader.
If my app runs in 2 class loaders , is it possible to tell spring to transform both the class loaders and not just that of the current thread?
-
Feb 1st, 2013, 04:12 AM
#6
No... It is either a single classloader (the one spring is using) or everything by using the agent on your classpath and modify the server startup.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules