AspectJ 与 JSF1.2
我正在使用 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;
}
}
I am using JSF1.2 framework. I didnt Integrate my application with Spring.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;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 WAR build.xml 文件中创建了一个目标,并添加了 AspectJ jar 文件。现在我得到了所有被调用的方法。这是目标代码:
将上面的代码放在一个包中,并将上面的 ant 脚本添加到你的 war build.xml 中,这样就可以工作了
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:
put the above code in one package and add the above ant script in you war build.xml thats it it will work