-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle @*Param annotations with CDI injection #1208
Comments
I've been making some notes and thinking about this. IMO these annotations need to be CDI qualifiers. It will make it much easier for injection. The one catch is for instance fields they'd need the extra |
On page 4 of https://github.com/jakartaee/rest/blob/release-4.0/JakartaRest40.pdf Santiago stated that the @Inject annotation would need to be used for |
A couple other notes on this. We also need to note that any of the qualifiers with required attributes, the required attribute needs to be annotated with Another thing we need to consider, for implementations, is how a CDI producer would look like for these qualifiers. It's fairly easy if the return type is a We also need to require the producers for these are |
After thinking about this a bit more, it might actually work with a dynamic producer registered in a CDI extension. We'd need to get the generic type from every |
Along these lines, I almost wonder if the I guess the one caveat would be the client side. |
+1 for 4.0+ |
Just to be clear Markus, are you voting -1 on annotating ParamConverterProvider with @deprecated(forRemoval = true) for the proposed release 3.2 (pre-4.0) release, or is there more to that vote? Thanks |
I am +1 for deprecating it in 3.x and removing it in 4.0. |
Thank you for the clarification. This makes a lot of sense to me as well. |
I note that with the way However, I think converters registered with We used a similar approach to allow injection of config values with arbitrary types in MP Config. |
If I recall, that would work for beanDiscoveryMode="all", or for CDI beans, i.e. |
@jansupol That would be my personal plan, yes. I'm going to propose jamezp/jakarta-rest@cleanup...jamezp:jaxrs-api:cdi-annotations once #1211 is merged. We just need one more approval for that if you'd like to give it a review :) |
The purpose of this issue is to discuss/document how @*Param annotations should be handled in a Jakarta Rest 3.2 version where both the deprecated
@Context
injection and straight CDI alignment are supported.This pertains to the following annotations:
@HeaderParam, @CookieParam, @MatrixParam, @QueryParam, and @PathParam
The each of following examples must be handled:
field injection
@Inject
@HeaderParam("who")
private String who;
constructor injection
@Inject
public SampleResource(GreetBean bean,
@QueryParam("lang") String lang) {
this.bean = bean;
this.lang = lang;
resource method injection
@POST
@Path("async")
@Consumes(MediaType.TEXT_PLAIN)
public putMessageAsync(
@QueryParam("override") boolean override,
@Body String message,
AsyncResponse ar) {
Executors.newSingleThreadExecutor().submit(() -> {
// ...
ar.resume("Done");
});
The text was updated successfully, but these errors were encountered: