Hi everybody,
I have a weird problem with annotations. I have created a dummy service with LiveMonitoring annotation. Spring AOP catch all method invocations marked with this annotation (with Around advice). For some reason I'm seeing the system output twice. Any ideas?
My dummy Service:
My Annotation:Code:public class ServiceImpl implements Service { /* (non-Javadoc) * @see org.enterprise.example.instrumentation.Service#doSomething() */ @LiveInstrumentation public void doSomething(){ System.out.println("Do Something!!!"); } }
My Service:Code:@Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface LiveInstrumentation { }
Code:@Aspect public class AspectLiveMonitoring { @Around("@annotation(org.enterprise.example.instrumentation.LiveInstrumentation)") public void live(ProceedingJoinPoint jp) throws Throwable{ StopWatch watch = new StopWatch(); watch.start(); jp.proceed(); watch.stop(); System.out.println("Method " + jp.getSignature().toLongString() + " executed in " + watch.getLastTaskTimeMillis() + " millis"); } }
Console Output:
Why does this trace appear twice?Code:Do Something!!! Method public abstract void org.enterprise.example.instrumentation.Service.doSomething() executed in 0 millis Method public abstract void org.enterprise.example.instrumentation.Service.doSomething() executed in 0 millis
Thanks in advance!
Isaac


Reply With Quote
