JBoss.org Community Documentation

- Prev
- Next

## 6.2. Compile-time instrumentation

While load-time is the preffered approach, it is also possible to instrument classes at compile-time. To do this, the aopc tool is used, with the following requirements:

1. The `aoppath` option must point to the location of pojocache-aop.xml

2. 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 executeed the clasess in the build directory are modified. They can then be packaged in a jar and loaded using the normal Java mechanisms.

- Prev6.1. Load-time instrumentation
- Top of page
- Front page
- Next6.3. Understanding the provided AOP descriptor