I would like to log the execution time for some methods in my controllers.
Right now I am just trying to figure out so I don't log but print, and it's for all methods.
I have a Profiler class:
@Aspect
public class Profiler {
@Pointcut("execution(public * *(..))")
public void methods() {}
@Around("methods()")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
long start = System.currentTimeMillis();
Object result = joinPoint.proceed();
System.out.println(joinPoint.getSignature() + " " + (System.currentTimeMillis() - start));
return result;
}
}
My pom.xml contains aspectjrt version 1.8.5
I don't use Spring.
I tried dozens of combinations of annotations like @Provider, @ApplicationScoped, @Initialized(ApplicationScoped.class), @Named.
I tried to use javax.ws.rs.core.Application, jboss-aop.xml, etc.
Nothing works (but no errors) :-(
Thanks for your help.