*/
public static final boolean IS_SECURITY_ENABLED =
(System.getSecurityManager() != null);
-
+
+ /**
+ *
+ */
+ public static final String ASYNC_SUPPORTED_ATTR =
+ "org.apache.catalina.ASYNC_SUPPORTED";
}
import javax.servlet.AsyncContext;
import javax.servlet.AsyncListener;
+import javax.servlet.DispatcherType;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Context;
+import org.apache.catalina.Globals;
import org.apache.coyote.ActionCode;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
final HttpServletResponse servletResponse = (HttpServletResponse)getResponse();
Runnable run = new Runnable() {
public void run() {
+ DispatcherType type = (DispatcherType)request.getAttribute(Globals.DISPATCHER_TYPE_ATTR);
try {
//piggy back on the request dispatcher to ensure that filters etc get called.
//TODO SERVLET3 - async should this be include/forward or a new dispatch type
//javadoc suggests include with the type of DispatcherType.ASYNC
+ request.setAttribute(Globals.DISPATCHER_TYPE_ATTR, DispatcherType.ASYNC);
requestDispatcher.include(servletRequest, servletResponse);
}catch (Exception x) {
//log.error("Async.dispatch",x);
throw new RuntimeException(x);
+ }finally {
+ request.setAttribute(Globals.DISPATCHER_TYPE_ATTR, type);
}
}
};
boolean success = true;
try {
- DispatcherType prevDispatcherType = request.getDispatcherType();
- request.setAttribute(Globals.DISPATCHER_TYPE_ATTR, DispatcherType.ASYNC);
// Calling the container
try {
if (status==SocketStatus.TIMEOUT) {
}catch (RuntimeException x) {
success = false;
} finally {
- request.setAttribute(Globals.DISPATCHER_TYPE_ATTR, prevDispatcherType);
}
if (request.isComet()) {
protected String localName = null;
/**
- * asyncSupported
- */
- protected boolean asyncSupported = true;
-
- /**
* AsyncContext
*/
protected AsyncContextImpl asyncContext = null;
*/
protected long asyncTimeout = 0;
+ protected Boolean asyncSupported = null;
+
// --------------------------------------------------------- Public Methods
public void setAsyncSupported(boolean asyncSupported) {
- this.asyncSupported = asyncSupported;
+ asyncSupported = asyncSupported?Boolean.TRUE:Boolean.FALSE;
}
/**
}
}
- asyncSupported = true;
+ asyncSupported = null;
if (asyncContext!=null) asyncContext.recycle();
}
? getRequestPathMB().toString()
: requestDispatcherPath.toString();
}
+
+ if (name.equals(Globals.ASYNC_SUPPORTED_ATTR)) {
+ return isAsyncSupported();
+ }
Object attr=attributes.get(name);
requestDispatcherPath = value;
return;
}
+
+ if (name.equals(Globals.ASYNC_SUPPORTED_ATTR)) {
+ this.asyncSupported = (Boolean)value;
+ }
Object oldValue = null;
boolean replaced = false;
public boolean isAsyncSupported() {
// TODO SERVLET3 - async
- return this.asyncSupported;
+ if (this.asyncSupported==null) {
+ return true;
+ } else {
+ return asyncSupported.booleanValue();
+ }
}
public AsyncContext getAsyncContext() {
import org.apache.catalina.connector.Response;
import org.apache.catalina.connector.ResponseFacade;
import org.apache.catalina.util.InstanceSupport;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
import org.apache.tomcat.util.res.StringManager;
/**
final class ApplicationDispatcher
implements RequestDispatcher {
+ protected static Log log = LogFactory.getLog(ApplicationDispatcher.class);
protected class PrivilegedForward
implements PrivilegedExceptionAction<Void> {
ApplicationFilterFactory factory = ApplicationFilterFactory.getInstance();
ApplicationFilterChain filterChain = factory.createFilterChain(request,
wrapper,servlet);
+
+ Object asyncSupported = request.getAttribute(Globals.ASYNC_SUPPORTED_ATTR);
+ //we have a new filter chain, setup isAsyncSupported here
+ boolean filterAsyncSupported = filterChain.isAsyncSupported();
+ if (!filterAsyncSupported && request.isAsyncSupported()) {
+ //the request says we support it, but the filters don't
+ //TODO SERVLET3 - async
+ request.setAttribute(Globals.ASYNC_SUPPORTED_ATTR, Boolean.FALSE);
+ }
+
// Call the service() method for the allocated servlet instance
try {
String jspFile = wrapper.getJspFile();
wrapper.getLogger().error(sm.getString("applicationDispatcher.serviceException",
wrapper.getName()), e);
runtimeException = e;
+ } finally {
+ request.setAttribute(Globals.ASYNC_SUPPORTED_ATTR, asyncSupported);
}
// Release the filter chain (if any) for this request
}
}
-
-
+
/**
* Unwrap the response if we have wrapped it.
*/
* Special attributes.
*/
protected Object[] specialAttributes = new Object[specials.length];
-
+
// ------------------------------------------------- ServletRequest Methods
this.queryParamString = queryString;
}
-
// ------------------------------------------------------ Protected Methods
-
/**
* Is this attribute name one of the special ones that is added only for
* included servlets?