|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ExecutionContext
An injectable interface that provides access to asynchronous server side request processing.
The injected execution context instance is bound to the currently processed request and can be used to@Suspend annotation
@Suspend| Method Summary | |
|---|---|
void |
cancel()
Cancel the request processing. |
Response |
getResponse()
Returns default response to be send back to the client in case the suspended request times out. |
void |
resume(Exception response)
Resume processing of the request bound to the execution context using an exception. |
void |
resume(Object response)
Resume processing of the request bound to the execution context using response data provided. |
void |
setResponse(Object response)
Set the default response to be used in case the suspended request times out. |
Future<?> |
suspend()
Programmatically suspend a request processing without explicitly specifying any timeout. |
Future<?> |
suspend(long millis)
Programmatically suspend a request processing with explicitly specified suspend timeout value in milliseconds. |
Future<?> |
suspend(long time,
TimeUnit unit)
Programmatically suspend a request processing with explicitly specified suspend timeout value and its time unit. |
| Method Detail |
|---|
void resume(Object response)
JAX-RS resource method.
The processing of the data by JAX-RS framework follows the same path as
it would for the response data returned synchronously by a JAX-RS resource
method.
response - data to be sent back in response to the suspended request.
IllegalStateException - in case the request has already been resumed
or has been canceled previously.resume(java.lang.Exception)void resume(Exception response)
JAX-RS resource method.
The processing of the exception by JAX-RS framework follows the same path as
it would for the exception thrown by a JAX-RS resource method.
response - an exception to be raised in response to the suspended request.
IllegalStateException - in case the request has already been resumed
or has been canceled previously.resume(java.lang.Object)Future<?> suspend()
JAX-RS resource method.
Any response value returned from a resource method in which the request
processing has been suspended is ignored by the framework.
The effective suspend timeout value is calculated using the following
mechanism:
Suspend.NEVER@Suspend annotation on
the enclosing JAX-RS resource method, the effective timeout value is
updated to the value of @Suspend.timeOut
converted into milliseconds using the value of
@Suspend.timeUnitgetResponse() method. Should the getResponse()
return null, WebApplicationException is raised with a HTTP
503 error status (Service unavailable). Use setResponse(java.lang.Object)
method to customize the default timeout response.
Future.isXxx() methods.
Invoking any other method on the returned Future instance is
not defined and reserved for future extensions of JAX-RS API.
IllegalStateException - in case the request has already been suspended,
resumed or has been canceled previously.suspend(long),
suspend(long, java.util.concurrent.TimeUnit),
setResponse(java.lang.Object)Future<?> suspend(long millis)
JAX-RS resource method.
Any response value returned from a resource method in which the request
processing has been suspended is ignored by the framework.
The specified timeout value overrides default
timeout value as well as any timeout value specified declaratively for the enclosing resource method.
If the request processing is suspended with a positive timeout value, the
processing will be resumed once the specified timeout threshold is reached
provided the request processing was not explicitly resumed before the
suspending has expired. The request processing will be resumed using response
data returned by getResponse() method. Should the getResponse()
return null, WebApplicationException is raised with a HTTP
503 error status (Service unavailable). Use setResponse(java.lang.Object)
method to customize the default timeout response.
Note that in some concurrent scenarios a call to resume(...) may
occur before the call to suspend(...). In which case the call to
suspend(...) is ignored. The returned response future
will be marked as done.
millis - suspend timeout value in milliseconds.
Future.isXxx() methods.
Invoking any other method on the returned Future instance is
not defined and reserved for future extensions of JAX-RS API.
IllegalStateException - in case the request has already been suspended
or has been canceled previously.suspend(),
suspend(long, java.util.concurrent.TimeUnit),
setResponse(java.lang.Object)
Future<?> suspend(long time,
TimeUnit unit)
JAX-RS resource method.
Any response value returned from a resource method in which the request
processing has been suspended is ignored by the framework.
The specified timeout value overrides default
timeout value as well as any timeout value specified declaratively for the enclosing resource method.
If the request processing is suspended with a positive timeout value, the
processing will be resumed once the specified timeout threshold is reached
provided the request processing was not explicitly resumed before the
suspending has expired. The request processing will be resumed using response
data returned by getResponse() method. Should the getResponse()
return null, WebApplicationException is raised with a HTTP
503 error status (Service unavailable). Use setResponse(java.lang.Object)
method to customize the default timeout response.
Note that in some concurrent scenarios a call to resume(...) may
occur before the call to suspend(...). In which case the call to
suspend(...) is ignored. The returned response future
will be marked as done.
time - suspend timeout value in the give time unit.unit - suspend timeout value time unit
Future.isXxx() methods.
Invoking any other method on the returned Future instance is
not defined and reserved for future extensions of JAX-RS API.
IllegalStateException - in case the request has already been suspended
or has been canceled previously.suspend(),
suspend(long, java.util.concurrent.TimeUnit),
setResponse(java.lang.Object)void cancel()
IllegalStateException being thrown.
void setResponse(Object response)
JAX-RS resource method.
If used, the processing of the data by JAX-RS framework follows the same
path as it would for the response data returned synchronously by a JAX-RS
resource method.
response - data to be sent back to the client in case the suspended
request times out.getResponse()Response getResponse()
null if no default response
was set in the execution context.
null if no default response was set.setResponse(java.lang.Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||