I created the following invoking class, which should be invoked, when an intercepted method is called:
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptor;
import javax.interceptor.InvocationContext;
@Interceptor
class TestAspect {
@AroundInvoke
public Object log(InvocationContext context) throws Exception {
System.out.println("AroundInvoke method called");
return context.proceed();
}
}
and this resource:
import javax.interceptor.Interceptors;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/test")
@Interceptors(TestAspect.class)
public class TestResource {
@GET
@Path("/")
public String test() {
System.out.println("Resource method called");
return new String("test");
}
}
But I only get the log line from the resouce.
Per the Quarkus CDI Reference Guide,
- @Interceptors is not supported
You'll need to add the @Priority
, @Interceptor
, and your binding annotation to your Interceptor class. See here for an example
You need to activate your interceptor either by defining it in beans.xml or adding @Priority(number) on your interceptor.
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