Coyote should not depend on Catalina
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 11 Dec 2010 18:27:15 +0000 (18:27 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 11 Dec 2010 18:27:15 +0000 (18:27 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1044692 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/AsyncContextImpl.java
java/org/apache/coyote/AsyncContextCallback.java [new file with mode: 0644]
java/org/apache/coyote/AsyncStateMachine.java
java/org/apache/coyote/ajp/AbstractAjpProcessor.java
java/org/apache/coyote/http11/AbstractHttp11Processor.java

index 065139c..c5b0e3c 100644 (file)
@@ -43,6 +43,7 @@ import org.apache.catalina.Context;
 import org.apache.catalina.Globals;
 import org.apache.catalina.connector.Request;
 import org.apache.coyote.ActionCode;
+import org.apache.coyote.AsyncContextCallback;
 import org.apache.coyote.RequestInfo;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -52,7 +53,7 @@ import org.apache.tomcat.InstanceManager;
  * @author fhanik
  *
  */
-public class AsyncContextImpl implements AsyncContext {
+public class AsyncContextImpl implements AsyncContext, AsyncContextCallback {
     
     private static final Log log = LogFactory.getLog(AsyncContextImpl.class);
     
diff --git a/java/org/apache/coyote/AsyncContextCallback.java b/java/org/apache/coyote/AsyncContextCallback.java
new file mode 100644 (file)
index 0000000..cf20be8
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  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 org.apache.coyote;
+
+/**
+ * Provides a mechanism for the Coyote connectors to signal to a
+ * {@link javax.servlet.AsyncContext} implementation that an action, such as
+ * firing event listeners needs to be taken. It is implemented in this manner
+ * so that the org.apache.coyote package does not have a dependency on the
+ * org.apache.coyote package.  
+ */
+public interface AsyncContextCallback {
+    public void fireOnComplete();
+}
index 6ca133e..b71a4ac 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.coyote;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
-import org.apache.catalina.core.AsyncContextImpl;
 import org.apache.tomcat.util.net.AbstractEndpoint.Handler.SocketState;
 import org.apache.tomcat.util.res.StringManager;
 
@@ -96,7 +95,7 @@ public class AsyncStateMachine {
 
     private volatile AsyncState state = AsyncState.DISPATCHED;
     // Need this to fire listener on complete
-    private AsyncContextImpl asyncCtxt = null;
+    private AsyncContextCallback asyncCtxt = null;
     private Processor processor;
     
     
@@ -122,7 +121,7 @@ public class AsyncStateMachine {
     }
 
 
-    public synchronized void asyncStart(AsyncContextImpl asyncCtxt) {
+    public synchronized void asyncStart(AsyncContextCallback asyncCtxt) {
         if (state == AsyncState.DISPATCHED) {
             state = AsyncState.STARTING;
             this.asyncCtxt = asyncCtxt;
index 2058c23..0802b3d 100644 (file)
@@ -25,10 +25,10 @@ import java.security.cert.X509Certificate;
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.apache.catalina.core.AsyncContextImpl;
 import org.apache.coyote.ActionCode;
 import org.apache.coyote.ActionHook;
 import org.apache.coyote.Adapter;
+import org.apache.coyote.AsyncContextCallback;
 import org.apache.coyote.AsyncStateMachine;
 import org.apache.coyote.InputBuffer;
 import org.apache.coyote.Processor;
@@ -334,7 +334,7 @@ public abstract class AbstractAjpProcessor implements ActionHook, Processor {
            replay = true;
 
        } else if (actionCode == ActionCode.ASYNC_START) {
-           asyncStateMachine.asyncStart((AsyncContextImpl) param);
+           asyncStateMachine.asyncStart((AsyncContextCallback) param);
        } else if (actionCode == ActionCode.ASYNC_DISPATCHED) {
            asyncStateMachine.asyncDispatched();
        } else if (actionCode == ActionCode.ASYNC_TIMEOUT) {
index 22bca8e..190de24 100644 (file)
@@ -23,10 +23,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
-import org.apache.catalina.core.AsyncContextImpl;
 import org.apache.coyote.ActionCode;
 import org.apache.coyote.ActionHook;
 import org.apache.coyote.Adapter;
+import org.apache.coyote.AsyncContextCallback;
 import org.apache.coyote.AsyncStateMachine;
 import org.apache.coyote.Processor;
 import org.apache.coyote.Request;
@@ -915,7 +915,7 @@ public abstract class AbstractHttp11Processor implements ActionHook, Processor {
                 request.getInputBuffer();
             internalBuffer.addActiveFilter(savedBody);
         } else if (actionCode == ActionCode.ASYNC_START) {
-            asyncStateMachine.asyncStart((AsyncContextImpl) param);
+            asyncStateMachine.asyncStart((AsyncContextCallback) param);
         } else if (actionCode == ActionCode.ASYNC_DISPATCHED) {
             asyncStateMachine.asyncDispatched();
         } else if (actionCode == ActionCode.ASYNC_TIMEOUT) {