Announcement Announcement Module
Collapse
No announcement yet.
AspectJ Question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

  • #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.

    Comment


    • #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.

      Comment


      • #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.

        Comment


        • #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?

          Comment


          • #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.

            Comment


            • #7
              Aspectj Question

              Have not tried this , but would this work

              In my app context 1 which is the root context have a line
              <context:load-time-weaver weaver-class="example.LoadTimeWeaver1">

              and in my other app context which is the web context

              <context:load-time-weaver weaver-class="example.LoadTimeWeaver2">

              where LoadTimeWeaver1 and LoadTimeWeaver 2 are classes extending the custom load time weaver (Websphereloadtimeweaver) and which are created by passing in the required class loader.

              Then would this work and would this have transformed the passed in class loaders?

              Comment

              Working...
              X