Class ApplicationHandler.FutureResponseWriter
- java.lang.Object
-
- java.util.concurrent.CompletableFuture<ContainerResponse>
-
- org.glassfish.jersey.server.ApplicationHandler.FutureResponseWriter
-
- All Implemented Interfaces:
java.util.concurrent.CompletionStage<ContainerResponse>,java.util.concurrent.Future<ContainerResponse>,ContainerResponseWriter
- Enclosing class:
- ApplicationHandler
private static class ApplicationHandler.FutureResponseWriter extends java.util.concurrent.CompletableFuture<ContainerResponse> implements ContainerResponseWriter
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
java.util.concurrent.CompletableFuture.AsynchronousCompletionTask
-
Nested classes/interfaces inherited from interface org.glassfish.jersey.server.spi.ContainerResponseWriter
ContainerResponseWriter.TimeoutHandler
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.OutputStreamoutputStreamprivate java.lang.StringrequestMethodNameprivate JerseyRequestTimeoutHandlerrequestTimeoutHandlerprivate ContainerResponseresponse
-
Constructor Summary
Constructors Modifier Constructor Description privateFutureResponseWriter(java.lang.String requestMethodName, java.io.OutputStream outputStream, java.util.concurrent.ScheduledExecutorService backgroundScheduler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommit()Commit the response & close the container response writer.booleanenableResponseBuffering()Returntrueif the entity buffering should be enabled in Jersey.voidfailure(java.lang.Throwable error)Propagate an unhandled error to the I/O container.voidsetSuspendTimeout(long time, java.util.concurrent.TimeUnit unit)Set the suspend timeout.booleansuspend(long time, java.util.concurrent.TimeUnit unit, ContainerResponseWriter.TimeoutHandler handler)Suspend the request/response processing.java.io.OutputStreamwriteResponseStatusAndHeaders(long contentLength, ContainerResponse response)Write the status and headers of the response and return an output stream for the web application to write the entity of the response.-
Methods inherited from class java.util.concurrent.CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, cancel, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
-
-
-
-
Field Detail
-
response
private ContainerResponse response
-
requestMethodName
private final java.lang.String requestMethodName
-
outputStream
private final java.io.OutputStream outputStream
-
requestTimeoutHandler
private final JerseyRequestTimeoutHandler requestTimeoutHandler
-
-
Method Detail
-
writeResponseStatusAndHeaders
public java.io.OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse response)Description copied from interface:ContainerResponseWriterWrite the status and headers of the response and return an output stream for the web application to write the entity of the response.If the response content length is declared to be greater or equal to 0, it means that the content length in bytes of the entity to be written is known, otherwise -1. I/O containers may use this value to determine whether the
"Content-Length"header can be set or utilize chunked transfer encoding.- Specified by:
writeResponseStatusAndHeadersin interfaceContainerResponseWriter- Parameters:
contentLength- greater or equal to 0 if the content length in bytes of the entity to be written is known, otherwise -1. Containers may use this value to determine whether the"Content-Length"header can be set or utilize chunked transfer encoding.response- the JAX-RS response to be written. The status and headers are obtained from the response.- Returns:
- the output stream to write the entity (if any).
-
suspend
public boolean suspend(long time, java.util.concurrent.TimeUnit unit, ContainerResponseWriter.TimeoutHandler handler)Description copied from interface:ContainerResponseWriterSuspend the request/response processing. The method returnstrueto indicate the response writer was suspended successfully. In case the provider has already been suspended earlier, the method returnsfalse.I/O container must not automatically
committhe response writer when the processing on the I/O container thread is finished and the thread is released. Instead, the Jersey runtime will make sure to manually close the container response writer instance by explicitly calling theContainerResponseWriter.commit()orContainerResponseWriter.failure(Throwable)method at some later point in time.Once suspended, the specified suspend timeout can be further updated using
ContainerResponseWriter.setSuspendTimeout(long, java.util.concurrent.TimeUnit)method.- Specified by:
suspendin interfaceContainerResponseWriter- Parameters:
time- time-out value. Value less or equal to 0, indicates that the processing is suspended indefinitely.unit- time-out time unit.handler- time-out handler to process a time-out event if it occurs.- Returns:
trueif the suspend operation completed successfully,falseotherwise.- See Also:
ContainerResponseWriter.setSuspendTimeout(long, TimeUnit),ContainerResponseWriter.commit()
-
setSuspendTimeout
public void setSuspendTimeout(long time, java.util.concurrent.TimeUnit unit)Description copied from interface:ContainerResponseWriterSet the suspend timeout. Once the container response writer is suspended, the suspend timeout value can be further updated by the method.- Specified by:
setSuspendTimeoutin interfaceContainerResponseWriter- Parameters:
time- time-out value. Value less or equal to 0, indicates that the processing is suspended indefinitely.unit- time-out time unit.
-
commit
public void commit()
Description copied from interface:ContainerResponseWriterCommit the response & close the container response writer. Indicates to the I/O container that request has been fully processed and response has been fully written. This signals the I/O container to finish the request/response processing, clean up any state, flush any streams, release resources etc.- Specified by:
commitin interfaceContainerResponseWriter- See Also:
ContainerResponseWriter.suspend(long, TimeUnit, TimeoutHandler),ContainerResponseWriter.failure(Throwable)
-
failure
public void failure(java.lang.Throwable error)
Description copied from interface:ContainerResponseWriterPropagate an unhandled error to the I/O container. Indicates to the I/O container that the request processing has finished with an error that could not be processed by the Jersey runtime. The I/O container is expected to process the exception in a container-specific way. This method also signals the I/O container to finish the request/response processing, clean up any state, flush any streams, release resources etc.- Specified by:
failurein interfaceContainerResponseWriter- Parameters:
error- unhandled request processing error.- See Also:
ContainerResponseWriter.suspend(long, TimeUnit, TimeoutHandler),ContainerResponseWriter.commit()
-
enableResponseBuffering
public boolean enableResponseBuffering()
Description copied from interface:ContainerResponseWriterReturntrueif the entity buffering should be enabled in Jersey. If enabled, the outbound entity is buffered by Jersey runtime up to a configured amount of bytes prior to being written to the output stream to determine its size that may be used to set the value of HTTP "Content-Length" header.Containers that provide it's own solution for determining the message payload size may decide to return
falseto prevent Jersey from buffering message entities unnecessarily.- Specified by:
enableResponseBufferingin interfaceContainerResponseWriter- Returns:
trueto enable entity buffering to be done by Jersey runtime,falseotherwise.
-
-