org.directwebremoting.util
Class Continuation

java.lang.Object
  extended by org.directwebremoting.util.Continuation

public class Continuation
extends java.lang.Object

A wrapper around Jetty Ajax Continuations

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

Field Summary
protected static java.lang.Class continuationClass
          Jetty code used by reflection to allow it to run outside of Jetty
protected static java.lang.reflect.Method getObject
          How we get the associated continuation object
protected static boolean isJetty
          Are we using Jetty at all?
protected static java.lang.reflect.Method resumeMethod
          How we resume the continuation
protected static java.lang.reflect.Method setObject
          How we set the associated continuation object
protected static java.lang.reflect.Method suspendMethod
          How we suspend the continuation
 
Constructor Summary
Continuation(HttpServletRequest request)
          Fish the Jetty continuation out of the request if it exists
 
Method Summary
 java.lang.Object getObject()
          Accessor for the object associated with this continuation
 boolean isAvailable()
          Are continuations working? If this method returns false then all the other methods will fail.
static boolean isJetty()
           
 void resume()
          Resume an continuation.
static void rethrowIfContinuation(java.lang.Throwable th)
          We shouldn't be catching Jetty RetryRequests so we rethrow them.
 void setObject(java.lang.Object object)
          Accessor for the object associated with this continuation
 void suspend(long sleepTime)
          Suspend the thread for a maximum of sleepTime milliseconds
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

continuationClass

protected static java.lang.Class continuationClass
Jetty code used by reflection to allow it to run outside of Jetty


suspendMethod

protected static java.lang.reflect.Method suspendMethod
How we suspend the continuation


resumeMethod

protected static java.lang.reflect.Method resumeMethod
How we resume the continuation


getObject

protected static java.lang.reflect.Method getObject
How we get the associated continuation object


setObject

protected static java.lang.reflect.Method setObject
How we set the associated continuation object


isJetty

protected static boolean isJetty
Are we using Jetty at all?

Constructor Detail

Continuation

public Continuation(HttpServletRequest request)
Fish the Jetty continuation out of the request if it exists

Parameters:
request - The http request
Method Detail

isAvailable

public boolean isAvailable()
Are continuations working? If this method returns false then all the other methods will fail.

Returns:
true if Jetty continuations are working

suspend

public void suspend(long sleepTime)
             throws java.lang.Exception
Suspend the thread for a maximum of sleepTime milliseconds

Parameters:
sleepTime - The maximum time to wait
Throws:
java.lang.Exception - If reflection breaks

resume

public void resume()
            throws java.lang.Exception
Resume an continuation. For Jetty: does not work like a real continuation because it restarts the http request.

Throws:
java.lang.Exception - If reflection breaks

getObject

public java.lang.Object getObject()
                           throws java.lang.Exception
Accessor for the object associated with this continuation

Returns:
the object associated with this continuation
Throws:
java.lang.Exception - If reflection breaks

setObject

public void setObject(java.lang.Object object)
               throws java.lang.Exception
Accessor for the object associated with this continuation

Parameters:
object - the object associated with this continuation
Throws:
java.lang.Exception - If reflection breaks

rethrowIfContinuation

public static void rethrowIfContinuation(java.lang.Throwable th)
We shouldn't be catching Jetty RetryRequests so we rethrow them.

Parameters:
th - The exception to test for continuation-ness

isJetty

public static boolean isJetty()
Returns:
True if we have detected Continuation classes