org.jboss.resteasy.core

## Class SynchronousExecutionContext.SynchronousAsynchronousResponse

- java.lang.Object
- - org.jboss.resteasy.core.AbstractAsynchronousResponse
  - - org.jboss.resteasy.core.SynchronousExecutionContext.SynchronousAsynchronousResponse

- All Implemented Interfaces:
    AsyncResponse, ResteasyAsynchronousResponse
  Enclosing class:
    SynchronousExecutionContext

      protected class SynchronousExecutionContext.SynchronousAsynchronousResponse
      extends AbstractAsynchronousResponse

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `cancelled`

    - ### Fields inherited from class org.jboss.resteasy.core.AbstractAsynchronousResponse

      `annotations, completionCallbacks, dispatcher, method, request, response, responseFilters, timeoutHandler, writerInterceptors`

    - ### Fields inherited from interface javax.ws.rs.container.AsyncResponse

      `NO_TIMEOUT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SynchronousExecutionContext.SynchronousAsynchronousResponse(SynchronousDispatcher dispatcher, HttpRequest request, HttpResponse response)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `cancel()` Cancel the suspended request processing.
    `boolean` | `cancel(Date retryAfter)` Cancel the suspended request processing.
    `boolean` | `cancel(int retryAfter)` Cancel the suspended request processing.
    `void` | `initialRequestThreadFinished()` Callback by the initial http request thread.
    `boolean` | `isCancelled()` Check if the asynchronous response instance has been cancelled.
    `boolean` | `isDone()` Check if the processing of a request this asynchronous response instance belongs to has finished.
    `boolean` | `isSuspended()` Check if the asynchronous response instance is in a suspended state.
    `boolean` | `resume(Object entity)` Resume the suspended request processing using the provided response data.
    `boolean` | `resume(Throwable exc)` Resume the suspended request processing using the provided throwable.
    `boolean` | `setTimeout(long time, TimeUnit unit)` Set/update the suspend timeout.

    - ### Methods inherited from class org.jboss.resteasy.core.AbstractAsynchronousResponse

      `completionCallbacks, getAnnotations, getMethod, getResponseFilters, getWriterInterceptors, internalResume, internalResume, register, register, register, register, setAnnotations, setMethod, setResponseFilters, setTimeoutHandler, setWriterInterceptors`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### cancelled

          protected boolean cancelled

  - ### Constructor Detail

    - #### SynchronousExecutionContext.SynchronousAsynchronousResponse

          public SynchronousExecutionContext.SynchronousAsynchronousResponse(SynchronousDispatcher dispatcher,
                                                                     HttpRequest request,
                                                                     HttpResponse response)

  - ### Method Detail

    - #### resume

          public boolean resume(Object entity)

      Description copied from interface: `AsyncResponse`
      Resume the suspended request processing using the provided response data. The provided response data can be of any Java type that can be returned from a `JAX-RS resource method`.

      The asynchronous response must be still in a `suspended` state 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:
        `true` if the request processing has been resumed, returns `false` in case the request processing is not `suspended` and could not be resumed.
      See Also:
        `AsyncResponse.resume(Throwable)`

    - #### resume

          public boolean resume(Throwable exc)
                         throws IllegalStateException

      Description copied from interface: `AsyncResponse`
      Resume the suspended request processing using the provided throwable. For the provided throwable same rules apply as for an exception thrown by a `JAX-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:
        `true` if the response has been resumed, returns `false` in case the response is not `suspended` and could not be resumed.
      Throws:
        `IllegalStateException`
      See Also:
        `AsyncResponse.resume(Object)`

    - #### initialRequestThreadFinished

          public void initialRequestThreadFinished()

      Description copied from interface: `ResteasyAsynchronousResponse`
      Callback 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

          public boolean setTimeout(long time,
                           TimeUnit unit)
                             throws IllegalStateException

      Description copied from interface: `AsyncResponse`
      Set/update the suspend timeout.

      The new suspend timeout values override any timeout value previously specified. The asynchronous response must be still in a `suspended` state for this method to succeed.

      Parameters:
        `time` - suspend timeout value in the give time `unit`. Value lower or equal to 0 causes the context to suspend indefinitely.
        `unit` - suspend timeout value time unit.
      Returns:
        `true` if the suspend time out has been set, returns `false` in case the request processing is not in the `suspended` state.
      Throws:
        `IllegalStateException`

    - #### cancel

          public boolean cancel()

      Description copied from interface: `AsyncResponse`
      Cancel 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 a `cancel(...)` method on an asynchronous response instance that has already been cancelled or resumed has no effect and the method call is ignored while returning `true`, in case the request has been cancelled previously. Otherwise, in case the request has been resumed regularly (using a `resume(...) method`) or resumed due to a time-out, method returns `false`.

      Returns:
        `true` if the request processing has been cancelled, returns `false` in case the request processing is not `suspended` and could not be cancelled and is not `cancelled` already.
      See Also:
        `AsyncResponse.cancel(int)`, `AsyncResponse.cancel(java.util.Date)`

    - #### cancel

          public boolean cancel(int retryAfter)

      Description copied from interface: `AsyncResponse`
      Cancel 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 a `Retry-After` header 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 a `cancel(...)` method on an asynchronous response instance that has already been cancelled or resumed has no effect and the method call is ignored while returning `true`, in case the request has been cancelled previously. Otherwise, in case the request has been resumed regularly (using a `resume(...) method`) or resumed due to a time-out, method returns `false`.

      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:
        `true` if the request processing has been cancelled, returns `false` in case the request processing is not `suspended` and could not be cancelled and is not `cancelled` already.
      See Also:
        `AsyncResponse.cancel()`, `AsyncResponse.cancel(java.util.Date)`

    - #### cancel

          public boolean cancel(Date retryAfter)

      Description copied from interface: `AsyncResponse`
      Cancel 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 a `Retry-After` header 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 a `cancel(...)` method on an asynchronous response instance that has already been cancelled or resumed has no effect and the method call is ignored while returning `true`, in case the request has been cancelled previously. Otherwise, in case the request has been resumed regularly (using a `resume(...) method`) or resumed due to a time-out, method returns `false`.

      Parameters:
        `retryAfter` - a date that indicates how long the service is expected to be unavailable to the requesting client.
      Returns:
        `true` if the request processing has been cancelled, returns `false` in case the request processing is not `suspended` and could not be cancelled and is not `cancelled` already.
      See Also:
        `AsyncResponse.cancel()`, `AsyncResponse.cancel(int)`

    - #### isSuspended

          public boolean isSuspended()

      Description copied from interface: `AsyncResponse`
      Check if the asynchronous response instance is in a suspended state. Method returns `true` if this asynchronous response is still suspended and has not finished processing yet (either by resuming or canceling the response).
      Returns:
        `true` if this asynchronous response is in a suspend state, `false` otherwise.
      See Also:
        `AsyncResponse.isCancelled()`, `AsyncResponse.isDone()`

    - #### isCancelled

          public boolean isCancelled()

      Description copied from interface: `AsyncResponse`
      Check if the asynchronous response instance has been cancelled. Method returns `true` if this asynchronous response has been canceled before completion.
      Returns:
        `true` if this task was canceled before completion.
      See Also:
        `AsyncResponse.isSuspended()`, `AsyncResponse.isDone()`

    - #### isDone

          public boolean isDone()

      Description copied from interface: `AsyncResponse`
      Check if the processing of a request this asynchronous response instance belongs to has finished. Method returns `true` if 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:
        `true` if this execution context has finished processing.
      See Also:
        `AsyncResponse.isSuspended()`, `AsyncResponse.isCancelled()`

Copyright © 2014. All Rights Reserved.