org.glassfish.jersey.process.internal
Interface RequestInvoker.InvocationContext

Enclosing class:
RequestInvoker

public static interface RequestInvoker.InvocationContext

Injectable invocation context that can be used to control various aspects of the invocation, e.g. the threading model.


Nested Class Summary
static class RequestInvoker.InvocationContext.Status
          Invocation context status.
 
Method Summary
 javax.ws.rs.core.Response getResponse()
          Returns default response to be send back to the client in case the suspended request invocation times out.
 RequestScope.Snapshot popRequestScope()
          Retrieve a request scope snapshot stored in the internal stack.
 void pushRequestScope(RequestScope.Snapshot snapshot)
          Store a request scope snapshot in the internal stack.
 void resume(javax.ws.rs.core.Response response)
          Resume the previously suspended request invocation with a response.
 void resume(Throwable exception)
          Resume the previously suspended request invocation with an exception.
 void setResponse(javax.ws.rs.core.Response response)
          Set the default response to be used in case the suspended request invocation times out.
 RequestInvoker.InvocationContext.Status status()
          Get the current status of the invocation context.
 Future<?> suspend()
          Suspend a request invocation.
 Future<?> suspend(long timeInMillis)
          Suspend a request invocation for up to the specified time in milliseconds.
 Future<?> suspend(long time, TimeUnit unit)
          Suspend a request invocation for up to the specified time.
 long suspesionTimeout()
          Get the remaining time to the suspension timeout in milliseconds.
 

Method Detail

pushRequestScope

void pushRequestScope(RequestScope.Snapshot snapshot)
Store a request scope snapshot in the internal stack.

Parameters:
snapshot - request scope snapshot to be stored.

popRequestScope

RequestScope.Snapshot popRequestScope()
Retrieve a request scope snapshot stored in the internal stack.

Note: the method blocks if no scope snapshot is stored and waits until a snapshot is available.

Returns:
the most recently stored request scope snapshot.

status

RequestInvoker.InvocationContext.Status status()
Get the current status of the invocation context.

Returns:
current status of the invocation context

resume

void resume(javax.ws.rs.core.Response response)
Resume the previously suspended request invocation with a response.

Parameters:
response - response to be used in the resumed invocation processing.
Throws:
IllegalStateException - in case the invocation context has not been suspended yet or has already been resumed.
See Also:
ExecutionContext.resume(Object)

resume

void resume(Throwable exception)
Resume the previously suspended request invocation with an exception.

Parameters:
exception - exception to be used in the resumed invocation processing.
Throws:
IllegalStateException - in case the invocation context has not been suspended yet or has already been resumed.
See Also:
ExecutionContext.resume(Exception)

suspend

Future<?> suspend()
Suspend a request invocation. The method is re-entrant, IOW calling the method multiple times has the same effect as calling it only once. In case the invocation has been resumed or canceled already, the call to suspend is ignored.

Returns:
future representing a handle of the suspended request invocation that can be used for querying its current state via one of the Future.isXxx() methods. The handle can also be used to cancel the invocation altogether.
See Also:
ExecutionContext.suspend()

suspend

Future<?> suspend(long timeInMillis)
Suspend a request invocation for up to the specified time in milliseconds.

If called on an already suspended invocation, the existing timeout value is overridden by a new value and the suspension timeout counter is reset. This means that the suspended invocation will time out in:

     System.currentTimeMillis() + timeInMillis
 
. In case the invocation has been resumed or canceled already, the call to suspend is ignored.

Parameters:
timeInMillis - suspension timeout in milliseconds.
Returns:
future representing a handle of the suspended request invocation that can be used for querying its current state via one of the Future.isXxx() methods. The handle can also be used to cancel the invocation altogether.
See Also:
ExecutionContext.suspend(long)

suspend

Future<?> suspend(long time,
                  TimeUnit unit)
Suspend a request invocation for up to the specified time.

If called on an already suspended invocation, the existing timeout value is overridden by a new value and the suspension timeout counter is reset. This means that the suspended invocation will time out in:

     System.currentTimeMillis() + unit.toMillis(time)
 
. In case the invocation has been resumed or canceled already, the call to suspend is ignored.

Parameters:
time - suspension timeout value.
unit - suspension timeout time unit.
Returns:
future representing a handle of the suspended request invocation that can be used for querying its current state via one of the Future.isXxx() methods. The handle can also be used to cancel the invocation altogether.
See Also:
ExecutionContext.suspend(long, TimeUnit)

suspesionTimeout

long suspesionTimeout()
Get the remaining time to the suspension timeout in milliseconds.

Returns:
the remaining time to the suspension timeout in milliseconds.

setResponse

void setResponse(javax.ws.rs.core.Response response)
Set the default response to be used in case the suspended request invocation times out.

Parameters:
response - data to be sent back to the client in case the suspended request invocation times out.
See Also:
ExecutionContext.setResponse(Object)

getResponse

javax.ws.rs.core.Response getResponse()
Returns default response to be send back to the client in case the suspended request invocation times out. The method may return null if no default response was set in the invocation context.

Returns:
default response to be sent back to the client in case the suspended request invocation times out or null if no default response was set.
See Also:
ExecutionContext.getResponse()


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.