Class SynchronousExecutionContext.SynchronousAsynchronousResponse
- All Implemented Interfaces:
AsyncResponse,ResourceMethodInvokerAwareResponse,ResteasyAsynchronousResponse
- Enclosing class:
- SynchronousExecutionContext
-
Field Summary
FieldsFields inherited from class org.jboss.resteasy.core.AbstractAsynchronousResponse
annotations, asyncWriterInterceptors, completionCallbacks, contextDataMap, dispatcher, method, request, response, responseFilters, timeoutHandler, writerInterceptorsFields inherited from interface jakarta.ws.rs.container.AsyncResponse
NO_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionSynchronousAsynchronousResponse(SynchronousDispatcher dispatcher, HttpRequest request, HttpResponse response) -
Method Summary
Modifier and TypeMethodDescriptionbooleancancel()Cancel the suspended request processing.booleancancel(int retryAfter) Cancel the suspended request processing.booleanCancel the suspended request processing.voidcomplete()voidCallback by the initial http request thread.booleanCheck if the asynchronous response instance has been cancelled.booleanisDone()Check if the processing of a request this asynchronous response instance belongs to has finished.booleanCheck if the asynchronous response instance is in a suspended state.booleanResume the suspended request processing using the provided response data.booleanResume the suspended request processing using the provided throwable.booleansetTimeout(long time, TimeUnit unit) Set/update the suspend timeout.Methods inherited from class org.jboss.resteasy.core.AbstractAsynchronousResponse
completionCallbacks, getAnnotations, getAsyncWriterInterceptors, getMethod, getResponseFilters, getWriterInterceptors, internalResume, internalResume, internalResume, internalResume, register, register, register, register, setAnnotations, setMethod, setResponseFilters, setTimeoutHandler, setWriterInterceptors
-
Field Details
-
cancelled
protected boolean cancelled
-
-
Constructor Details
-
SynchronousAsynchronousResponse
public SynchronousAsynchronousResponse(SynchronousDispatcher dispatcher, HttpRequest request, HttpResponse response)
-
-
Method Details
-
complete
public void complete() -
resume
Description copied from interface:AsyncResponseResume the suspended request processing using the provided response data. The provided response data can be of any Java type that can be returned from aJAX-RS resource method.The asynchronous response must be still in a
suspendedstate for this method to succeed.By executing this method, the request is guaranteed to complete either successfully or with an error. The data processing by the JAX-RS runtime follows the same path as it would for the response data returned synchronously by a JAX-RS resource, except that unmapped exceptions are not re-thrown by JAX-RS runtime to be handled by a hosting I/O container. Instead, any unmapped exceptions are propagated to the hosting I/O container via a container-specific callback mechanism. Depending on the container implementation, propagated unmapped exceptions typically result in an error status being sent to the client and/or the connection being closed.
- Parameters:
entity- data to be sent back in response to the suspended request.- Returns:
trueif the request processing has been resumed, returnsfalsein case the request processing is notsuspendedand could not be resumed.- See Also:
-
resume
Description copied from interface:AsyncResponseResume the suspended request processing using the provided throwable. For the provided throwable same rules apply as for an exception thrown by aJAX-RS resource method.By executing this method, the request is guaranteed to complete either successfully or with an error. The throwable processing by the JAX-RS runtime follows the same path as it would for the response data returned synchronously by a JAX-RS resource, except that unmapped exceptions are not re-thrown by JAX-RS runtime to be handled by a hosting I/O container. Instead, any unmapped exceptions are propagated to the hosting I/O container via a container-specific callback mechanism. Depending on the container implementation, propagated unmapped exceptions typically result in an error status being sent to the client and/or the connection being closed.
- Parameters:
exc- an exception to be raised in response to the suspended request.- Returns:
trueif the response has been resumed, returnsfalsein case the response is notsuspendedand could not be resumed.- Throws:
IllegalStateException- See Also:
-
initialRequestThreadFinished
public void initialRequestThreadFinished()Description copied from interface:ResteasyAsynchronousResponseCallback by the initial http request thread. It is used to help simulate suspend/resume asynchronous semantics in containers that do not support asychronous HTTP. This method is a no-op in environments that support async HTTP. -
setTimeout
Description copied from interface:AsyncResponseSet/update the suspend timeout.The new suspend timeout values override any timeout value previously specified. The asynchronous response must be still in a
suspendedstate for this method to succeed.- Parameters:
time- suspend timeout value in the give timeunit. Value lower or equal to 0 causes the context to suspend indefinitely.unit- suspend timeout value time unit.- Returns:
trueif the suspend time out has been set, returnsfalsein case the request processing is not in thesuspendedstate.- Throws:
IllegalStateException
-
cancel
public boolean cancel()Description copied from interface:AsyncResponseCancel the suspended request processing.When a request processing is cancelled using this method, the JAX-RS implementation MUST indicate to the client that the request processing has been cancelled by sending back a
HTTP 503 (Service unavailable)error response.Invoking a
cancel(...)method multiple times to cancel request processing has the same effect as canceling the request processing only once. Invoking acancel(...)method on an asynchronous response instance that has already been cancelled or resumed has no effect and the method call is ignored while returningtrue, in case the request has been cancelled previously. Otherwise, in case the request has been resumed regularly (using aresume(...) method) or resumed due to a time-out, method returnsfalse. -
cancel
public boolean cancel(int retryAfter) Description copied from interface:AsyncResponseCancel the suspended request processing.When a request processing is cancelled using this method, the JAX-RS implementation MUST indicate to the client that the request processing has been cancelled by sending back a
HTTP 503 (Service unavailable)error response with aRetry-Afterheader set to the value provided by the method parameter.Invoking a
cancel(...)method multiple times to cancel request processing has the same effect as canceling the request processing only once. Invoking acancel(...)method on an asynchronous response instance that has already been cancelled or resumed has no effect and the method call is ignored while returningtrue, in case the request has been cancelled previously. Otherwise, in case the request has been resumed regularly (using aresume(...) method) or resumed due to a time-out, method returnsfalse.- Parameters:
retryAfter- a decimal integer number of seconds after the response is sent to the client that indicates how long the service is expected to be unavailable to the requesting client.- Returns:
trueif the request processing has been cancelled, returnsfalsein case the request processing is notsuspendedand could not be cancelled and is notcancelledalready.- See Also:
-
cancel
Description copied from interface:AsyncResponseCancel the suspended request processing.When a request processing is cancelled using this method, the JAX-RS implementation MUST indicate to the client that the request processing has been cancelled by sending back a
HTTP 503 (Service unavailable)error response with aRetry-Afterheader set to the value provided by the method parameter.Invoking a
cancel(...)method multiple times to cancel request processing has the same effect as canceling the request processing only once. Invoking acancel(...)method on an asynchronous response instance that has already been cancelled or resumed has no effect and the method call is ignored while returningtrue, in case the request has been cancelled previously. Otherwise, in case the request has been resumed regularly (using aresume(...) method) or resumed due to a time-out, method returnsfalse.- Parameters:
retryAfter- a date that indicates how long the service is expected to be unavailable to the requesting client.- Returns:
trueif the request processing has been cancelled, returnsfalsein case the request processing is notsuspendedand could not be cancelled and is notcancelledalready.- See Also:
-
isSuspended
public boolean isSuspended()Description copied from interface:AsyncResponseCheck if the asynchronous response instance is in a suspended state. Method returnstrueif this asynchronous response is still suspended and has not finished processing yet (either by resuming or canceling the response).- Returns:
trueif this asynchronous response is in a suspend state,falseotherwise.- See Also:
-
isCancelled
public boolean isCancelled()Description copied from interface:AsyncResponseCheck if the asynchronous response instance has been cancelled. Method returnstrueif this asynchronous response has been canceled before completion.- Returns:
trueif this task was canceled before completion.- See Also:
-
isDone
public boolean isDone()Description copied from interface:AsyncResponseCheck if the processing of a request this asynchronous response instance belongs to has finished. Method returnstrueif the processing of a request this asynchronous response is bound to is finished.The request processing may be finished due to a normal termination, a suspend timeout, or cancellation -- in all of these cases, this method will return
true.- Returns:
trueif this execution context has finished processing.- See Also:
-