Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Important aspects of JDK 1.4 weaving


Bo,

How are you invoking your application to use LTW? According to the AspectJ Development Environment Guide http://www.eclipse.org/aspectj/doc/released/devguide/ltw-configuration.html your aop.xml should be in a "META-INF" directory, typically used for configuration information when packaging your application as a JAR. Then you can us "aj" (instead of "java") to run your application:

C:\temp\bo.zimmerman>c:\aspectj1.5\bin\aj HelloWorld
info AspectJ Weaver Version 1.5.0 built on Tuesday Dec 20, 2005 at 12:05:54 GMT
info register classloader org.aspectj.weaver.loadtime.WeavingURLClassLoader
info using /C:/temp/bo.zimmerman/META-INF/aop.xml
info register aspect HelloAspect
info weaving 'HelloWorld'
info weaving 'HelloAspect'
info processing reweavable type HelloAspect: C:\temp\bo.zimmerman\HelloAspect.java
Before Hello World.
Hello World.

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/

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:        aspectj-users-bounces@xxxxxxxxxxx

To:        aspectj-users@xxxxxxxxxxx
cc:        
Subject:        [aspectj-users] Important aspects of JDK 1.4 weaving


Using JDK1.4 to compile and test aspects using the WeavingURLClassLoader method.
 
When the classes below are compiled together (ajc.bat *.java) and HelloWorld is executed, it works Great! When they are compiled separately (ajc.bat HelloWorld.java, ajc.bat HelloAspect.java) and then HelloWorld is executed, weaving does not occur.  Everything is being done from the same directory, with "." in the classpath, to keep things simple.
 
Any help would be very appreciated.
 
- Bo
 
Here it is! My simple and frustrating example:
 
HelloWorld.java:
import java.io.*;
public class HelloWorld
{
   public void greet(String msg)
   {
      System.out.println(msg);
   }
   public static void main(String args[])
   {
      new HelloWorld().greet("Hello World.");
   }
}
 
HelloAspect.java:
import java.io.*;
public aspect HelloAspect
{
   pointcut GreetCuts(String msg) : call(void *.greet*(String, ..)) && args(msg, ..);
 
   before(String msg) : GreetCuts(msg)
   {
      System.out.println("Before "+msg);
   }
}
 
Aop.xml:
<aspectj>
   <aspects>
      <aspect name="HelloAspect"/>
   </aspects>
   <weaver options="-verbose -XlazyTjp -Xlint:ignore">
      <include within="*" />
   </weaver>
</aspectj>
 _______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top