Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] LTW javax package & dyanmic class loading

There are two options, weaveJavaPackages and weaveJavaxPackages - you
may need to set both.  However, unless the weaver gets in early enough
to attach a weaver to the classloader that loads the types that need
weaving, it wont weave them.  I defer to others for a working example,
I just thought I'd mention that.


On 27/03/2008, Mark Stobbe <markstobbe@xxxxxxxxx> wrote:
> Hello all,
> I have two questions, both pretty advanced I would think.
> My first question relates to weaving of Java core packages. I have searched
> the internet for *working* examples, but I don't seem to be able to find
> any. Could someone please supply me a working example of weaving a java
> class. For example, the following aspect should go around any setVisible
> call, ie:
> import java.awt.*;
> import javax.swing.*;
> public aspect MyAspect
>   void around(Window window): target(window) && call(void
> Window.setVisible(boolean))
>   {
>     System.out.println("Window.setVisible(..)");
>   }
> }
> ---
> With aop.xml:
> ---
> <aspectj>
>  <weaver options="-Xset:weaveJavaPackages=true">
>   <include within="*"/>
>   <include within="java..*"/>
>   <include within="javax..*"/>
>  </weaver>
>  <aspects>
>    <aspect name="MyAspect"/>
>  </aspects>
> </aspectj>
> However, it doesn't work. Can someone make this work?
> =====
> The other question relates to a custom classloader. Again, searching the
> internet gave me useful insight, but not precisely what I was looking for,
> neither are there many examples. What I would like todo is associate certain
> aspects with certain classes -- at runtime. Formulated as a solution:
> A custom weave classloader which loads the target class and weaves my
> defined aspects.
> I haven't made much progress with this problem. Mostly because the Javadocs
> are useless. The best I got was creating a new WeavingURLClassLoader, but I
> couldn't get it to work with my arguments.. I must be doing something wrong
> in the formatting. Thereby, I would rather have to give it a path to an
> aop.xml, as to be able to declare aspects in a separate file.
> I hope I gave enough details for both questions.. hopefully someone can help
> me.
> Mark
> _______________________________________________
>  aspectj-users mailing list
>  aspectj-users@xxxxxxxxxxx

Back to the top