[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] lauching applications from another one with load-time weaving


Fabio,

Dynamic class loading is tricky. If you combine that with LTW then things get tricker so I suggest you keep it as simple as possible. May I ask what you are trying to do? There may already be some tools that do it for you. Most importantly if you write an aspect that targets a particular class, you generate an aop.xml file for it (using -outxml), start the JVM with the AspectJ LTW agent and load the class as you have described below then it will be woven.

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/



"Fabio Fagundes Silveira" <ffs@xxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx

26/10/2006 21:48

Please respond to
aspectj-users@xxxxxxxxxxx

To
aspectj-users@xxxxxxxxxxx
cc
Subject
Re: [aspectj-users] lauching applications from another one        with        load-time weaving





Hi Matthew,

   Ok ... but how to get this working?  I just can get this working if I type: java -javaagent:xxx Test ... Therefore, I dont know how to load the other application (e.g. from App1.main) using a separate class loader ... :-(

  Would you please send me some hints (piece of code)?


Thank you,
Fabio

On Thu, 26 Oct 2006 16:07:14 +0100, Matthew Webster wrote

>
Fabio,
>
>
If you are using Java 5 then just use the -javaagent that comes with AspectJ: http://www.eclipse.org/aspectj/doc/released/devguide/ltw-agents.html. You may want to load you test application using a separate class loader, with it's own classpath. As each class is loaded it will automatically get passes to AspectJ.
>
>
Matthew Webster
> AOSD Project
> Java Technology Centre, MP146
> IBM Hursley Park, Winchester,  SO21 2JN, England
> Telephone: +44 196 2816139 (external) 246139 (internal)
> Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
> http://w3.hursley.ibm.com/~websterm/

>
>

>
To
aspectj-users@xxxxxxxxxxx

>
cc

>
Subject
[aspectj-users] lauching applications from another one with        load-time weaving


>



>


>
>
Hello,
>
>   To launch an application from another java program is possible using
> reflection, such as:
>
> Class cls = Class.forName("Test");
> String s[] = new String[] {};
> Object arguments[] = new Object[] { s };
> Method mainMethod = cls.getMethod("main", new Class[] {s.getClass()});
> Object result = mainMethod.invoke(null, arguments);
>
>  Ok, but how to do that (ie. launching "Test" application) using
> load-time weaving? I meant, lauching Test and aspects defined to be
> applied to this class in a META-INF/aop.xml file?
>
>  I've tried to find out any WeavingAdaptor tutorial or something like
> that ... but I didn't  ... :-(
>
>  Could you help me?  :-)
>
> Regards,
> Fabio

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users