7

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.

yogiginger
  • 1,075
  • 4
  • 13
  • 25

2 Answers2

1

You need to activate your interceptor either by defining it in beans.xml or adding @Priority(number) on your interceptor.

Serkan
  • 639
  • 5
  • 14
1

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