Package org.eclipse.jetty.server
Class HttpChannelState
- java.lang.Object
-
- org.eclipse.jetty.server.HttpChannelState
-
public class HttpChannelState extends Object
Implementation of AsyncContext interface that holds the state of request-response cycle.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpChannelState.Action
The actions to take as the channel moves from state to state.static class
HttpChannelState.Async
The state of the servlet async API.static class
HttpChannelState.Interest
static class
HttpChannelState.State
The dispatched state of the HttpChannel, used to control the overall lifecycle
-
Constructor Summary
Constructors Modifier Constructor Description protected
HttpChannelState(HttpChannel channel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(javax.servlet.AsyncListener listener)
void
asyncError(Throwable failure)
protected void
cancelTimeout()
protected void
cancelTimeout(AsyncContextEvent event)
void
complete()
void
dispatch(javax.servlet.ServletContext context, String path)
protected void
error(Throwable th)
void
errorComplete()
AsyncContextEvent
getAsyncContextEvent()
Object
getAttribute(String name)
Request
getBaseRequest()
ContextHandler
getContextHandler()
HttpChannel
getHttpChannel()
javax.servlet.ServletResponse
getServletResponse()
javax.servlet.ServletResponse
getServletResponse(AsyncContextEvent event)
HttpChannelState.State
getState()
String
getStatusString()
long
getTimeout()
protected HttpChannelState.Action
handling()
boolean
isAsync()
boolean
isAsyncStarted()
boolean
isExpired()
boolean
isIdle()
boolean
isInitial()
boolean
isReadPossible()
boolean
isSuspended()
protected void
onComplete()
protected void
onError()
boolean
onReadPossible()
Called to signal that content is now available to read.boolean
onReadReady()
Called to signal that the channel is ready for a callback.void
onReadUnready()
Called to signal async read isReady() has returned false.protected void
onTimeout()
boolean
onWritePossible()
protected void
recycle()
void
removeAttribute(String name)
protected void
scheduleDispatch()
void
setAttribute(String name, Object attribute)
void
setTimeout(long ms)
void
startAsync(AsyncContextEvent event)
String
toString()
protected HttpChannelState.Action
unhandle()
Signal that the HttpConnection has finished handling the request.void
upgrade()
-
-
-
Constructor Detail
-
HttpChannelState
protected HttpChannelState(HttpChannel channel)
-
-
Method Detail
-
getState
public HttpChannelState.State getState()
-
addListener
public void addListener(javax.servlet.AsyncListener listener)
-
setTimeout
public void setTimeout(long ms)
-
getTimeout
public long getTimeout()
-
getAsyncContextEvent
public AsyncContextEvent getAsyncContextEvent()
-
getStatusString
public String getStatusString()
-
handling
protected HttpChannelState.Action handling()
- Returns:
- Next handling of the request should proceed
-
startAsync
public void startAsync(AsyncContextEvent event)
-
error
protected void error(Throwable th)
-
asyncError
public void asyncError(Throwable failure)
-
unhandle
protected HttpChannelState.Action unhandle()
Signal that the HttpConnection has finished handling the request. For blocking connectors, this call may block if the request has been suspended (startAsync called).- Returns:
- next actions be handled again (eg because of a resume that happened before unhandle was called)
-
dispatch
public void dispatch(javax.servlet.ServletContext context, String path)
-
onTimeout
protected void onTimeout()
-
complete
public void complete()
-
errorComplete
public void errorComplete()
-
onError
protected void onError()
-
onComplete
protected void onComplete()
-
recycle
protected void recycle()
-
upgrade
public void upgrade()
-
scheduleDispatch
protected void scheduleDispatch()
-
cancelTimeout
protected void cancelTimeout()
-
cancelTimeout
protected void cancelTimeout(AsyncContextEvent event)
-
isIdle
public boolean isIdle()
-
isExpired
public boolean isExpired()
-
isInitial
public boolean isInitial()
-
isSuspended
public boolean isSuspended()
-
isAsyncStarted
public boolean isAsyncStarted()
-
isAsync
public boolean isAsync()
-
getBaseRequest
public Request getBaseRequest()
-
getHttpChannel
public HttpChannel getHttpChannel()
-
getContextHandler
public ContextHandler getContextHandler()
-
getServletResponse
public javax.servlet.ServletResponse getServletResponse()
-
getServletResponse
public javax.servlet.ServletResponse getServletResponse(AsyncContextEvent event)
-
removeAttribute
public void removeAttribute(String name)
-
onReadUnready
public void onReadUnready()
Called to signal async read isReady() has returned false. This indicates that there is no content available to be consumed and that once the channel enters the ASYNC_WAIT state it will register for read interest by callingHttpChannel.onAsyncWaitForContent()
either from this method or from a subsequent call tounhandle()
.
-
onReadPossible
public boolean onReadPossible()
Called to signal that content is now available to read. If the channel is in ASYNC_WAIT state and unready (ie isReady() has returned false), then the state is changed to ASYNC_WOKEN and true is returned.- Returns:
- True IFF the channel was unready and in ASYNC_WAIT state
-
onReadReady
public boolean onReadReady()
Called to signal that the channel is ready for a callback. This is similar to callingonReadUnready()
followed byonReadPossible()
, except that as content is already available, read interest is never set.- Returns:
- true if woken
-
isReadPossible
public boolean isReadPossible()
-
onWritePossible
public boolean onWritePossible()
-
-