AspectJ with JSF1.2
I am using JSF1.2 framework. I didnt Integrate my application with Sp开发者_C百科ring.I want to perform profiling on method invocations. my application file is EAR (EJB + WAR ). i can get the session beans methods execution time with the help of interceptor but for WAR module i was suggested to use AspectJ in this blog. so i have written some code. is there any thing i need to do like configuration details. I added the required jar file of AspectJ is JSF support AspectJ with any configuration? my code is:
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
@Aspect
public class AopInterceptor implements MethodInterceptor{
public AopInterceptor() {
}
@Pointcut("execution (* *.*(..))")
public void profile(){}
@Around("profile()")
public Object invoke(MethodInvocation mi) throws Throwable {
System.out.println("test start");
Object obj=mi.proceed();
System.out.println("test end");
return obj;
}
}
I have created a target in WAR build.xml file and I added the AspectJ jar files. Now I am getting all the invoked methods. here is the targer code:
<taskdef classpath="C:/Users/s.kosna/Downloads/aspectj-1.6.11/lib/aspectjtools.jar"
resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties"/>
<target name="aspectj">
<echo level="info">--- aspectj (start) ---</echo>
<condition property="targetos" value="windows" else="unix">
<os family="windows"/>
</condition>
<pathconvert targetos="${targetos}" property="javac.convertedClasspath" >
<path path="${javac.classpath}" />
</pathconvert>
<iajc source="1.6" target="1.6" showweaveinfo="true" verbose="true" destdir="${build.classes.dir}" >
<inpath>
<pathelement location="${build.classes.dir}"/>
</inpath>
<classpath>
<pathelement location="${javac.convertedClasspath}" />
</classpath>
</iajc>
<echo level="info">LORDDOSKIAS BRUTAL TEST ---</echo>
</target>
<target name="-post-compile" depends="aspectj"></target>
put the above code in one package and add the above ant script in you war build.xml thats it it will work
精彩评论