My application file (EAR) consists of combination of EJB and WAR. FrameWork is JSF and IDE is Netbeans 6.9.1 applition server is glassfich V2.x. I want to calculate the execution time fro each and every invoked method in my application. i have gone through so many blogs. most of them suggested to use AOP. but nobody tell me how to configure and how to use it in my application. could anybody tell me ragarding this. I have some code here and i made use of AOP and JAMon to calculate the method execution time. but i confused about how to configure this because for every method invocation this calss should be invoked for that what to do i dont know. could anybody give some suggestions on it.If you any additional details to answer this i will provide. Code is:
public class PerformanceMonitorIncptr implements MethodInterceptor{
/** Creates a new instance of PerformanceMonitorIncptr */
public PerformanceMonitorIncptr() {
}
public Object invoke(MethodInvocation mi) throws Throwable {
String mName = mi.getMethod().getDeclaringClass().getName() + "." + mi.
getMethod().getName();
Monitor mon = MonitorFactory.start(mName);
// long l = System.currentTimeMillis();
Object returnValue = null;
try {
returnValue = mi.proceed();
} finally {
mon.stop();
System.out.println(mon);
}
System.out.println(mName);
// System.out.println(l - System.currentTimeMillis());
return returnValue;
}
}
AOP is best suited here.
You need to configure
@PointCut@Aroundeach method you want to log the time of executionHave a look at this tutorial .
Update
I hope 20 methods you are talking about /can be are Spring Service methods, and you don’t need to alter them at all you just need to configure a
@Aspectthat will involve all the methods. read more