Author: fhanik Date: Thu Aug 6 19:34:34 2009 New Revision: 801789 URL: http://svn.apache.org/viewvc?rev=801789&view=rev Log: One more use case
Added: tomcat/trunk/webapps/examples/WEB-INF/classes/async/Async3.java (with props) tomcat/trunk/webapps/examples/jsp/async/async3.jsp (with props) Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterChain.java tomcat/trunk/java/org/apache/catalina/core/StandardWrapperValve.java tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java tomcat/trunk/webapps/examples/WEB-INF/web.xml tomcat/trunk/webapps/examples/jsp/async/index.jsp Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterChain.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterChain.java?rev=801789&r1=801788&r2=801789&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterChain.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterChain.java Thu Aug 6 19:34:34 2009 @@ -160,6 +160,8 @@ */ private static Class<?>[] classTypeUsedInEvent = new Class[] { CometEvent.class }; + + // ---------------------------------------------------- FilterChain Methods @@ -570,6 +572,16 @@ 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; + } } Modified: tomcat/trunk/java/org/apache/catalina/core/StandardWrapperValve.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardWrapperValve.java?rev=801789&r1=801788&r2=801789&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/StandardWrapperValve.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/StandardWrapperValve.java Thu Aug 6 19:34:34 2009 @@ -196,8 +196,11 @@ 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 Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java?rev=801789&r1=801788&r2=801789&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProcessor.java Thu Aug 6 19:34:34 2009 @@ -1326,8 +1326,9 @@ 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 { + } } } Added: tomcat/trunk/webapps/examples/WEB-INF/classes/async/Async3.java URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/async/Async3.java?rev=801789&view=auto ============================================================================== --- tomcat/trunk/webapps/examples/WEB-INF/classes/async/Async3.java (added) +++ tomcat/trunk/webapps/examples/WEB-INF/classes/async/Async3.java Thu Aug 6 19:34:34 2009 @@ -0,0 +1,44 @@ +/* +* 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(); + } + + +} Propchange: tomcat/trunk/webapps/examples/WEB-INF/classes/async/Async3.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/webapps/examples/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/web.xml?rev=801789&r1=801788&r2=801789&view=diff ============================================================================== --- tomcat/trunk/webapps/examples/WEB-INF/web.xml (original) +++ tomcat/trunk/webapps/examples/WEB-INF/web.xml Thu Aug 6 19:34:34 2009 @@ -320,4 +320,12 @@ <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> Added: tomcat/trunk/webapps/examples/jsp/async/async3.jsp URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/jsp/async/async3.jsp?rev=801789&view=auto ============================================================================== --- tomcat/trunk/webapps/examples/jsp/async/async3.jsp (added) +++ tomcat/trunk/webapps/examples/jsp/async/async3.jsp Thu Aug 6 19:34:34 2009 @@ -0,0 +1,4 @@ +<%...@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 Propchange: tomcat/trunk/webapps/examples/jsp/async/async3.jsp ------------------------------------------------------------------------------ svn:eol-style = native Modified: tomcat/trunk/webapps/examples/jsp/async/index.jsp URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/jsp/async/index.jsp?rev=801789&r1=801788&r2=801789&view=diff ============================================================================== --- tomcat/trunk/webapps/examples/jsp/async/index.jsp (original) +++ tomcat/trunk/webapps/examples/jsp/async/index.jsp Thu Aug 6 19:34:34 2009 @@ -18,6 +18,11 @@ - 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() --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org