Annotated examples
This example uses JDK 5 annotations. To execute the ant file that comes with the example
you need to be set up to use JDK 5, since the annotations will only compile with JDK 5 or above
Run with JDK 5
The two main targets for running with JDK 5 are
$ ant run.aopc.50
$ ant run.loadtime.50
ant.run.aopc.50
The ant.run.aopc.50 target uses compile-time weaving, and performs the following steps:
- Compiles the classes using JDK 5
- Runs the AOPC compiler using JDK 5
- Runs the woven example using JDK 5
ant.loadtime.aopc.50
The ant.loadtime.aopc.50 target uses load-time weaving (the classes are
transformed when first loaded) and performs the following steps:
- Compiles the classes using JDK 5
- Runs the example using JDK 5, with the -javagent switch passed in to
the java runtime to enable loadtime weaving
Run with JDK 1.4
We might want to make use of annotations in our code, but still deploy to a JDK 1.4 environment.
JBoss AOP ships with JBoss Retro which allows you to modify JDK 5 bytecode to run on JDK 1.4. To use
annotations we still need to compile with JDK 5, the following two targets illustrate the steps to run
annotated code on JDK 1.4:
$ ant run.aopc.14
$ ant run.loadtime.14
ant.run.aopc.14
The ant.run.aopc.14 target uses compile-time weaving, and performs the following steps:
- Compiles the classes using JDK 5 (otherwise the annotations will not compile)
- Runs the JBoss Retro processor to transform the JDK 5 bytecode into JDK 1.4 bytecode
- Runs the AOPC compiler
- Switches to JDK 1.4, and runs the woven example using JDK 1.4 with jbossretro-rt.jar on the classpath.
You need to specify the location of the JDK 1.4 executable in the jdk14.java property in the
examples.properties file.
ant.loadtime.14
The ant.loadtime.14 target uses loadtime-time weaving (the classes are:
transformed when first loaded) and performs the following steps:
- Compiles the classes using JDK 5 (otherwise the annotations will not compile)
- Runs the JBoss Retro processor to transform the JDK 5 bytecode into JDK 1.4 bytecode
- Switches to JDK 1.4, and runs the woven example using JDK 1.4 with jbossretro-rt.jar on the classpath,
and with the -Xbootclasspath/p: switch passed in to the java runtime to enable loadtime weaving.
You need to specify the location of the JDK 1.4 executable in the jdk14.java property in the
examples.properties file.