Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions jaxrs-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
</build>

<dependencies>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
</dependency>

Copy link
Copy Markdown
Contributor

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"?

Copy link
Copy Markdown
Member Author

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.

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/ApplicationPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Stereotype;

/**
* Identifies the application path that serves as the base URI for all resource URIs provided by
* {@link jakarta.ws.rs.Path}. May only be applied to a subclass of {@link jakarta.ws.rs.core.Application}.
Expand All @@ -40,6 +43,8 @@
@Documented
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@ApplicationScoped
@Stereotype
public @interface ApplicationPath {

/**
Expand Down
5 changes: 4 additions & 1 deletion jaxrs-api/src/main/java/jakarta/ws/rs/BeanParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.inject.Qualifier;

/**
* The annotation that may be used to inject custom JAX-RS "parameter aggregator" value object into a resource class
* field, property or resource method parameter.
* <p>
* The JAX-RS runtime will instantiate the object and inject all its fields and properties annotated with either one of
* the {@code @XxxParam} annotation ({@link PathParam &#64;PathParam}, {@link FormParam &#64;FormParam} ...) or the
* {@link jakarta.ws.rs.core.Context &#64;Context} annotation. For the POJO classes same instantiation and injection rules
* {@link jakarta.inject.Inject &#64;Inject} annotation. For the POJO classes same instantiation and injection rules
* apply as in case of instantiation and injection of request-scoped root resource classes.
* </p>
* For example:
Expand Down Expand Up @@ -68,5 +70,6 @@
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Qualifier
public @interface BeanParam {
}
3 changes: 3 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/CookieParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.inject.Qualifier;

/**
* Binds the value of a HTTP cookie to a resource method parameter, resource class field, or resource class bean
* property. A default value can be specified using the {@link DefaultValue} annotation.
Expand Down Expand Up @@ -55,6 +57,7 @@
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Qualifier
public @interface CookieParam {

/**
Expand Down
3 changes: 3 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/FormParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.inject.Qualifier;

/**
* Binds the value(s) of a form parameter contained within a request entity body to a resource method parameter. Values
* are URL decoded unless this is disabled using the {@link Encoded} annotation. A default value can be specified using
Expand Down Expand Up @@ -66,6 +68,7 @@
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Qualifier
public @interface FormParam {

/**
Expand Down
3 changes: 3 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/HeaderParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.inject.Qualifier;

/**
* Binds the value(s) of a HTTP header to a resource method parameter, resource class field, or resource class bean
* property. A default value can be specified using the {@link DefaultValue} annotation.
Expand Down Expand Up @@ -58,6 +60,7 @@
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Qualifier
public @interface HeaderParam {

/**
Expand Down
3 changes: 3 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/MatrixParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.inject.Qualifier;

/**
* Binds the value(s) of a URI matrix parameter to a resource method parameter, resource class field, or resource class
* bean property. Values are URL decoded unless this is disabled using the {@link Encoded} annotation. A default value
Expand Down Expand Up @@ -66,6 +68,7 @@
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Qualifier
public @interface MatrixParam {

/**
Expand Down
5 changes: 5 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/Path.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.enterprise.context.RequestScoped;
import jakarta.enterprise.inject.Stereotype;

/**
* Identifies the URI path that a resource class or class method will serve requests for.
*
Expand Down Expand Up @@ -65,6 +68,8 @@
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestScoped
@Stereotype
public @interface Path {

/**
Expand Down
3 changes: 3 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/PathParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.inject.Qualifier;

/**
* Binds the value of a URI template parameter or a path segment containing the template parameter to a resource method
* parameter, resource class field, or resource class bean property. The value is URL decoded unless this is disabled
Expand Down Expand Up @@ -67,6 +69,7 @@
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Qualifier
public @interface PathParam {

/**
Expand Down
3 changes: 3 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/QueryParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import jakarta.inject.Qualifier;

/**
* Binds the value(s) of a HTTP query parameter to a resource method parameter, resource class field, or resource class
* bean property. Values are URL decoded unless this is disabled using the {@link Encoded} annotation. A default value
Expand Down Expand Up @@ -60,6 +62,7 @@
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Qualifier
public @interface QueryParam {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

package jakarta.ws.rs.container;

import jakarta.ws.rs.core.Context;

/**
* The resource context provides access to instances of resource classes.
* <p>
* This interface can be injected using the {@link Context} annotation.
* This interface can be injected using the {@link jakarta.inject.Inject Inject} annotation.
* </p>
* <p>
* The resource context can be utilized when instances of managed resource classes are to be returned by sub-resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@
*
* @author Marek Potociar
* @since 2.0
* @deprecated use Jakarta Context and Dependency injection

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add since 5.0 to the JavaDocs also, so people have a better understanding which version supports what technology?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the version in the @Deprecated annotation. We could add it here too I guess.

*/
@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
Expand Up @@ -25,7 +25,7 @@
* implementation supplies a concrete subclass of this abstract class.
* <p>
* The implementation-created instance of an Application subclass may be injected into resource classes and providers
* using {@link jakarta.ws.rs.core.Context}.
* using {@link jakarta.inject.Inject}.
* </p>
* <p>
* In case any of the {@code Application} subclass methods or its constructor throws a {@link RuntimeException}, the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public interface Configurable<C extends Configurable> {
* As opposed to components registered via {@link #register(Class)} method, the lifecycle of providers registered using
* this instance-based {@code register(...)} is not managed by JAX-RS runtime. The same registered component instance is
* used during the whole lifespan of the configurable context. Fields and properties of all registered JAX-RS component
* instances are injected with their declared dependencies (see {@link Context}) by the JAX-RS runtime prior to use.
* instances are injected with their declared dependencies by CDI prior to use.
* </p>
*
* @param component JAX-RS component instance to be configured in the scope of this configurable context.
Expand Down
4 changes: 2 additions & 2 deletions jaxrs-api/src/main/java/jakarta/ws/rs/core/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
* component classes and/or instances.
* </p>
* <p>
* This interface can be injected using the {@link Context} annotation.
* This interface can be injected using the {@link jakarta.inject.Inject} annotation.
* </p>
*
* @author Marek Potociar
Expand Down Expand Up @@ -174,7 +174,7 @@ public default boolean hasProperty(String name) {
/**
* Get the immutable set of registered JAX-RS component (such as provider or {@link Feature feature}) instances to be
* utilized by the configurable instance. Fields and properties of returned instances are injected with their declared
* dependencies (see {@link Context}) by the runtime prior to use.
* dependencies by the runtime prior to use.
* <p>
* For each component type, there can be only a single class-based or instance-based registration present in the
* configuration context at any given time.
Expand Down
2 changes: 2 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/core/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
* @see SecurityContext
* @see jakarta.ws.rs.ext.Providers
* @since 1.0
* @deprecated use Jakarta Context and Dependency injection
*/
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Deprecated(forRemoval = true, since = "5.0")
public @interface Context {
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*
* @author Paul Sandoz
* @author Marc Hadley
* @see Context

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*
* @author Paul Sandoz
* @author Marc Hadley
* @see Context
* @since 1.0
*/
public interface SecurityContext {
Expand Down
1 change: 0 additions & 1 deletion jaxrs-api/src/main/java/jakarta/ws/rs/core/UriInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
*
* @author Paul Sandoz
* @author Marc Hadley
* @see Context
* @since 1.0
*/
public interface UriInfo {
Expand Down
5 changes: 5 additions & 0 deletions jaxrs-api/src/main/java/jakarta/ws/rs/ext/Provider.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -33,5 +36,7 @@
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@ApplicationScoped

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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 {
}
2 changes: 0 additions & 2 deletions jaxrs-api/src/main/java/jakarta/ws/rs/ext/Providers.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
*
* @author Paul Sandoz
* @author Marc Hadley
* @see jakarta.ws.rs.core.Context
* @see MessageBodyReader
* @see MessageBodyWriter
* @see ContextResolver
* @see ExceptionMapper
* @since 1.0
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* &#64;GET
* &#64;Path("eventStream")
* &#64;Produces(MediaType.SERVER_SENT_EVENTS)
* public void eventStream(@Context SseEventSink eventSink) {
* public void eventStream(SseEventSink eventSink) {
* // ...
* }
* </pre>
Expand Down
1 change: 1 addition & 0 deletions jaxrs-api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
module jakarta.ws.rs {

requires java.logging;
requires jakarta.cdi;

exports jakarta.ws.rs;
exports jakarta.ws.rs.client;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
- [[[bib13,13]]] Jakarta^®^ Concurrency Specification, Version 2.0. Available at:
https://jakarta.ee/specifications/concurrency/2.0/

- [[[bib14,14]]] Jakarta^®^ Contexts and Dependency Injection Specification, Version 2.0. Available at:
https://jakarta.ee/specifications/cdi/2.0/
- [[[bib14,14]]] Jakarta^®^ Contexts and Dependency Injection Specification, Version 5.0. Available at:
https://jakarta.ee/specifications/cdi/5.0/

- [[[bib15,15]]] Jakarta^®^ Annotations Specification, Version 2.0. Available at:
https://jakarta.ee/specifications/annotations/2.0/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
[[change-log]]
== Change Log

include::_changes-since-4.0-release.adoc[]

include::_changes-since-3.1-release.adoc[]

include::_changes-since-3.0-release.adoc[]
Expand Down
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`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to list @EntityParam here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we determine that @EntityParam really is a CDI qualifier, yes. I'm not sure it can be. I need to think through how this would work.

`@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])
Loading
Loading