JBoss.org Community Documentation
While load-time is the preferred approach, it is also possible to instrument classes at compile-time. To do this, the aopc tool is used, with the following requirements:
The
aoppath
option must point to the location of pojocache-aop.xml
The
src
option must point to the location of your class files that are
to be instrumented. This is typically the output folder of a
javac
run.
The following is an example ant task which performs compile-time instrumentation:
<taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="aop.classpath"/> <target name="aopc" depends="compile" description="Precompile aop class"> <aopc compilerclasspathref="aop.classpath" verbose="true"> <src path="${build}"/> <include name="org/jboss/cache/aop/test/**/*.class"/> <aoppath path="${output}/resources/pojocache-aop.xml"/> <classpath path="${build}"/> <classpath refid="lib.classpath"/> </aopc> </target>
In this example, once the aopc target is executed the classes in the build directory are modified. They can then be packaged in a jar and loaded using the normal Java mechanisms.