From: fhanik Date: Thu, 6 Aug 2009 19:34:34 +0000 (+0000) Subject: One more use case X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a52bd4173f9447f71ed58934fa6166ce67695ab4;p=tomcat7.0 One more use case git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@801789 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/core/ApplicationFilterChain.java b/java/org/apache/catalina/core/ApplicationFilterChain.java index c2790c4ba..2b577a96f 100644 --- a/java/org/apache/catalina/core/ApplicationFilterChain.java +++ b/java/org/apache/catalina/core/ApplicationFilterChain.java @@ -160,6 +160,8 @@ final class ApplicationFilterChain implements FilterChain, CometFilterChain { */ private static Class[] classTypeUsedInEvent = new Class[] { CometEvent.class }; + + // ---------------------------------------------------- FilterChain Methods @@ -570,6 +572,16 @@ final class ApplicationFilterChain implements FilterChain, CometFilterChain { 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; + } } diff --git a/java/org/apache/catalina/core/StandardWrapperValve.java b/java/org/apache/catalina/core/StandardWrapperValve.java index 049aee1ad..2f0b266ba 100644 --- a/java/org/apache/catalina/core/StandardWrapperValve.java +++ b/java/org/apache/catalina/core/StandardWrapperValve.java @@ -196,8 +196,11 @@ final class StandardWrapperValve 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 diff --git a/java/org/apache/coyote/http11/Http11NioProcessor.java b/java/org/apache/coyote/http11/Http11NioProcessor.java index 5926147c7..aadcd75d0 100644 --- a/java/org/apache/coyote/http11/Http11NioProcessor.java +++ b/java/org/apache/coyote/http11/Http11NioProcessor.java @@ -1326,8 +1326,9 @@ public class Http11NioProcessor implements ActionHook { 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 { + } } } diff --git a/webapps/examples/WEB-INF/classes/async/Async3.java b/webapps/examples/WEB-INF/classes/async/Async3.java new file mode 100644 index 000000000..1d4a7e117 --- /dev/null +++ b/webapps/examples/WEB-INF/classes/async/Async3.java @@ -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(); + } + + +} diff --git a/webapps/examples/WEB-INF/web.xml b/webapps/examples/WEB-INF/web.xml index dd51c027e..ea64cb2fd 100644 --- a/webapps/examples/WEB-INF/web.xml +++ b/webapps/examples/WEB-INF/web.xml @@ -320,4 +320,12 @@ async2 /async/async2 + + async3 + async.Async3 + + + async3 + /async/async3 + diff --git a/webapps/examples/jsp/async/async3.jsp b/webapps/examples/jsp/async/async3.jsp new file mode 100644 index 000000000..089a034ae --- /dev/null +++ b/webapps/examples/jsp/async/async3.jsp @@ -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 diff --git a/webapps/examples/jsp/async/index.jsp b/webapps/examples/jsp/async/index.jsp index 0e3276705..b75c8513f 100644 --- a/webapps/examples/jsp/async/index.jsp +++ b/webapps/examples/jsp/async/index.jsp @@ -18,6 +18,11 @@ Use cases: - background thread calls writes and calls complete() "> Async 2 +4. Simple dispatch + - servlet does a startAsync() + - servlet calls dispatch(/path/to/jsp) + - servlet calls complete() + "> Async 3 3. Timeout s1 - servlet does a startAsync()