yogiginger
yogiginger

Reputation: 1145

AroundInvoke not called with Quarkus

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.

Upvotes: 7

Views: 2317

Answers (2)

Keith Herbert
Keith Herbert

Reputation: 28

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

Upvotes: 1

Serkan
Serkan

Reputation: 1235

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

Upvotes: 1

Related Questions