*/
private static Class<?>[] classTypeUsedInEvent =
new Class[] { CometEvent.class };
+
+
// ---------------------------------------------------- FilterChain Methods
this.support = support;
}
+
+ public boolean isAsyncSupported() {
+ boolean supported = true;
+ for (ApplicationFilterConfig config : filters) {
+ if (config!=null && config.getFilterDef()!=null) {
+ supported = supported & config.getFilterDef().isAsyncSupported();
+ }
+ }
+ return supported;
+ }
}
ApplicationFilterFactory.getInstance();
ApplicationFilterChain filterChain =
factory.createFilterChain(request, wrapper, servlet);
+
// Reset comet flag value after creating the filter chain
request.setComet(false);
+ //check filters to see if we support async or not.
+ request.setAsyncSupported(filterChain.isAsyncSupported());
// Call the filter chain for this request
// NOTE: This also calls the servlet's service() method
AtomicBoolean dispatch = (AtomicBoolean)param;
if ( rp.getStage() != org.apache.coyote.Constants.STAGE_SERVICE ) {//async handling
endpoint.processSocket(this.socket, SocketStatus.OPEN, true);
- } else {
dispatch.set(true);
+ } else {
+
}
}
}
--- /dev/null
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package async;
+
+import java.io.IOException;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
+public class Async3 extends HttpServlet {
+ protected static Log log = LogFactory.getLog(Async3.class);
+ public Async3() {
+ }
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ final AsyncContext actx = req.startAsync();
+ actx.setAsyncTimeout(30*1000);
+ actx.dispatch("/jsp/async/async3.jsp");
+ actx.complete();
+ }
+
+
+}
<servlet-name>async2</servlet-name>
<url-pattern>/async/async2</url-pattern>
</servlet-mapping>
+ <servlet>
+ <servlet-name>async3</servlet-name>
+ <servlet-class>async.Async3</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>async3</servlet-name>
+ <url-pattern>/async/async3</url-pattern>
+ </servlet-mapping>
</web-app>
--- /dev/null
+<%@page session="false"%>
+Output from async3.jsp
+Type is <%=request.getDispatcherType()%>
+Completed async 3 request at <%=new java.sql.Date(System.currentTimeMillis())%>
\ No newline at end of file
- background thread calls writes and calls complete()
<a href="<%=response.encodeURL("/examples/async/async2")%>"> Async 2 </a>
+4. Simple dispatch
+ - servlet does a startAsync()
+ - servlet calls dispatch(/path/to/jsp)
+ - servlet calls complete()
+ <a href="<%=response.encodeURL("/examples/async/async3")%>"> Async 3 </a>
3. Timeout s1
- servlet does a startAsync()