Re: CDI integration


Turning on CDI by default implies that all methods have to be non-final, which is not backwards compatible to JAX-RS 2.0. So we cannot do that.



From: [] On Behalf Of Ondrej Mihályi
Sent: Dienstag, 6. Juni 2017 16:27
Subject: Re: [jaxrs] CDI integration


>> The only caveat is that the implementation will need to know the classes by that point, which is before ServletContainerInitializer is fired

that certainly is a problem, we do rely on servlet scanning..

Even it wouldn't be a problem, if @Path annotation isn't a bean defining annotation, the event wouldn't be fired at all in the "annotated" discovery mode if there are no other CDI beans (possible if resources only want to inject beans from other modules).

The approach of turning @Path into a stereotype is very nice and it doesn't require a runtime dependency on CDI at all. CDI API would be needed only to compile JAX-RS API because annotations not found on the classpath are ignored by the JVM, CDI impl wouldn't be needed at all. If we specify @RequestScoped in the stereotype, it would just specify what I believe all implementations do anyway -> create a resource instance per request, which is the default behavior mandated by the previous JAX-RS 2.0
It would be possible to override the scope for each class in a standard way by providing a scope annotation along with @Path.

Furthermore, if @Path is a stereotype, it would also become a bean-defining annotation and turn on CDI by default, even if there are no other CDI beans in the module, which is what most people would expect.


Join to automatically receive all group messages.