Run it with all the flags set for debug and trace:
-Daj.weaving.verbose=true -Dorg.aspectj.weaver.showWeaveInfo=true
-Dorg.aspectj.tracing.messages=true -Dorg.aspectj.tracing.enabled=true
-Dorg.aspectj.tracing.factory=default
You will see trace but also 'I' entries which are info messages from the
weaver. The setup would be that you need the aspects on the aspectpath and
and on the classpath, there is no aop.xml required as you are directly
telling the weaver what the aspects are through the constructor. I just
tried it and it worked for me:
public class Sample {
public static void main(String[] args) throws Exception {
URL[] cpath = getClasspath("foo.jar", "aspects.jar");
URL[] apath = getClasspath("aspects.jar");
WeavingURLClassLoader wucl = new WeavingURLClassLoader(cpath, apath,
Thread.currentThread().getContextClassLoader());
Class foo = wucl.loadClass("Foo");
Method m = foo.getMethod("m", null);
m.invoke(foo.newInstance(), null);
}
public static URL[] getClasspath(String... files) throws Exception {
URL[] urls = new URL[files.length];
int pos = 0;
for (String file : files) {
urls[pos++] = new File(file).toURL();
}
return urls;
}
}
In the verbose output from tracing I see:
12:09:05.578 main I [WeavingAdaptor] info AspectJ Weaver Version DEVELOPMENT
built on Tuesday Oct 21, 2008 at 18:57:36 GMT
12:09:05.812 main I [WeavingAdaptor] info adding aspect library:
'C:\asc\ws\aspectj16_2\A\aspects.jar'
12:09:06.312 main ? [WeavingAdaptor] weaveinfo Join point
'staticinitialization(void Foo.<clinit>())' in Type 'Foo' (Foo.java) advised
by before advice from 'X' (aspects.jar!X.class:2(from X.java))
And my advice runs.
Andy.
2008/10/22 kfinkels <[EMAIL PROTECTED]>
>
> Hi,
> I'm trying to LTW an applet - using a wrapper applet.
> I have the jar - including the source applet, a jar including the aspects
> and an applet that initialize the WeavingURLClassLoader and load the
> source-applet.
> in the html applet tag - I set the aspectjrt & aspectjweaver jars as
> archive.
> all jars are signed.
> The problem is that the source is not weaving and works like there are no
> aspects to run.
> I get the source applet visible and no error at all!!!!
>
> the aop.xml file is in the wrapper jar - is that correct? - what am I doing
> wrong?
> pls help - I'm desperate.
>
> here is the code of the wrapper applet:
>
> import java.awt.Component;
> import java.io.File;
> import java.lang.reflect.InvocationTargetException;
> import java.lang.reflect.Method;
> import java.net.MalformedURLException;
> import java.net.URL;
> import java.net.URLClassLoader;
> import java.util.jar.JarFile;
>
> import javax.swing.JApplet;
>
> import org.aspectj.weaver.loadtime.WeavingURLClassLoader;
>
> public class SmApplet extends JApplet {
> public void init() {
>
> try {
>
> File source = new
> File("C:/workspace/HackClassLoader/target/AOP-1.0.jar");
> File aspect = new
> File("C:/workspace/HackClassLoader/target/demoAOP-1.0.jar");
> URL[] urlList = {source.toURL(), aspect.toURL()};
> URL[] aspectUrlList = {};
>
> WeavingURLClassLoader weavingClassLoader = new
> WeavingURLClassLoader(urlList, aspectUrlList,
> Thread.currentThread().getContextClassLoader());
>
> Class mainApplet =
> weavingClassLoader.loadClass("demoAOP.HelloMainApplet");
> Object applet = mainApplet.newInstance();
>
> if (mainApplet != null) {
>
> Class[] args = null;
> Method init = mainApplet.getMethod("init",
> args);
> init.invoke(applet, (Object[])null);
> this.add((Component)applet);
> }
>
> } catch (MalformedURLException me){
> System.out.println("MalformedURLException");
> me.printStackTrace();
> } catch (ClassNotFoundException cx){
> System.out.println("ClassNotFoundException");
> cx.printStackTrace();
> } catch (NoSuchMethodException nx){
> System.out.println("NoSuchMethodException");
> nx.printStackTrace();
> } catch (InvocationTargetException ix){
> System.out.println("InvocationTargetException");
> ix.printStackTrace();
> } catch (IllegalAccessException ax){
> System.out.println("IllegalAccessException");
> ax.printStackTrace();
> } catch (InstantiationException ee) {
> System.out.println("InstantiationException");
> ee.printStackTrace();
> }
>
> }
>
> }
>
> --
> View this message in context:
> http://www.nabble.com/LTW-of-an-applet-tp20109437p20109437.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users