Reputation: 4589
If I use IDE to run the code, everything works fine.
But when i use ant to compile the code, Aspectj's proxy doesn't work. My ant target
<property name="ajc.adapter" value="org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter"/>
<target name="compile" description="compile all files">
<mkdir dir="WebContent/WEB-INF/classes" />
<javac
debug="true"
srcdir="src"
destdir="WebContent/WEB-INF/classes"
classpathref="classpath"
deprecation="true"
source="1.6"
target="1.6"
optimize="true">
<include name="**/*.java" />
<compilerarg compiler="${ajc.adapter}" line="-verbose -Xlint -proceedOnError"/>
<compilerarg compiler="${ajc.adapter}" value="-classpath"/>
<!--<compilerarg value="-Xlint:deprecation"/>-->
<!--<compilerarg value="-Xlint:unchecked"/>-->
</javac>
<!-- Copy the properties files. -->
<copy todir="WebContent/WEB-INF/classes">
<fileset dir="src">
<include name="**/*.properties" />
</fileset>
</copy>
<!-- Copy the XML files -->
<copy todir="WebContent/WEB-INF/classes">
<fileset dir="src">
<include name="**/*.xml" />
</fileset>
</copy>
</target>
Java code :
@Around("execution(* *.*(..)) && @annotation(com.xyz.MonitorMethod)")
public Object check(ProceedingJoinPoint pjp) throws Throwable {
try {
return pjp.proceed();
} finally {
System.out.println("======================222");
}
}
Is any issue in this target? THX. I want use Ajc11CompilerAdapter (javac)
Upvotes: 0
Views: 1376
Reputation: 7630
You are not running ajc
at all in your ant target, just standard javac
.
Please refer to ajc
ant task documentation
EDIT: (listing the rough steps from the page above):
aspectjtools.jar
into ant's lib directorymodify your javac
target using following for guidance guidance:
<property name="ajc"
value="org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter"/>
<javac srcdir="src" includes="org/aspectj/**/*.java" destdir="dest" >
<compilerarg compiler="${ajc}" line="-argfile src/args.lst"/>
<javac/>
run your build script passing the build.compiler
property with value of fully qualified name of the adapter class:Ant -Dbuild.compiler=org.aspectj.tools.ant.taskdefs.Ajc11CompilerAdapter
(I can't tell why you would pass it as command line argument AND define it as property within the script either)
Upvotes: 2