protoj.lang.internal.sample.snippet.UseCaseAspectj Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protoj-jdk6 Show documentation
Show all versions of protoj-jdk6 Show documentation
ProtoJ: the pure java build library with maximum dependencies
The newest version!
package protoj.lang.internal.sample.snippet;
import org.aspectj.tools.ant.taskdefs.AjcTask;
import protoj.lang.CompileFeature;
import protoj.lang.StandardProject;
import protoj.util.ArgRunnable;
/**
* A code fragment used to demonstrate configuring a project to use aspectj.
*
* @author Ashley Williams
*
*/
public final class UseCaseAspectj {
/**
* Adds configuration to the specified project to enable both aspectj
* compilation and also load-time-weaving.
*
* @param project
*/
public void addConfig(StandardProject project) {
// 1. Enable the aspectj compiler.
//
// By default javac is configured so specifying true specifies that ajc
// should be used instead. We also take the opportunity to configure
// some of the ajc properties with hard-coded values. These values can
// also be overridden with the system properties "protoj.compile.source"
// and "protoj.compile.memory", so they server as global defaults
project.getCompileFeature().initConfig(true,
new ArgRunnable() {
public void run(CompileFeature feature) {
AjcTask compileTask = feature.getAjcCompileTask()
.getCompileTask();
compileTask.setMaxmem("16m");
compileTask.setSource("1.5");
}
});
// 2. Enable load-time-weaving.
//
// We are not forced to enabled load-time-weaving just because we are
// using the aspectj compiler, but we choose to do so here. The null
// argument signifies that the API should look for the default weaver
// jar called "aspectjweaver.jar".
project.getDispatchFeature().initLoadTimeWeaving(null);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy