I have a CDI bean with private method inside it. I have written an interceptor like following:
Interceptor's code:
@Interceptor
@TimeMeasure
public class TimeWatcher implements Serializable {
    @AroundInvoke
    public Object logMethodEntry(InvocationContext ctx) throws Exception {
        long t0 = System.nanoTime();
        try {
            return ctx.proceed();
        } finally {
            long dt = System.nanoTime() - t0;
            System.out.println("Method execution time: " + ctx.getMethod().getName() +  " - " + dt);
        }
    }
}
Annotation's code:
 import static java.lang.annotation.ElementType.METHOD;
    import static java.lang.annotation.ElementType.TYPE;
    import static java.lang.annotation.RetentionPolicy.RUNTIME;
    @InterceptorBinding
    @Target({TYPE, METHOD})
    @Retention(RUNTIME)
    public @interface TimeMeasure {
    }
Everything works fine only for public methods which are called externally, if I call method from inside CDI bean it doesn't work. I use JSF 2.0 MyFaces together with Omnifaces to accomplish @ViewScoped
Thank you in advance.
This is by design. Internal calls can never be intercepted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With