-
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
Support injection via CDI to indicate a dependency on a Servlet-defined resource #1214
Comments
IMO we shouldn't add anything specific here for the REST spec. In fact, we should probably deprecate these injection types. If servlet is available, the CDI spec requires servlet containers make these types injectable https://jakarta.ee/specifications/cdi/4.0/jakarta-cdi-spec-4.0#additional_builtin_beans. The one exception here is the |
Looks like jakarta.servlet.http.HttpServletResponse is another exception. |
Good catch. I would guess most implementations do allow it to be injected, but you're correct that it's not listed. |
@arjantijms Can you, please, shed light on what CDI beans are provided by Servlet 6.1 (Remember we discussed some changes) and what provides the Glassfish Servlet impl? |
No, the only beans I'm aware of provided by CDI are in the spec section James linked before. However, note that these requirements will move to the web profile spec for EE 11, so the REST spec may want to restate them anyway. If the REST implementation already has a way to get hold of these objects, I would have thought that making them available for injection should be fairly straight forward with a producer method. |
If we do include those as required in the spec, we should be specific they are only available in a servlet environment. The Jakarta EE Core Profile does not include servlet. |
As well as in the CDI-managed environment |
Build-in beans should really be provided by the technology that owns (defines/exports) these types. In this case, it should be Servlet, and only Servlet, that should define that those types are injectable. It's rather late in the cycle, but it has been discussed before, and maybe we can still get in the Servlet spec. |
I agree with this. Even if we can't get it into the servlet spec, could we deprecate/remove the ability to inject it in the REST spec? I know it's a breaking change. I can say in Wildfly the only one that can't currently be injected is the |
That would be better indeed. REST would otherwise have to inject only the types not already injected via CDI itself, otherwise they would clash. That would then cause one group of Servlet types to be injected by CDI itself, another group by REST, while all the while Servlet itself should do it. |
Can we say that it is only injectable by |
+1 from me, this makes the most sense |
I have seen it to be used quite heavily, unfortunately. |
I've updated jakartaee/platform#837 to request support for these interfaces as part of the work being done in the platform for EE11. |
I think they're is going to be an issue with injecting the |
@jamezp Could you elaborate on your comment? The "too soon" part in particular? |
Sure. Note this is Weld specific, but I would assume other implementations behave the same or similar. Weld creates the request scope in the One idea @WhiteCat22 and I were discussing was possibly something like injecting a The Jakarta REST spec does not currently have a hard dependency on Jakarta Servlet and we likely don't want it given Jakarta EE Core does not include servlet. It's also kind of a weird API for the servlet spec too. It's also just a bit odd in general to have to get the response like that, but I don't have a lot of other ideas :) |
The following Servlet-defined types are currently supported via
@Context
injection and will need to be supported via CDI going forward:See: https://jakarta.ee/specifications/restful-ws/3.1/jakarta-restful-ws-spec-3.1#servlet_container
The text was updated successfully, but these errors were encountered: