diff --git a/examples/pom.xml b/examples/pom.xml
index 6987a3651..6749d2f96 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -22,7 +22,7 @@
* This example uses some basic external JSSE configuration: + *
+ **
@@ -68,7 +71,7 @@ private ExternalConfigJavaSeBootstrapExample() { * @param args unused command line arguments * @throws InterruptedException when process is killed */ - public static void main(final String[] args) throws InterruptedException { + public static final void main(final String[] args) throws InterruptedException { final Application application = new HelloWorld(); final Config config = ConfigProvider.getConfig(); @@ -77,10 +80,15 @@ public static void main(final String[] args) throws InterruptedException { .build(); SeBootstrap.start(application, requestedConfiguration).thenAccept(instance -> { - instance.stopOnShutdown(stopResult -> - System.out.printf("Stop result: %s [Native stop result: %s].%n", stopResult, - stopResult.unwrap(Object.class))); - final URI uri = instance.configuration().baseUri(); + Runtime.getRuntime() + .addShutdownHook(new Thread(() -> instance.stop() + .thenAccept(stopResult -> System.out.printf("Stop result: %s [Native stop result: %s].%n", + stopResult, stopResult.unwrap(Object.class))))); + + final Configuration actualConfigurarion = instance.configuration(); + final URI uri = UriBuilder.newInstance().scheme(actualConfigurarion.protocol().toLowerCase()) + .host(actualConfigurarion.host()).port(actualConfigurarion.port()) + .path(actualConfigurarion.rootPath()).build(); System.out.printf("Instance %s running at %s [Native handle: %s].%n", instance, uri, instance.unwrap(Object.class)); System.out.println("Send SIGKILL to shutdown."); diff --git a/examples/src/main/java/jaxrs/examples/bootstrap/HttpsJavaSeBootstrapExample.java b/examples/src/main/java/jaxrs/examples/bootstrap/HttpsJavaSeBootstrapExample.java index 045bf0b23..481edd01d 100644 --- a/examples/src/main/java/jaxrs/examples/bootstrap/HttpsJavaSeBootstrapExample.java +++ b/examples/src/main/java/jaxrs/examples/bootstrap/HttpsJavaSeBootstrapExample.java @@ -19,7 +19,9 @@ import java.net.URI; import jakarta.ws.rs.SeBootstrap; +import jakarta.ws.rs.SeBootstrap.Configuration; import jakarta.ws.rs.core.Application; +import jakarta.ws.rs.core.UriBuilder; /** * Java SE bootstrap example using HTTPS. @@ -29,13 +31,17 @@ * {@code https://localhost/} on an implementation-specific default IP port (e. g. 443, 8443, or someting completely * different). The actual configuration needs to be queried after bootstrapping, otherwise callers would be unaware of * the actual chosen port. + *
** This example uses some basic external JSSE configuration: + *
+ **
@@ -66,7 +69,7 @@ private PropertyProviderJavaSeBootstrapExample() {
* @param args unused command line arguments
* @throws InterruptedException when process is killed
*/
- public static void main(final String[] args) throws InterruptedException {
+ public static final void main(final String[] args) throws InterruptedException {
final Application application = new HelloWorld();
final Config config = ConfigProvider.getConfig();
@@ -75,10 +78,15 @@ public static void main(final String[] args) throws InterruptedException {
.protocol("HTTPS").build();
SeBootstrap.start(application, requestedConfiguration).thenAccept(instance -> {
- instance.stopOnShutdown(stopResult ->
- System.out.printf("Stop result: %s [Native stop result: %s].%n", stopResult,
- stopResult.unwrap(Object.class)));
- final URI uri = instance.configuration().baseUri();
+ Runtime.getRuntime()
+ .addShutdownHook(new Thread(() -> instance.stop()
+ .thenAccept(stopResult -> System.out.printf("Stop result: %s [Native stop result: %s].%n",
+ stopResult, stopResult.unwrap(Object.class)))));
+
+ final Configuration actualConfigurarion = instance.configuration();
+ final URI uri = UriBuilder.newInstance().scheme(actualConfigurarion.protocol().toLowerCase())
+ .host(actualConfigurarion.host()).port(actualConfigurarion.port())
+ .path(actualConfigurarion.rootPath()).build();
System.out.printf("Instance %s running at %s [Native handle: %s].%n", instance, uri,
instance.unwrap(Object.class));
System.out.println("Send SIGKILL to shutdown.");
diff --git a/examples/src/main/java/jaxrs/examples/bootstrap/TlsJavaSeBootstrapExample.java b/examples/src/main/java/jaxrs/examples/bootstrap/TlsJavaSeBootstrapExample.java
index 88a5f1b32..32ee38a89 100644
--- a/examples/src/main/java/jaxrs/examples/bootstrap/TlsJavaSeBootstrapExample.java
+++ b/examples/src/main/java/jaxrs/examples/bootstrap/TlsJavaSeBootstrapExample.java
@@ -27,7 +27,9 @@
import java.security.KeyStore;
import jakarta.ws.rs.SeBootstrap;
+import jakarta.ws.rs.SeBootstrap.Configuration;
import jakarta.ws.rs.core.Application;
+import jakarta.ws.rs.core.UriBuilder;
/**
* Java SE bootstrap example using TLS customization.
@@ -54,7 +56,7 @@ private TlsJavaSeBootstrapExample() {
* @throws IOException in case file access fails
* @throws InterruptedException when process is killed
*/
- public static void main(final String[] args)
+ public static final void main(final String[] args)
throws GeneralSecurityException, IOException, InterruptedException {
final Application application = new HelloWorld();
@@ -73,10 +75,15 @@ public static void main(final String[] args)
.sslContext(sslContext).build();
SeBootstrap.start(application, requestedConfiguration).thenAccept(instance -> {
- instance.stopOnShutdown(stopResult ->
- System.out.printf("Stop result: %s [Native stop result: %s].%n", stopResult,
- stopResult.unwrap(Object.class)));
- final URI uri = instance.configuration().baseUri();
+ Runtime.getRuntime()
+ .addShutdownHook(new Thread(() -> instance.stop()
+ .thenAccept(stopResult -> System.out.printf("Stop result: %s [Native stop result: %s].%n",
+ stopResult, stopResult.unwrap(Object.class)))));
+
+ final Configuration actualConfigurarion = instance.configuration();
+ final URI uri = UriBuilder.newInstance().scheme(actualConfigurarion.protocol().toLowerCase())
+ .host(actualConfigurarion.host()).port(actualConfigurarion.port())
+ .path(actualConfigurarion.rootPath()).build();
System.out.printf("Instance %s running at %s [Native handle: %s].%n", instance, uri,
instance.unwrap(Object.class));
System.out.println("Send SIGKILL to shutdown.");
diff --git a/examples/src/main/java/jaxrs/examples/bootstrap/package-info.java b/examples/src/main/java/jaxrs/examples/bootstrap/package-info.java
index 75ad1856f..6515d1f3d 100644
--- a/examples/src/main/java/jaxrs/examples/bootstrap/package-info.java
+++ b/examples/src/main/java/jaxrs/examples/bootstrap/package-info.java
@@ -17,6 +17,6 @@
*
* @author Markus KARG (markus@headcrashing.eu)
* @since 3.1
- * @see jakarta.ws.rs.SeBootstrap
+ * @see jakarta.ws.rs.SeBootstrap;
*/
package jaxrs.examples.bootstrap;
diff --git a/examples/src/main/java/jaxrs/examples/link/LinkExamples.java b/examples/src/main/java/jaxrs/examples/link/LinkExamples.java
index 976e68b2a..4f725ef94 100644
--- a/examples/src/main/java/jaxrs/examples/link/LinkExamples.java
+++ b/examples/src/main/java/jaxrs/examples/link/LinkExamples.java
@@ -51,7 +51,7 @@ public Response example2() {
* 1-step process: Build Response and add a link directly to it using either a String or a URI.
*
* @return response.
- * @throws URISyntaxException if URI is invalid
+ * @throws URISyntaxException
*/
public Response example3() throws URISyntaxException {
Response r;
diff --git a/examples/src/main/java/jaxrs/examples/link/ResourceExample.java b/examples/src/main/java/jaxrs/examples/link/ResourceExample.java
index a6f7127b0..015369f08 100644
--- a/examples/src/main/java/jaxrs/examples/link/ResourceExample.java
+++ b/examples/src/main/java/jaxrs/examples/link/ResourceExample.java
@@ -10,10 +10,10 @@
package jaxrs.examples.link;
+import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Link;
import jakarta.ws.rs.core.UriInfo;
@@ -25,7 +25,7 @@
@Path("/myresource")
public class ResourceExample {
- @Context
+ @Inject
private UriInfo uriInfo;
@GET
diff --git a/examples/src/main/java/jaxrs/examples/link/clusterservice/ClusterResource.java b/examples/src/main/java/jaxrs/examples/link/clusterservice/ClusterResource.java
index 8b109b356..0d733796c 100644
--- a/examples/src/main/java/jaxrs/examples/link/clusterservice/ClusterResource.java
+++ b/examples/src/main/java/jaxrs/examples/link/clusterservice/ClusterResource.java
@@ -12,15 +12,14 @@
import java.net.URI;
+import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Link;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
-
import jaxrs.examples.link.clusterservice.Cluster.Status;
/**
@@ -31,7 +30,7 @@
@Path("/cluster")
public class ClusterResource {
- @Context
+ @Inject
private UriInfo uriInfo;
private Cluster cluster = Model.getCluster();
diff --git a/examples/src/main/java/jaxrs/examples/link/clusterservice/MachineResource.java b/examples/src/main/java/jaxrs/examples/link/clusterservice/MachineResource.java
index da6a9f10b..1c2e1664b 100644
--- a/examples/src/main/java/jaxrs/examples/link/clusterservice/MachineResource.java
+++ b/examples/src/main/java/jaxrs/examples/link/clusterservice/MachineResource.java
@@ -12,17 +12,16 @@
import java.net.URI;
+import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.WebApplicationException;
-import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.Link;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
-
import jaxrs.examples.link.clusterservice.Machine.Status;
/**
@@ -33,7 +32,7 @@
@Path("/cluster/machine/{name}")
public class MachineResource {
- @Context
+ @Inject
private UriInfo uriInfo;
private Machine machine;
diff --git a/examples/src/main/java/jaxrs/examples/multipart/MultipartClient.java b/examples/src/main/java/jaxrs/examples/multipart/MultipartClient.java
deleted file mode 100644
index 602b5d16e..000000000
--- a/examples/src/main/java/jaxrs/examples/multipart/MultipartClient.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************
-* Copyright (c) 2021 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.
-*******************************************************************/
-package jaxrs.examples.multipart;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-
-import jakarta.ws.rs.client.Client;
-import jakarta.ws.rs.client.ClientBuilder;
-import jakarta.ws.rs.client.Entity;
-import jakarta.ws.rs.client.WebTarget;
-import jakarta.ws.rs.core.EntityPart;
-import jakarta.ws.rs.core.GenericType;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-
-
-public class MultipartClient {
- private static final Logger LOG = Logger.getLogger(MultipartClient.class.getName());
-
- public boolean sendPdfs(Path dir) throws IOException {
- List
* Following is the list of recognized commands:
*
* The JAX-RS runtime will instantiate the object and inject all it's fields and properties annotated with either one of
* the {@code @XxxParam} annotation ({@link PathParam @PathParam}, {@link FormParam @FormParam} ...) or the
- * {@link jakarta.ws.rs.core.Context @Context} annotation. For the POJO classes same instantiation and injection rules
+ * {@link Entity @Context} annotation. For the POJO classes same instantiation and injection rules
* apply as in case of instantiation and injection of request-scoped root resource classes.
* This annotation is used to inject information into a class field, bean property or method parameter. Annotation that identifies the entity parameter. Note that future versions of this API will stop supporting injection via
- * {@code Context} as part of a tighter integration and alignment with
- * Jakarta CDI.
- * This method is intended to be used in Java SE environments only. The outcome of invocations in Jakarta EE container
- * environments is undefined.
- *
- * This method is intended to be used in Java SE environments only. The outcome of invocations in Jakarta EE container
- * environments is undefined.
- *
- * This method is intended to be used in Java SE environments only. The outcome of invocations in Jakarta EE container
- * environments is undefined.
- *
@@ -213,7 +150,7 @@ static CompletionStage
- * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if
- * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
- * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
- * (missing comma), or the value {@code no - store} (whitespace within value).
- *
- * @param name the message header.
- * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split.
- * @param valuePredicate value must fulfil this predicate.
- * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
- * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.
- * @see #getHeaders()
- * @see #getHeaderString(String)
- * @since 4.0
- */
- public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate
- * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if
- * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
- * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
- * (missing comma), or the value {@code no - store} (whitespace within value).
- *
- * @param name the message header.
- * @param valuePredicate value must fulfil this predicate.
- * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
- * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.
- * @see #getHeaders()
- * @see #getHeaderString(String)
- * @since 4.0
- */
- public default boolean containsHeaderString(String name, Predicate
- * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if
- * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
- * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
- * (missing comma), or the value {@code no - store} (whitespace within value).
- *
- * @param name the message header.
- * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split.
- * @param valuePredicate value must fulfil this predicate.
- * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
- * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.
- * @see #getHeaders()
- * @see #getHeaderString(String)
- * @since 4.0
- */
- public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate
- * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if
- * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
- * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
- * (missing comma), or the value {@code no - store} (whitespace within value).
- *
- * @param name the message header.
- * @param valuePredicate value must fulfil this predicate.
- * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
- * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.
- * @see #getHeaders()
- * @see #getHeaderString(String)
- * @since 4.0
- */
- public default boolean containsHeaderString(String name, Predicate
* A new instance of {@code AsyncResponse} may be injected into a {@link jakarta.ws.rs.HttpMethod resource or sub-resource
- * method} parameter using the {@link Suspended @Suspended} annotation.
+ * method} parameter.
*
- * A completion callback is always invoked when the whole request processing is over, i.e. once a response for the request has
- * been processed and sent back to the client (including processing by a custom exception mapper) or when an unmapped
- * exception or error is being propagated to the default exception mapper.
+ * A completion callback is invoked when the whole request processing is over, i.e. once a response for the request has
+ * been processed and sent back to the client or in when an unmapped exception or error is being propagated to the
+ * container.
*
+ * An unmapped throwable is propagated to the hosting I/O container in case no {@link jakarta.ws.rs.ext.ExceptionMapper
+ * exception mapper} has been found for a throwable indicating a request processing failure. In this case a
+ * non-{@code null} unmapped throwable instance is passed to the method. Note that the throwable instance represents the
+ * actual unmapped exception thrown during the request processing, before it has been wrapped into an I/O
+ * container-specific exception that was used to propagate the throwable to the hosting I/O container.
+ *
- * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if
- * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
- * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
- * (missing comma), or the value {@code no - store} (whitespace within value).
- *
- * @param name the message header.
- * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split.
- * @param valuePredicate value must fulfil this predicate.
- * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
- * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.
- * @see #getHeaders()
- * @see #getHeaderString(String)
- * @since 4.0
- */
- public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate
- * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if
- * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
- * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
- * (missing comma), or the value {@code no - store} (whitespace within value).
- *
- * @param name the message header.
- * @param valuePredicate value must fulfil this predicate.
- * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
- * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.
- * @see #getHeaders()
- * @see #getHeaderString(String)
- * @since 4.0
- */
- public default boolean containsHeaderString(String name, Predicate
- * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if
- * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
- * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
- * (missing comma), or the value {@code no - store} (whitespace within value).
- *
- * @param name the message header.
- * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split.
- * @param valuePredicate value must fulfil this predicate.
- * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
- * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.
- * @see #getHeaders()
- * @see #getHeaderString(String)
- * @since 4.0
- */
- public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate
- * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if
- * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
- * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
- * (missing comma), or the value {@code no - store} (whitespace within value).
- *
- * @param name the message header.
- * @param valuePredicate value must fulfil this predicate.
- * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
- * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.
- * @see #getHeaders()
- * @see #getHeaderString(String)
- * @since 4.0
- */
- public default boolean containsHeaderString(String name, Predicate
- * This interface can be injected using the {@link Context} annotation.
+ * This interface can be injected using the {@link Entity} annotation.
*
* The resource context can be utilized when instances of managed resource classes are to be returned by sub-resource
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/container/Suspended.java b/jaxrs-api/src/main/java/jakarta/ws/rs/container/Suspended.java
deleted file mode 100644
index fba0a462c..000000000
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/container/Suspended.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2012, 2019 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package jakarta.ws.rs.container;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Inject a suspended {@link AsyncResponse} into a parameter of an invoked JAX-RS {@link jakarta.ws.rs.HttpMethod resource
- * or sub-resource method}.
- *
- * The injected {@code AsyncResponse} instance is bound to the processing of the active request and can be used to
- * resume the request processing when a response is available.
- *
- * By default there is {@link AsyncResponse#NO_TIMEOUT no suspend timeout set} and the asynchronous response is
- * suspended indefinitely. The suspend timeout as well as a custom {@link TimeoutHandler timeout handler} can be
- * specified programmatically using the {@link AsyncResponse#setTimeout(long, TimeUnit)} and
- * {@link AsyncResponse#setTimeoutHandler(TimeoutHandler)} methods. For example:
- *
- * A resource or sub-resource method that injects a suspended instance of an {@code AsyncResponse} using the
- * {@code @Suspended} annotation is expected be declared to return {@code void} type. Methods that inject asynchronous
- * response instance using the {@code @Suspended} annotation and declare a return type other than {@code void} MUST be
- * detected by the JAX-RS runtime and a warning message MUST be logged. Any response value returned from such resource
- * or sub-resource method MUST be ignored by the framework:
- *
* 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 Entity}.
*
* In case any of the {@code Application} subclass methods or it's constructor throws a {@link RuntimeException}, the
@@ -62,7 +64,7 @@ public Set
* Implementations should warn about and ignore classes that do not conform to the requirements of root resource or
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/CacheControl.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/CacheControl.java
index 2760ea761..7175545e3 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/CacheControl.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/CacheControl.java
@@ -21,7 +21,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
import jakarta.ws.rs.ext.RuntimeDelegate;
import jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
@@ -340,8 +339,15 @@ public String toString() {
*/
@Override
public int hashCode() {
- int hash = Objects.hash(this.privateFlag, this.noCache, this.noStore, this.noTransform, this.mustRevalidate,
- this.proxyRevalidate, this.maxAge, this.sMaxAge);
+ int hash = 7;
+ hash = 41 * hash + (this.privateFlag ? 1 : 0);
+ hash = 41 * hash + (this.noCache ? 1 : 0);
+ hash = 41 * hash + (this.noStore ? 1 : 0);
+ hash = 41 * hash + (this.noTransform ? 1 : 0);
+ hash = 41 * hash + (this.mustRevalidate ? 1 : 0);
+ hash = 41 * hash + (this.proxyRevalidate ? 1 : 0);
+ hash = 41 * hash + this.maxAge;
+ hash = 41 * hash + this.sMaxAge;
hash = 41 * hash + hashCodeOf(this.privateFields);
hash = 41 * hash + hashCodeOf(this.noCacheFields);
hash = 41 * hash + hashCodeOf(this.cacheExtension);
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Configurable.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Configurable.java
index 2d4910317..aded3ab0c 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Configurable.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Configurable.java
@@ -18,6 +18,8 @@
import java.util.Map;
+import jakarta.ws.rs.Entity;
+
/**
* Represents a client or server-side configurable context in JAX-RS.
*
@@ -261,7 +263,7 @@ public interface Configurable
- * This interface can be injected using the {@link Context} annotation.
+ * This interface can be injected using the {@link Entity} annotation.
*
* 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.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Cookie.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Cookie.java
index ba19e9b67..902a01289 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Cookie.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Cookie.java
@@ -16,8 +16,6 @@
package jakarta.ws.rs.core;
-import java.util.Objects;
-
import jakarta.ws.rs.ext.RuntimeDelegate;
import jakarta.ws.rs.ext.RuntimeDelegate.HeaderDelegate;
@@ -56,9 +54,7 @@ public class Cookie {
* @param domain the host domain for which the cookie is valid.
* @param version the version of the specification to which the cookie complies.
* @throws IllegalArgumentException if name is {@code null}.
- * @deprecated This constructor will be removed in a future version. Please use {@link Cookie.Builder} instead.
*/
- @Deprecated
public Cookie(final String name, final String value, final String path, final String domain, final int version)
throws IllegalArgumentException {
if (name == null) {
@@ -79,9 +75,7 @@ public Cookie(final String name, final String value, final String path, final St
* @param path the URI path for which the cookie is valid.
* @param domain the host domain for which the cookie is valid.
* @throws IllegalArgumentException if name is {@code null}.
- * @deprecated This constructor will be removed in a future version. Please use {@link Cookie.Builder} instead.
*/
- @Deprecated
public Cookie(final String name, final String value, final String path, final String domain)
throws IllegalArgumentException {
this(name, value, path, domain, DEFAULT_VERSION);
@@ -93,32 +87,12 @@ public Cookie(final String name, final String value, final String path, final St
* @param name the name of the cookie.
* @param value the value of the cookie.
* @throws IllegalArgumentException if name is {@code null}.
- * @deprecated This constructor will be removed in a future version. Please use {@link Cookie.Builder} instead.
*/
- @Deprecated
public Cookie(final String name, final String value)
throws IllegalArgumentException {
this(name, value, null, null);
}
- /**
- * Create a new instance from the supplied {@link AbstractCookieBuilder} instance.
- *
- * @param builder the builder.
- * @throws IllegalArgumentException if {@code builder.name} is {@code null}.
- * @since 3.1
- */
- protected Cookie(AbstractCookieBuilder> builder) throws IllegalArgumentException {
- if (builder.name == null) {
- throw new IllegalArgumentException("name==null");
- }
- this.name = builder.name;
- this.value = builder.value;
- this.version = builder.version;
- this.domain = builder.domain;
- this.path = builder.path;
- }
-
/**
* Creates a new instance of {@code Cookie} by parsing the supplied string.
*
@@ -199,7 +173,13 @@ public String toString() {
*/
@Override
public int hashCode() {
- return Objects.hash(this.name, this.value, this.version, this.path, this.domain);
+ int hash = 7;
+ hash = 97 * hash + (this.name != null ? this.name.hashCode() : 0);
+ hash = 97 * hash + (this.value != null ? this.value.hashCode() : 0);
+ hash = 97 * hash + this.version;
+ hash = 97 * hash + (this.path != null ? this.path.hashCode() : 0);
+ hash = 97 * hash + (this.domain != null ? this.domain.hashCode() : 0);
+ return hash;
}
/**
@@ -219,141 +199,21 @@ public boolean equals(final Object obj) {
return false;
}
final Cookie other = (Cookie) obj;
- if (!Objects.equals(this.name, other.name)) {
+ if (this.name != other.name && (this.name == null || !this.name.equals(other.name))) {
return false;
}
- if (!Objects.equals(this.value, other.value)) {
+ if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) {
return false;
}
- if (!Objects.equals(this.version, other.version)) {
+ if (this.version != other.version) {
return false;
}
- if (!Objects.equals(this.path, other.path)) {
+ if (this.path != other.path && (this.path == null || !this.path.equals(other.path))) {
return false;
}
- if (!Objects.equals(this.domain, other.domain)) {
+ if (this.domain != other.domain && (this.domain == null || !this.domain.equals(other.domain))) {
return false;
}
return true;
}
-
- /**
- * JAX-RS {@link Cookie} builder class.
- *
- * Cookie builder provides methods that let you conveniently configure and subsequently build a new
- * {@code Cookie} instance.
- *
- * Multipart entities may be received in a resource method as a collection of
- * parts (e.g. {@code List
- * Likewise, a client may receive a multipart response by reading the returned
- * entity as a collection of EntityParts (ex: {@code response.readEntity(new
- * GenericType
- * In order to send a multipart entity either as a client request or a response
- * from a resource method, you may create the Lists using
- * {@code EntityPart.Builder}. For example:
- *
- * Logically, this is the same as {@code EntityPart.withName(x).fileName(x)}.
- *
- * The {@code InputStream} will be closed by the implementation code after
- * sending the multipart data. Closing the stream before it is sent could result
- * in unexpected behavior.
- *
- * If the content is specified using this method, then the {@link #build()}
- * method is responsible for finding a registered
- * {@link jakarta.ws.rs.ext.MessageBodyWriter} that is capable of writing the
- * object type specified here using the default {@link MediaType} or the
- * {@link MediaType} specified in the {@link #mediaType(MediaType)} or
- * {@link #mediaType(String)} methods and using any headers specified via the
- * {@link #header(String, String...)} or {@link #headers(MultivaluedMap)}
- * methods.
- *
- * If the content is specified using this method, then the {@link #build()}
- * method is responsible for finding a registered
- * {@link jakarta.ws.rs.ext.MessageBodyWriter} that is capable of writing the
- * object's class type specified here using the default {@link MediaType} or the
- * {@link MediaType} specified in the {@link #mediaType(MediaType)} or
- * {@link #mediaType(String)} methods and using any headers specified via the
- * {@link #header(String, String...)} or {@link #headers(MultivaluedMap)}
- * methods.
- *
- * This is the equivalent of calling
- * {@code content(content, content.getClass())}.
- *
- * If the content is specified using this method, then the {@link #build()}
- * method is responsible for finding a registered
- * {@link jakarta.ws.rs.ext.MessageBodyWriter} that is capable of writing the
- * object type specified here using the default {@link MediaType} or the
- * {@link MediaType} specified in the {@link #mediaType(MediaType)} or
- * {@link #mediaType(String)} methods and using any headers specified via the
- * {@link #header(String, String...)} or {@link #headers(MultivaluedMap)}
- * methods.
- *
* Get a HTTP header as a single string value.
*
- * For example: {@code containsHeaderString("cache-control", ",", "no-store"::equalsIgnoreCase)} will return {@code true} if
- * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
- * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
- * (missing comma), or the value {@code no - store} (whitespace within value).
- *
- * @param name the message header.
- * @param valueSeparatorRegex Separates the header value into single values. {@code null} does not split.
- * @param valuePredicate value must fulfil this predicate.
- * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
- * matching the predicate, or having at least one whitespace-trimmed single value in a token-separated list of single values.
- * @see #getRequestHeaders()
- * @see #getHeaderString(String)
- * @since 4.0
- */
- public boolean containsHeaderString(String name, String valueSeparatorRegex, Predicate
- * For example: {@code containsHeaderString("cache-control", "no-store"::equalsIgnoreCase)} will return {@code true} if
- * a {@code Cache-Control} header exists that has the value {@code no-store}, the value {@code No-Store} or the value
- * {@code Max-Age, NO-STORE, no-transform}, but {@code false} when it has the value {@code no-store;no-transform}
- * (missing comma), or the value {@code no - store} (whitespace within value).
- *
- * @param name the message header.
- * @param valuePredicate value must fulfil this predicate.
- * @return {@code true} if and only if a header with the given name exists, having either a whitespace-trimmed value
- * matching the predicate, or having at least one whitespace-trimmed single value in a comma-separated list of single values.
- * @see #getRequestHeaders()
- * @see #getHeaderString(String)
- * @since 4.0
- */
- public default boolean containsHeaderString(String name, Predicate
@@ -402,187 +395,4 @@ public interface Builder {
*/
public Link buildRelativized(URI uri, Object... values);
}
-
- /**
- * Value type for {@link jakarta.ws.rs.core.Link} that can be marshalled and
- * unmarshalled by JAXB.
- *
- * Note that usage of this class requires the Jakarta XML Binding API and an implementation. The Jakarta RESTful Web
- * Services implementation is not required to provide these dependencies.
- *
- * @see jakarta.ws.rs.core.Link.JaxbAdapter
- * @since 2.0
- * @deprecated
- */
- @Deprecated
- public static class JaxbLink {
-
- private URI uri;
- private Map
- * New Cookie builder provides methods that let you conveniently configure and subsequently build a new
- * {@code NewCookie} instance.
- *
- * Note that it is recommended to use {@link #maxAge(int) Max-Age} to control cookie expiration, however some browsers
- * do not understand {@code Max-Age}, in which case setting {@code Expires} parameter may be necessary.
- *
*
* @return the path segment
*/
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java
index 39c44e104..82e85d704 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Response.java
@@ -463,22 +463,6 @@ public MultivaluedMap
@@ -1189,13 +1173,6 @@ public enum Status implements StatusType {
* @since 2.0
*/
PARTIAL_CONTENT(206, "Partial Content"),
- /**
- * 300 Multiple Choices, see HTTP/1.1:
- * Semantics and Content.
- *
- * @since 3.1
- */
- MULTIPLE_CHOICES(300, "Multiple Choices"),
/**
* 301 Moved Permanently, see HTTP/1.1
* documentation.
@@ -1229,13 +1206,6 @@ public enum Status implements StatusType {
* documentation.
*/
TEMPORARY_REDIRECT(307, "Temporary Redirect"),
- /**
- * 308 Permanent Redirect, see RFC 7538:
- * The Hypertext Transfer Protocol Status Code 308 (Permanent Redirect).
- *
- * @since 3.1
- */
- PERMANENT_REDIRECT(308, "Permanent Redirect"),
/**
* 400 Bad Request, see HTTP/1.1
* documentation.
@@ -1364,13 +1334,6 @@ public enum Status implements StatusType {
* @since 2.1
*/
REQUEST_HEADER_FIELDS_TOO_LARGE(431, "Request Header Fields Too Large"),
- /**
- * 451 Unavailable For Legal Reasons, see RFC 7725:
- * An HTTP Status Code to Report Legal Obstacles.
- *
- * @since 3.1
- */
- UNAVAILABLE_FOR_LEGAL_REASONS(451, "Unavailable For Legal Reasons"),
/**
* 500 Internal Server Error, see HTTP/1.1
* documentation.
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/SecurityContext.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/SecurityContext.java
index aeabef68e..07f0f4824 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/SecurityContext.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/SecurityContext.java
@@ -18,12 +18,14 @@
import java.security.Principal;
+import jakarta.ws.rs.Entity;
+
/**
* An injectable interface that provides access to security related information.
*
* @author Paul Sandoz
* @author Marc Hadley
- * @see Context
+ * @see Entity
* @since 1.0
*/
public interface SecurityContext {
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/UriInfo.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/UriInfo.java
index 26a0a9f3a..8a2a0c9f0 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/UriInfo.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/UriInfo.java
@@ -19,6 +19,8 @@
import java.net.URI;
import java.util.List;
+import jakarta.ws.rs.Entity;
+
/**
* An injectable interface that provides access to application and request URI information. Relative URIs are relative
* to the base URI of the application, see {@link #getBaseUri}.
@@ -30,7 +32,7 @@
*
* @author Paul Sandoz
* @author Marc Hadley
- * @see Context
+ * @see Entity
* @since 1.0
*/
public interface UriInfo {
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java
index b48bc6b10..d7b98c39d 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Variant.java
@@ -19,7 +19,6 @@
import java.io.StringWriter;
import java.util.List;
import java.util.Locale;
-import java.util.Objects;
import jakarta.ws.rs.ext.RuntimeDelegate;
@@ -199,7 +198,11 @@ public static VariantListBuilder encodings(final String... encodings) {
*/
@Override
public int hashCode() {
- return Objects.hash(this.language, this.mediaType, this.encoding);
+ int hash = 7;
+ hash = 29 * hash + (this.language != null ? this.language.hashCode() : 0);
+ hash = 29 * hash + (this.mediaType != null ? this.mediaType.hashCode() : 0);
+ hash = 29 * hash + (this.encoding != null ? this.encoding.hashCode() : 0);
+ return hash;
}
/**
@@ -217,13 +220,14 @@ public boolean equals(final Object obj) {
return false;
}
final Variant other = (Variant) obj;
- if (!Objects.equals(this.language, other.language)) {
+ if (this.language != other.language && (this.language == null || !this.language.equals(other.language))) {
return false;
}
- if (!Objects.equals(this.mediaType, other.mediaType)) {
+ if (this.mediaType != other.mediaType && (this.mediaType == null || !this.mediaType.equals(other.mediaType))) {
return false;
}
- return Objects.equals(this.encoding, other.encoding);
+ // noinspection StringEquality
+ return this.encoding == other.encoding || (this.encoding != null && this.encoding.equals(other.encoding));
}
@Override
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/ext/ContextResolver.java b/jaxrs-api/src/main/java/jakarta/ws/rs/ext/ContextResolver.java
index 368d680cc..094255f58 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/ext/ContextResolver.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/ext/ContextResolver.java
@@ -16,6 +16,8 @@
package jakarta.ws.rs.ext;
+import jakarta.ws.rs.Entity;
+
/**
* Contract for a provider that supplies context information to resource classes and other providers.
*
@@ -30,7 +32,7 @@
* @param
- * This method is not intended to be invoked by applications. Call {@link SeBootstrap#start(Application,
- * SeBootstrap.Configuration)} instead.
+ * This method is not intended to be invoked by applications. Call {@link SeBootstrap#start(Application, Configuration)}
+ * instead.
*
- * This method is not intended to be invoked by applications. Call {@link SeBootstrap#start(Class,
- * SeBootstrap.Configuration)} instead.
- *
- * This method is not intended to be invoked by applications. Call {@link EntityPart#withName(String)} instead.
- *
* Subsequent calls have no effect and are ignored. Once the {@link SseEventSink} is closed, invoking any method other
* than this one and {@link #isClosed()} would result in an {@link IllegalStateException} being thrown.
- * @throws IOException if an I/O error occurs.
*/
@Override
- void close() throws IOException;
+ void close();
}
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSource.java b/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSource.java
index 7df3f1fc5..bc5f06d54 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSource.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSource.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2021 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -72,11 +72,6 @@
*
* In the case of an error condition response, the
- * Note that if, for any of the registered event consumers, an invocation of {@link Consumer#accept(Object)
- * Consumer<InboundSseEvent>#accept(InboundSseEvent)} method throws an exception, this is not an error condition.
- * Thus > entity = Entity.entity(parts, MediaType.MULTIPART_FORM_DATA);
- Response response = target.request().post(entity);
- return response.getStatus() == 200;
- }
-
- private EntityPart toPart(Path file) {
- String filename = file.getFileName().toString();
- try {
- return EntityPart.withName(filename)
- .content(filename, Files.newInputStream(file))
- .mediaType("application/pdf")
- .build();
- } catch (IOException ioex) {
- LOG.log(Level.WARNING, "Failed to process file {0}", file);
- return null;
- }
- }
-
- public List
>() { });
- return parts.stream().map(part -> {
- try (InputStream is = part.getContent()) {
- Path file = Files.createFile(Paths.get(part.getFileName().orElse(part.getName() + ".pdf")));
- Files.copy(is, file);
- return file;
- } catch (IOException ioex) {
- LOG.log(Level.WARNING, "Failed to process attachment part {0}", part);
- return null;
- }
- }).collect(Collectors.toList());
- }
-}
diff --git a/examples/src/main/java/jaxrs/examples/multipart/MultipartResource.java b/examples/src/main/java/jaxrs/examples/multipart/MultipartResource.java
deleted file mode 100644
index 4e3862670..000000000
--- a/examples/src/main/java/jaxrs/examples/multipart/MultipartResource.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************
-* Copyright (c) 2021 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.
-*******************************************************************/
-package jaxrs.examples.multipart;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.List;
-
-import jakarta.ws.rs.BadRequestException;
-import jakarta.ws.rs.Consumes;
-import jakarta.ws.rs.FormParam;
-import jakarta.ws.rs.GET;
-import jakarta.ws.rs.NotFoundException;
-import jakarta.ws.rs.NotSupportedException;
-import jakarta.ws.rs.POST;
-import jakarta.ws.rs.Path;
-import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.WebApplicationException;
-import jakarta.ws.rs.core.EntityPart;
-import jakarta.ws.rs.core.MediaType;
-import jakarta.ws.rs.core.Response;
-
-@Path("/multipart")
-public class MultipartResource {
-
- private static final String PDF_ROOT_DIR = System.getProperty("pdf.root.dir", "/myPDFs");
-
- @GET
- @Produces(MediaType.MULTIPART_FORM_DATA)
- public List
@@ -136,7 +134,7 @@ public String processCommand(String command) {
@Produces(MediaType.SERVER_SENT_EVENTS)
public void itemEvents(
@HeaderParam(HttpHeaders.LAST_EVENT_ID_HEADER) @DefaultValue("-1") int lastEventId,
- @Context SseEventSink serverSink) {
+ SseEventSink serverSink) {
if (lastEventId >= 0) {
LOGGER.info("Received last event id :" + lastEventId);
diff --git a/examples/src/main/java/jaxrs/examples/sse/ServerSentEventsResource.java b/examples/src/main/java/jaxrs/examples/sse/ServerSentEventsResource.java
index dc19a685a..903fd29c2 100644
--- a/examples/src/main/java/jaxrs/examples/sse/ServerSentEventsResource.java
+++ b/examples/src/main/java/jaxrs/examples/sse/ServerSentEventsResource.java
@@ -22,7 +22,6 @@
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
-import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.sse.Sse;
import jakarta.ws.rs.sse.SseEventSink;
@@ -48,7 +47,7 @@ public ServerSentEventsResource(Sse sse) {
@GET
@Produces(MediaType.SERVER_SENT_EVENTS)
- public void getMessageQueue(@Context SseEventSink sseEventSink) {
+ public void getMessageQueue(SseEventSink sseEventSink) {
synchronized (outputLock) {
if (this.eventSink != null) {
throw new IllegalStateException("Server sink already served.");
@@ -78,8 +77,7 @@ public void close() throws IOException {
@POST
@Path("domains/{id}")
@Produces(MediaType.SERVER_SENT_EVENTS)
- public void startDomain(@PathParam("id") final String id,
- @Context SseEventSink sseEventSink) {
+ public void startDomain(@PathParam("id") final String id, SseEventSink sseEventSink) {
executorService.submit(() -> {
try {
@@ -98,10 +96,7 @@ public void startDomain(@PathParam("id") final String id,
sseEventSink.close();
} catch (final InterruptedException e) {
e.printStackTrace();
- } catch (IOException ioe) {
- //handle I/O error
}
-
});
}
}
diff --git a/jaxrs-api/.gitignore b/jaxrs-api/.gitignore
deleted file mode 100644
index 414c06f02..000000000
--- a/jaxrs-api/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-.checkstyle
diff --git a/jaxrs-api/pom.xml b/jaxrs-api/pom.xml
index efb00c8ab..d7d6736e7 100644
--- a/jaxrs-api/pom.xml
+++ b/jaxrs-api/pom.xml
@@ -28,7 +28,7 @@
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/PathParam.java b/jaxrs-api/src/main/java/jakarta/ws/rs/PathParam.java
index 93850e82c..5c92c2019 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/PathParam.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/PathParam.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2019 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import jakarta.enterprise.util.Nonbinding;
+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
@@ -67,6 +70,7 @@
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
+@Qualifier
public @interface PathParam {
/**
@@ -80,5 +84,5 @@
*
* @return resource URI template parameter name.
*/
- String value();
+ @Nonbinding String value();
}
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/QueryParam.java b/jaxrs-api/src/main/java/jakarta/ws/rs/QueryParam.java
index 423258b29..5c68dadcd 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/QueryParam.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/QueryParam.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
@@ -22,6 +22,9 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import jakarta.enterprise.util.Nonbinding;
+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
@@ -60,6 +63,7 @@
@Target({ ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
+@Qualifier
public @interface QueryParam {
/**
@@ -70,5 +74,5 @@
*
* @return HTTP query parameter name.
*/
- String value();
+ @Nonbinding String value();
}
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/SeBootstrap.java b/jaxrs-api/src/main/java/jakarta/ws/rs/SeBootstrap.java
index 5cf909305..afbef44e5 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/SeBootstrap.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/SeBootstrap.java
@@ -16,16 +16,12 @@
package jakarta.ws.rs;
-import java.net.URI;
+import javax.net.ssl.SSLContext;
import java.util.Optional;
import java.util.concurrent.CompletionStage;
import java.util.function.BiFunction;
-import java.util.function.Consumer;
-
-import javax.net.ssl.SSLContext;
import jakarta.ws.rs.core.Application;
-import jakarta.ws.rs.core.UriBuilder;
import jakarta.ws.rs.ext.RuntimeDelegate;
/**
@@ -143,65 +139,6 @@ static CompletionStage
- * @Stateless
- * @Path("/")
- * public class MyEjbResource {
- * …
- * @GET
- * @Asynchronous
- * public void longRunningOperation(@Suspended AsyncResponse ar) {
- * ar.setTimeoutHandler(customHandler);
- * ar.setTimeout(10, TimeUnit.SECONDS);
- * final String result = executeLongRunningOperation();
- * ar.resume(result);
- * }
- *
- * private String executeLongRunningOperation() { … }
- * }
- *
- *
- * @Path("/messages/next")
- * public class MessagingResource {
- * …
- * @GET
- * public String readMessage(@Suspended AsyncResponse ar) {
- * suspended.put(ar);
- * return "This response will be ignored.";
- * }
- * …
- * }
- *
- *
- * @author Marek Potociar
- * @since 2.0
- */
-@Target({ ElementType.PARAMETER })
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-public @interface Suspended {
-}
diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Application.java b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Application.java
index f336345b9..69f5e3fe0 100644
--- a/jaxrs-api/src/main/java/jakarta/ws/rs/core/Application.java
+++ b/jaxrs-api/src/main/java/jakarta/ws/rs/core/Application.java
@@ -20,12 +20,14 @@
import java.util.Map;
import java.util.Set;
+import jakarta.ws.rs.Entity;
+
/**
* Defines the components of a JAX-RS application and supplies additional meta-data. A JAX-RS application or
* implementation supplies a concrete subclass of this abstract class.
*
- * Cookie cookie = new Cookie.Builder("name")
- * .path("/")
- * .domain("domain.com")
- * .build();
- *
- *
- * @since 3.1
- */
- public static class Builder extends AbstractCookieBuilder>() {})}).
- *
- * Client c = ClientBuilder.newClient();
- *WebTarget target = c.target(someURL);
- *List<EntityPart> parts = Arrays.asList(
- * EntityPart.withName("name1").fileName("file1.doc").content(stream1).build(),
- * EntityPart.withName("name2").fileName("file2.doc").content(stream2).build(),
- * EntityPart.withName("name3").fileName("file3.xml").content(myObject, MyClass.class).mediaType("application/xml").build());
- *GenericEntity<List<EntityPart>> genericEntity = new GenericEntity<>(parts){};
- *Entity entity = Entity.entity(genericEntity, MediaType.MULTIPART_FORM_DATA);
- *Response r = target.request().post(entity);
- *
- *
- * Note that when building a EntityPart, the name and content are required.
- * Other properties such as headers, file name, and media type are optional.
- *
- * It is the responsibility of the implementation code to close the content
- * input streams when sending the multipart content. Closing the stream before
- * the implementation has sent it could result in unexpected exceptions. It is
- * the responsibility of the calling code to close the stream when receiving the
- * multipart content.
- *
- * @since 3.1
- */
-public interface EntityPart {
-
- /**
- * Creates a new {@code EntityPart.Builder} instance.
- *
- * @param partName name of the part to create within the multipart entity
- * @return {@link Builder} for building new {@link EntityPart} instances
- */
- static Builder withName(String partName) {
- return RuntimeDelegate.getInstance().createEntityPartBuilder(partName);
- }
-
- /**
- * Creates a new {@code EntityPart.Builder} instance that sets the part
- * {@code name} and {@code fileName} to the passed in {@code partAndFileName}
- * value.
- *
- * @XmlRootElement
- * public class MyModel {
- *
- * private Link link;
- *
- * @XmlElement(name="link")
- * @XmlJavaTypeAdapter(JaxbAdapter.class)
- * public Link getLink() {
- * return link;
- * }
- * ...
- * }
- *
- *
- * Note that usage of this class requires the Jakarta XML Binding API and an implementation. The Jakarta RESTful Web
- * Services implementation is not required to provide these dependencies.
- *
- * @see jakarta.ws.rs.core.Link.JaxbLink
- * @since 2.0
- * @deprecated
- */
- @Deprecated
- public static class JaxbAdapter extends XmlAdapter
- * NewCookie cookie = new NewCookie.Builder("name")
- * .path("/")
- * .domain("domain.com")
- * .sameSite(SameSite.LAX)
- * .build();
- *
- *
- * @since 3.1
- */
- public static class Builder extends AbstractNewCookieBuilderThrowable
passed to the onError
consumer
* should be a WebApplicationException containing the invalid Response
object.
- * onError
is not invoked and event processing is not stopped.
- * Users are encouraged to handle exceptions on their own as part of the event processing logic.
*
* @author Marek Potociar
* @since 2.1
@@ -141,13 +136,6 @@ static Builder newBuilder() {
}
}
- /**
- * Set the SSE streaming endpoint.
- *
- * @param endpoint SSE streaming endpoint. Must not be {@code null}.
- * @return updated event source builder instance.
- * @throws NullPointerException in case the supplied web target is {@code null}.
- */
protected abstract Builder target(WebTarget endpoint);
/**
diff --git a/jaxrs-api/src/main/java/module-info.java b/jaxrs-api/src/main/java/module-info.java
index aa24390e0..cc23fce91 100644
--- a/jaxrs-api/src/main/java/module-info.java
+++ b/jaxrs-api/src/main/java/module-info.java
@@ -14,14 +14,11 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
-/**
- * Defines the Jakarta RESTful Web Services API
- */
module jakarta.ws.rs {
- requires static jakarta.xml.bind;
-
requires java.logging;
+ requires jakarta.inject;
+ requires jakarta.cdi;
exports jakarta.ws.rs;
exports jakarta.ws.rs.client;
@@ -34,5 +31,4 @@
uses jakarta.ws.rs.ext.RuntimeDelegate;
uses jakarta.ws.rs.sse.SseEventSource.Builder;
- opens jakarta.ws.rs.core to jakarta.xml.bind;
}
diff --git a/jaxrs-api/src/test/java/jakarta/ws/rs/SeBootstrapTest.java b/jaxrs-api/src/test/java/jakarta/ws/rs/SeBootstrapTest.java
index bc09f2e97..ba3c14132 100644
--- a/jaxrs-api/src/test/java/jakarta/ws/rs/SeBootstrapTest.java
+++ b/jaxrs-api/src/test/java/jakarta/ws/rs/SeBootstrapTest.java
@@ -1,30 +1,26 @@
package jakarta.ws.rs;
+import javax.net.ssl.SSLContext;
+import java.util.concurrent.CompletionStage;
+
+import jakarta.ws.rs.SeBootstrap;
+import jakarta.ws.rs.SeBootstrap.Configuration;
+import jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication;
+import jakarta.ws.rs.core.Application;
+import jakarta.ws.rs.ext.RuntimeDelegate;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
-import java.net.URI;
-import java.util.concurrent.CompletionStage;
-
-import javax.net.ssl.SSLContext;
-
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import jakarta.ws.rs.core.UriBuilder;
-import jakarta.ws.rs.SeBootstrap.Configuration;
-import jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication;
-import jakarta.ws.rs.core.Application;
-import jakarta.ws.rs.ext.RuntimeDelegate;
-
/**
* Unit tests for {@link SeBootstrap}
*
@@ -38,7 +34,7 @@ public final class SeBootstrapTest {
* installed RuntimeDelegate.
*/
@BeforeEach
- public void setUp() {
+ public final void setUp() {
RuntimeDelegate.setInstance(mock(RuntimeDelegate.class));
}
@@ -47,7 +43,7 @@ public void setUp() {
* use a possibly cluttered instance.
*/
@AfterEach
- public void tearDown() {
+ public final void tearDown() {
RuntimeDelegate.setInstance(null);
}
@@ -58,7 +54,7 @@ public void tearDown() {
* @since 3.1
*/
@Test
- public void shouldDelegateApplicationStartupToRuntimeDelegate() {
+ public final void shouldDelegateApplicationStartupToRuntimeDelegate() {
// given
final Application application = mock(Application.class);
final Configuration configuration = mock(Configuration.class);
@@ -73,30 +69,6 @@ public void shouldDelegateApplicationStartupToRuntimeDelegate() {
assertThat(actualCompletionStage, is(sameInstance(nativeCompletionStage)));
}
- /**
- * Assert that {@link SeBootstrap#start(Class, Configuration)} will delegate to
- * {@link RuntimeDelegate#bootstrap(Class, Configuration)}.
- *
- * @since 3.1
- */
- @Test
- public void shouldDelegateClassApplicationStartupToRuntimeDelegate() {
- // given
- final Application application = mock(Application.class);
- final Class extends Application> clazz = application.getClass();
- final Configuration configuration = mock(Configuration.class);
- @SuppressWarnings("unchecked")
- final CompletionStage