Author: remy.maucherat(a)jboss.com
Date: 2009-04-01 21:12:31 -0400 (Wed, 01 Apr 2009)
New Revision: 978
Modified:
trunk/java/org/apache/catalina/connector/Request.java
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
Log:
- Implement in real conditions the fixme comments.
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2009-04-02 00:48:01 UTC (rev
977)
+++ trunk/java/org/apache/catalina/connector/Request.java 2009-04-02 01:12:31 UTC (rev
978)
@@ -2824,7 +2824,7 @@
// ------------------------------------------ AsyncContextImpl Inner Class
- protected class AsyncContextImpl implements AsyncContext {
+ public class AsyncContextImpl implements AsyncContext {
protected ServletRequest request = null;
protected ServletResponse response = null;
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-02 00:48:01 UTC
(rev 977)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2009-04-02 01:12:31 UTC
(rev 978)
@@ -28,7 +28,6 @@
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import javax.servlet.AsyncContext;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
@@ -45,6 +44,7 @@
import org.apache.tomcat.util.log.SystemLogHandler;
import org.jboss.servlet.http.HttpEvent;
import org.jboss.servlet.http.HttpEventServlet;
+import org.jboss.servlet.http.HttpEvent.EventType;
/**
* Valve that implements the default basic behavior for the
@@ -305,7 +305,7 @@
// Release the filter chain (if any) for this request
if (filterChain != null) {
- if (request.isEventMode()) {
+ if (request.isEventMode() && !request.isAsyncStarted()) {
// If this is a event request, then the same chain will be used for the
// processing of all subsequent events.
filterChain.reuse();
@@ -421,19 +421,30 @@
(ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR,
requestPathMB);
- // FIXME: Implement async mode, which means invoking listeners or the Servlet
- // FIXME: Some async mode need creating a new filter chain
+ // FIXME: Implement async mode, which means invoking listeners or the Servlet,
etc
+ Request.AsyncContextImpl asyncContext = (Request.AsyncContextImpl)
request.getAsyncContext();
+ if (asyncContext != null) {
+ if (event.getType() == EventType.END || event.getType() == EventType.ERROR)
{
+ // Invoke the listeners with onComplete
+ // FIXME
+ } else if (event.getType() == EventType.TIMEOUT) {
+ // Invoke the listeners with onTimeout
+ // FIXME
+ } else if (asyncContext.getRunnable() != null) {
+ // Execute the runnable
+ // FIXME
+ } else if (asyncContext.getPath() != null) {
+ // Remap the request, set the dispatch attributes, create the filter
chain
+ // and invoke the Servlet
+ // FIXME: Also check how cross context works, but it is be ok to do from
here
+ // (or do another distpatcher object similar to the current request
dispatcher)
+ } else {
+ // Create the filter chain and reinvoke the same Servlet
+ // FIXME
+ }
+ return; // FIXME
+ }
- /* FIXME:
- * - If async context has path: remap and invoke Servlet
- * - If async context has runnable, invoke runnable
- * - If no path, reinvoke servlet with current filters
- * - If no event mode (and end event) invoke listeners
- * - If timeout, invoke listeners
- * - If error ?
- */
- AsyncContext asyncContext = request.getAsyncContext();
-
// Get the current (unchanged) filter chain for this request
ApplicationFilterChain filterChain =
(ApplicationFilterChain) request.getFilterChain();
@@ -500,7 +511,11 @@
// Release the filter chain (if any) for this request
if (filterChain != null) {
- filterChain.reuse();
+ if (asyncContext != null) {
+ filterChain.release();
+ } else {
+ filterChain.reuse();
+ }
}
// Deallocate the allocated servlet instance
Show replies by date