org.apache.catalina.connector
Class HttpEventImpl

java.lang.Object
  extended by org.apache.catalina.connector.HttpEventImpl
All Implemented Interfaces:
org.jboss.servlet.http.HttpEvent

public class HttpEventImpl
extends java.lang.Object
implements org.jboss.servlet.http.HttpEvent


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.servlet.http.HttpEvent
org.jboss.servlet.http.HttpEvent.EventType
 
Field Summary
protected  org.jboss.servlet.http.HttpEvent.EventType eventType
          Event type.
protected  Request request
          Associated request.
protected  Response response
          Associated response.
protected static StringManager sm
          The string manager for this package.
 
Constructor Summary
HttpEventImpl(Request request, Response response)
           
 
Method Summary
 void clear()
          Clear the event.
 void close()
          Ends the request, which marks the end of the event stream.
 javax.servlet.http.HttpServletRequest getHttpServletRequest()
          Returns the HttpServletRequest.
 javax.servlet.http.HttpServletResponse getHttpServletResponse()
          Returns the HttpServletResponse.
 org.jboss.servlet.http.HttpEvent.EventType getType()
          Returns the event type.
 boolean isReadReady()
          Returns true when data may be read from the connection (the flag becomes false if no data is available to read).
 boolean isWriteReady()
          Returns true when data may be written to the connection (the flag becomes false when the client is unable to accept data fast enough).
 void resume()
          Resume will cause the Servlet container to send a generic event to the Servlet, where the request can be processed synchronously (for example, it is possible to use this to complete the request after some asynchronous processing is done).
 void setTimeout(int timeout)
          This method sets the timeout in milliseconds of idle time on the connection.
 void setType(org.jboss.servlet.http.HttpEvent.EventType eventType)
           
 void suspend()
          Suspend processing of the connection until the configured timeout occurs, or resume() is called.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sm

protected static StringManager sm
The string manager for this package.


request

protected Request request
Associated request.


response

protected Response response
Associated response.


eventType

protected org.jboss.servlet.http.HttpEvent.EventType eventType
Event type.

Constructor Detail

HttpEventImpl

public HttpEventImpl(Request request,
                     Response response)
Method Detail

clear

public void clear()
Clear the event.


setType

public void setType(org.jboss.servlet.http.HttpEvent.EventType eventType)

close

public void close()
           throws java.io.IOException
Description copied from interface: org.jboss.servlet.http.HttpEvent
Ends the request, which marks the end of the event stream. This will send back to the client a notice that the server has no more data to send as part of this request. An END event will be sent to the Servlet.

Specified by:
close in interface org.jboss.servlet.http.HttpEvent
Throws:
java.io.IOException - if an IO exception occurs

getType

public org.jboss.servlet.http.HttpEvent.EventType getType()
Description copied from interface: org.jboss.servlet.http.HttpEvent
Returns the event type.

Specified by:
getType in interface org.jboss.servlet.http.HttpEvent
Returns:
EventType
See Also:
#EventType

getHttpServletRequest

public javax.servlet.http.HttpServletRequest getHttpServletRequest()
Description copied from interface: org.jboss.servlet.http.HttpEvent
Returns the HttpServletRequest.

Specified by:
getHttpServletRequest in interface org.jboss.servlet.http.HttpEvent
Returns:
HttpServletRequest

getHttpServletResponse

public javax.servlet.http.HttpServletResponse getHttpServletResponse()
Description copied from interface: org.jboss.servlet.http.HttpEvent
Returns the HttpServletResponse.

Specified by:
getHttpServletResponse in interface org.jboss.servlet.http.HttpEvent
Returns:
HttpServletResponse

setTimeout

public void setTimeout(int timeout)
Description copied from interface: org.jboss.servlet.http.HttpEvent
This method sets the timeout in milliseconds of idle time on the connection. The timeout is reset every time data is received from the connection. If a timeout occurs, the Servlet will receive an TIMEOUT event which will not result in automatically closing the event (the event may be closed using the close() method).

Specified by:
setTimeout in interface org.jboss.servlet.http.HttpEvent
Parameters:
timeout - The timeout in milliseconds for this connection, must be a positive value, larger than 0

isReadReady

public boolean isReadReady()
Description copied from interface: org.jboss.servlet.http.HttpEvent
Returns true when data may be read from the connection (the flag becomes false if no data is available to read). When the flag becomes false, the Servlet can attempt to read additional data, but it will block until data is available. This method is equivalent to Reader.ready() and (InputStream.available() > 0).

Specified by:
isReadReady in interface org.jboss.servlet.http.HttpEvent
Returns:
boolean true if data can be read without blocking

isWriteReady

public boolean isWriteReady()
Description copied from interface: org.jboss.servlet.http.HttpEvent
Returns true when data may be written to the connection (the flag becomes false when the client is unable to accept data fast enough). When the flag becomes false, the Servlet must stop writing data. If there's an attempt to flush additional data to the client and data still cannot be written immediately, an IOException will be thrown. If calling this method returns false, it will also request notification when the connection becomes available for writing again, and the Servlet will receive a write event.
Note: If the Servlet is not using isWriteReady, and is writing its output inside the container threads (inside the event() method processing, for example), using this method is not mandatory, and writes will block until all bytes are written.

Specified by:
isWriteReady in interface org.jboss.servlet.http.HttpEvent
Returns:
boolean true if data can be written without blocking

resume

public void resume()
Description copied from interface: org.jboss.servlet.http.HttpEvent
Resume will cause the Servlet container to send a generic event to the Servlet, where the request can be processed synchronously (for example, it is possible to use this to complete the request after some asynchronous processing is done). This also resumes read events if they have been disabled using suspend. It is then possible to call suspend again later. It is also possible to call resume without calling suspend before. This method must be called asynchronously.

Specified by:
resume in interface org.jboss.servlet.http.HttpEvent

suspend

public void suspend()
Description copied from interface: org.jboss.servlet.http.HttpEvent
Suspend processing of the connection until the configured timeout occurs, or resume() is called. In practice, this means the servlet will no longer receive read events. Reading should always be performed synchronously in the Tomcat threads unless the connection has been suspended.

Specified by:
suspend in interface org.jboss.servlet.http.HttpEvent

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2000-2009 Apache Software Foundation. All Rights Reserved.