jakartaee/rest

Support class field or method parameter injection via CDI for types supported via @Context injection

Opened this issue · 3 comments

The following types are allowed to be injected in class fields and method parameters via @context injection. These will need to be supported via CDI going forward:

  • Application subclasses
  • UriInfo
  • HttpHeaders
  • Request
  • SecurityContext
  • Providers
  • ResourceContext
  • Configuration (both client and server runtime configurations)
  • Sse
  • SseEventSink

See: https://jakarta.ee/specifications/restful-ws/3.1/jakarta-restful-ws-spec-3.1#contexttypes

Just a +1 and this should be fairly simple, at least it is in RESTEasy, to accomplish. Two that we missed are Sse and SseEventSink.

One thing we should determine is the scope these types should have. The following would be my personal recommendation:

Type Scope
Application subclasses @ApplicationScoped
UniInfo @RequestScoped
HttpHeaders @RequestScoped
Rquest @RequestScoped
SecurityContext @RequestScoped
Providers @ApplicationScoped
ResourceContext @ApplicationScoped
Configuration none (@Dependant)
Sse @ApplicationScoped
SseEventSink @RequestScoped

Note that if we end up allowing, or defining, that more than one application can be used per-deployment, then we may need to adjust the @ApplicationScoped ones. Maybe we preemptively do that now.

I just realized the two I said we missed were already referenced in #1212 :)

I agree, I'll close #1212.