org.directwebremoting.dwrp
Class JettyContinuationSleeper

java.lang.Object
  extended by org.directwebremoting.dwrp.JettyContinuationSleeper

public class JettyContinuationSleeper
extends java.lang.Object

A Sleeper that works with Jetty Continuations

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Field Summary
static java.lang.String ATTRIBUTE_JETTY_CONDUIT
          We remember the notify conduit so we can reuse it
protected  Continuation continuation
          The continuation object
protected  boolean resumed
          Has the continuation been restarted already?
 
Constructor Summary
JettyContinuationSleeper(HttpServletRequest request)
           
 
Method Summary
 void goToSleep(java.lang.Runnable awakening)
          'halt' the current execution in some way.
static boolean isRestart(HttpServletRequest request)
          Is this a restarted continuation?
static void restart(HttpServletRequest request)
          Act on a restarted continuation by executing the onAwakening action
 void wakeUp()
          This method should attempt to resume the execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

continuation

protected final Continuation continuation
The continuation object


resumed

protected boolean resumed
Has the continuation been restarted already?


ATTRIBUTE_JETTY_CONDUIT

public static final java.lang.String ATTRIBUTE_JETTY_CONDUIT
We remember the notify conduit so we can reuse it

See Also:
Constant Field Values
Constructor Detail

JettyContinuationSleeper

public JettyContinuationSleeper(HttpServletRequest request)
Parameters:
request - The request into which we store this as an attribute
Method Detail

isRestart

public static boolean isRestart(HttpServletRequest request)
Is this a restarted continuation?

Parameters:
request - The request on which a Sleeper might be stored
Returns:
true if this request is from a restarted Continuation

restart

public static void restart(HttpServletRequest request)
Act on a restarted continuation by executing the onAwakening action

Parameters:
request - The request on which the Sleeper is stored

goToSleep

public void goToSleep(java.lang.Runnable awakening)
'halt' the current execution in some way. This method should be the last meaningful thing that is done on a request, and work that needs to be done before completion should be done in a Runnable so the system can schedule it at an appropriate time.

Parameters:
awakening - The action to take when wakeUp() is called

wakeUp

public void wakeUp()
This method should attempt to resume the execution. It is possible that this method will be called more than once at the same time so Sleepers should be prepared take steps to be woken only once.