我正在使用JSF1.2框架。我没有将我的应用程序与 Spring 集成。我想对方法调用执行分析。我的应用程序文件是EAR (EJB + WAR)。我可以在拦截器的帮助下获取会话 bean 方法的执行时间,但对于 WAR 模块,我建议在此博客中使用 AspectJ。所以我写了一些代码。有什么我需要做的,比如配置细节。我添加了AspectJ所需的 jar 文件,JSF 是否支持 AspectJ的任何配置?我的代码是:
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;
}
}