Author: fhanik
Date: Thu Jul 13 08:12:56 2006
New Revision: 421645
URL: http://svn.apache.org/viewvc?rev=421645&view=rev
Log:
Add optional comet timeout support
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/catalina/CometProcessor.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CometServlet.java
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/CometProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/CometProcessor.java?rev=421645&r1=421644&r2=421645&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/CometProcessor.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/CometProcessor.java Thu Jul
13 08:12:56 2006
@@ -88,7 +88,7 @@
* Reader may be used to determine if there is a risk of blocking: the
servlet
* should read while data is reported available, and can make one
additional read
* without blocking. When encountering a read error or an EOF, the servlet
MUST
- * report it by either returning null or throwing an exception such as an
+ * report it by either returning false or throwing an exception such as an
* IOException. This will cause the error method to be invoked, and the
connection
* will be closed. It is not allowed to attempt reading data from the
request object
* outside of the execution of this method.
@@ -104,5 +104,28 @@
*/
public boolean read(HttpServletRequest request, HttpServletResponse
response)
throws IOException, ServletException;
+
+ /**
+ * Sets the timeout for this Comet connection. Please NOTE, that the
implementation
+ * of a per connection timeout is OPTIONAL and MAY NOT be implemented.<br/>
+ * 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 or
data is flushed
+ * using <code>response.flushBuffer()</code>. If a timeout occurs, the
+ * <code>error(HttpServletRequest, HttpServletResponse)</code> method is
invoked. The
+ * web application SHOULD NOT attempt to reuse the request and response
objects after a timeout
+ * as the <code>error(HttpServletRequest, HttpServletResponse)</code>
method indicates.<br/>
+ * This method should not be called asynchronously, as that will have no
effect.
+ * @param request The HTTP servlet request instance
+ * @param response The HTTP servlet response instance
+ * @param timeout The timeout in milliseconds for this connection
+ * @throws IOException An IOException may be thrown to indicate an IO
error,
+ * or that the EOF has been reached on the connection
+ * @throws ServletException An exception has occurred, as specified by the
root
+ * cause
+ * @throws UnsupportedOperationException if per connection timeout is not
supported, either at all or at this phase
+ * of the invocation.
+ */
+ public void setTimeout(HttpServletRequest request, HttpServletResponse
response, int timeout)
+ throws IOException, ServletException, UnsupportedOperationException;
}
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CometServlet.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CometServlet.java?rev=421645&r1=421644&r2=421645&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CometServlet.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CometServlet.java
Thu Jul 13 08:12:56 2006
@@ -86,7 +86,16 @@
}
}
}
-
}
+
+ public void setTimeout(HttpServletRequest request, HttpServletResponse
response, int timeout)
+ throws IOException, ServletException, UnsupportedOperationException {
+ if (request.getAttribute("org.apache.tomcat.comet.timeout.support") ==
Boolean.TRUE) {
+ request.setAttribute("org.apache.tomcat.comet.timeout",new
Integer(timeout));
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]