-
Notifications
You must be signed in to change notification settings - Fork 139
Introduce CDI requirements for deprecated @Context injection
#1340
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
base: main
Are you sure you want to change the base?
Changes from all commits
a4253c9
69379c3
c1bb1b5
6694dc7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,9 +76,11 @@ | |
| * | ||
| * @author Marek Potociar | ||
| * @since 2.0 | ||
| * @deprecated use Jakarta Context and Dependency injection | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should add
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have the version in the |
||
| */ | ||
| @Target({ ElementType.PARAMETER }) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Documented | ||
| @Deprecated(forRemoval = true, since = "5.0") | ||
| public @interface Suspended { | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,7 +28,6 @@ | |
| * | ||
| * @author Paul Sandoz | ||
| * @author Marc Hadley | ||
| * @see Context | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we need another cross reference mentioned, to make clear that these interfaces are injectable? |
||
| * @since 1.0 | ||
| */ | ||
| public interface HttpHeaders { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,9 @@ | |
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| import jakarta.enterprise.context.ApplicationScoped; | ||
| import jakarta.enterprise.inject.Stereotype; | ||
|
|
||
| /** | ||
| * Marks an implementation of an extension interface that should be discoverable by JAX-RS runtime during a provider | ||
| * scanning phase. | ||
|
|
@@ -33,5 +36,7 @@ | |
| @Target({ ElementType.TYPE }) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Documented | ||
| @ApplicationScoped | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I wonder if providers can only be application scoped, or if it was valid to make them request scoped before?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see why they couldn't be request scoped. I probably wouldn't suggest it, but I don't see why it would be an issue :) |
||
| @Stereotype | ||
| public @interface Provider { | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| //// | ||
| ******************************************************************* | ||
| * Copyright (c) 2026 Eclipse Foundation | ||
| * | ||
| * This specification document is made available under the terms | ||
| * of the Eclipse Foundation Specification License v1.0, which is | ||
| * available at https://www.eclipse.org/legal/efsl.php. | ||
| ******************************************************************* | ||
| //// | ||
|
|
||
| [[changes-since-4.0-release]] | ||
| === Changes Since 4.0 Release | ||
|
|
||
| * <<cdi>>: Required CDI 5.0 or later for proper integration of Jakarta REST and CDI injection (https://github.com/jakartaee/rest/issues/569[#569]) | ||
| * <<cdi-injection-model>>: Documented comprehensive CDI injection model for resources and providers (https://github.com/jakartaee/rest/issues/569[#569]) | ||
| * <<cdi>>: Updated `@ApplicationPath`, `@Path`, and `@Provider` annotations to be CDI stereotype | ||
| annotations with default scopes (`@ApplicationScoped` for `@ApplicationPath` and `@Provider`, | ||
| `@RequestScoped` for `@Path`) (https://github.com/jakartaee/rest/issues/556[#556], https://github.com/jakartaee/rest/issues/952[#952]) | ||
| * <<cdi-injection-model>>: Parameter extraction annotations (`@QueryParam`, `@PathParam`, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to list
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we determine that |
||
| `@HeaderParam`, `@MatrixParam`, `@CookieParam`, `@FormParam`) now act as CDI qualifiers (https://github.com/jakartaee/rest/issues/569[#569]) | ||
| * <<cdi-injection-model>>: Fields in CDI-managed beans must use `@Inject` instead of the | ||
| deprecated `@Context` annotation (https://github.com/jakartaee/rest/issues/569[#569], https://github.com/jakartaee/rest/issues/1209[#1209]) | ||
| * <<cdi-injection-model>>: Resource method parameters support only Jakarta REST context types, | ||
| parameter extraction annotations, entity parameters, `AsyncResponse`, and `SseEventSink`; | ||
| arbitrary CDI beans must be injected via fields or constructors (https://github.com/jakartaee/rest/issues/569[#569]) | ||
| * <<cdi-injection-model>>: Clarified that `AsyncResponse` and `SseEventSink` can only be | ||
| used as resource method parameters, not as injectable fields (https://github.com/jakartaee/rest/issues/569[#569]) | ||
| * <<cdi-producers>>: Required CDI producers for Jakarta REST context types and parameter | ||
| extraction annotations (https://github.com/jakartaee/rest/issues/569[#569]) | ||
| * Deprecated `@Context` annotation for removal in a future release (https://github.com/jakartaee/rest/issues/569[#569], https://github.com/jakartaee/rest/issues/1209[#1209]) | ||
| * Deprecated `@Suspended` annotation in 5.0 for removal in a future release; use type-alone approach | ||
| for `AsyncResponse` in CDI environments (https://github.com/jakartaee/rest/issues/1209[#1209]) | ||
| * <<servlet_container>>: Deprecated `@Context` injection for Servlet-defined types; use CDI | ||
| injection (`@Inject`) as specified by Jakarta Servlet and Jakarta EE Platform specifications (https://github.com/jakartaee/rest/issues/1214[#1214]) | ||
| * Removed Additional Requirements section; CDI specification defines bean lifecycle behaviors (https://github.com/jakartaee/rest/issues/1215[#1215]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be "provided"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can go either way. It's required at runtime and Maven doesn't provide the best scopes for this. However, I've always been of the opinion that an API should transitively bring in the dependencies it needs. Users can always override them.