Comet didn't work at all under a security manger. Need to allow web apps access to...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 6 Nov 2009 18:26:39 +0000 (18:26 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 6 Nov 2009 18:26:39 +0000 (18:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@833510 13f79535-47bb-0310-9956-ffa450edef68

36 files changed:
conf/catalina.policy
java/org/apache/catalina/CometEvent.java [deleted file]
java/org/apache/catalina/CometFilter.java [deleted file]
java/org/apache/catalina/CometFilterChain.java [deleted file]
java/org/apache/catalina/CometProcessor.java [deleted file]
java/org/apache/catalina/Valve.java
java/org/apache/catalina/comet/CometEvent.java [new file with mode: 0644]
java/org/apache/catalina/comet/CometFilter.java [new file with mode: 0644]
java/org/apache/catalina/comet/CometFilterChain.java [new file with mode: 0644]
java/org/apache/catalina/comet/CometProcessor.java [new file with mode: 0644]
java/org/apache/catalina/connector/CometEventImpl.java
java/org/apache/catalina/connector/CoyoteAdapter.java
java/org/apache/catalina/core/ApplicationFilterChain.java
java/org/apache/catalina/core/ApplicationFilterFactory.java
java/org/apache/catalina/core/StandardContextValve.java
java/org/apache/catalina/core/StandardEngineValve.java
java/org/apache/catalina/core/StandardHostValve.java
java/org/apache/catalina/core/StandardWrapperValve.java
java/org/apache/catalina/filters/RemoteAddrFilter.java
java/org/apache/catalina/filters/RemoteHostFilter.java
java/org/apache/catalina/filters/RequestFilter.java
java/org/apache/catalina/valves/CometConnectionManagerValve.java
java/org/apache/catalina/valves/ValveBase.java
modules/bayeux/java/org/apache/tomcat/bayeux/BayeuxServlet.java
modules/bayeux/java/org/apache/tomcat/bayeux/ClientImpl.java
modules/bayeux/java/org/apache/tomcat/bayeux/RequestBase.java
modules/bayeux/java/org/apache/tomcat/bayeux/RequestFactory.java
modules/bayeux/java/org/apache/tomcat/bayeux/TomcatBayeux.java
modules/bayeux/java/org/apache/tomcat/bayeux/request/MetaConnectRequest.java
modules/bayeux/java/org/apache/tomcat/bayeux/request/MetaDisconnectRequest.java
modules/bayeux/java/org/apache/tomcat/bayeux/request/MetaHandshakeRequest.java
modules/bayeux/java/org/apache/tomcat/bayeux/request/MetaSubscribeRequest.java
modules/bayeux/java/org/apache/tomcat/bayeux/request/MetaUnsubscribeRequest.java
modules/bayeux/java/org/apache/tomcat/bayeux/request/PublishRequest.java
webapps/docs/aio.xml
webapps/examples/WEB-INF/classes/chat/ChatServlet.java

index 63e4b62..8a8e51f 100644 (file)
@@ -146,6 +146,9 @@ grant {
     // Precompiled JSPs need access to these system properties.
     permission java.util.PropertyPermission "org.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER", "read";
     permission java.util.PropertyPermission "org.apache.el.parser.COERCE_TO_ZERO", "read";
+    
+    // Applications using Comet need to be able to access this package
+    permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina.comet";
 };
 
 
diff --git a/java/org/apache/catalina/CometEvent.java b/java/org/apache/catalina/CometEvent.java
deleted file mode 100644 (file)
index 341a57e..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * 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.catalina;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * The CometEvent interface.
- * 
- * @author Filip Hanik
- * @author Remy Maucherat
- */
-public interface CometEvent {
-
-    /**
-     * Enumeration describing the major events that the container can invoke 
-     * the CometProcessors event() method with
-     * BEGIN - will be called at the beginning 
-     *  of the processing of the connection. It can be used to initialize any relevant 
-     *  fields using the request and response objects. Between the end of the processing 
-     *  of this event, and the beginning of the processing of the end or error events,
-     *  it is possible to use the response object to write data on the open connection.
-     *  Note that the response object and dependent OutputStream and Writer are still 
-     *  not synchronized, so when they are accessed by multiple threads, 
-     *  synchronization is mandatory. After processing the initial event, the request 
-     *  is considered to be committed.
-     * READ - This indicates that input data is available, and that one read can be made
-     *  without blocking. The available and ready methods of the InputStream or
-     *  Reader may be used to determine if there is a risk of blocking: the servlet
-     *  should read while data is reported available. When encountering a read error, 
-     *  the servlet should report it by propagating the exception properly. Throwing 
-     *  an exception will cause the error event to be invoked, and the connection 
-     *  will be closed. 
-     *  Alternately, it is also possible to catch any exception, perform clean up
-     *  on any data structure the servlet may be using, and using the close method
-     *  of the event. It is not allowed to attempt reading data from the request 
-     *  object outside of the execution of this method.
-     * END - End may be called to end the processing of the request. Fields that have
-     *  been initialized in the begin method should be reset. After this event has
-     *  been processed, the request and response objects, as well as all their dependent
-     *  objects will be recycled and used to process other requests. End will also be 
-     *  called when data is available and the end of file is reached on the request input
-     *  (this usually indicates the client has pipelined a request).
-     * ERROR - Error will be called by the container in the case where an IO exception
-     *  or a similar unrecoverable error occurs on the connection. Fields that have
-     *  been initialized in the begin method should be reset. After this event has
-     *  been processed, the request and response objects, as well as all their dependent
-     *  objects will be recycled and used to process other requests.
-     */
-    public enum EventType {BEGIN, READ, END, ERROR}
-    
-    
-    /**
-     * Event details
-     * TIMEOUT - the connection timed out (sub type of ERROR); note that this ERROR type is not fatal, and
-     *   the connection will not be closed unless the servlet uses the close method of the event
-     * CLIENT_DISCONNECT - the client connection was closed (sub type of ERROR)
-     * IOEXCEPTION - an IO exception occurred, such as invalid content, for example, an invalid chunk block (sub type of ERROR)
-     * WEBAPP_RELOAD - the webapplication is being reloaded (sub type of END)
-     * SERVER_SHUTDOWN - the server is shutting down (sub type of END)
-     * SESSION_END - the servlet ended the session (sub type of END)
-     */
-    public enum EventSubType { TIMEOUT, CLIENT_DISCONNECT, IOEXCEPTION, WEBAPP_RELOAD, SERVER_SHUTDOWN, SESSION_END }
-    
-    
-    /**
-     * Returns the HttpServletRequest.
-     * 
-     * @return HttpServletRequest
-     */
-    public HttpServletRequest getHttpServletRequest();
-    
-    /**
-     * Returns the HttpServletResponse.
-     * 
-     * @return HttpServletResponse
-     */
-    public HttpServletResponse getHttpServletResponse();
-    
-    /**
-     * Returns the event type.
-     * 
-     * @return EventType
-     */
-    public EventType getEventType();
-    
-    /**
-     * Returns the sub type of this event.
-     * 
-     * @return EventSubType
-     */
-    public EventSubType getEventSubType();
-    
-    /**
-     * Ends the Comet session. This signals to the container that 
-     * the container wants to end the comet session. This will send back to the
-     * client a notice that the server has no more data to send as part of this
-     * request. The servlet should perform any needed cleanup as if it had received
-     * an END or ERROR event. 
-     * 
-     * @throws IOException if an IO exception occurs
-     */
-    public void close() throws IOException;
-    
-    /**
-     * Sets the timeout for this Comet connection. Please NOTE, that the implementation 
-     * of a per connection timeout is OPTIONAL and MAY NOT be implemented.<br/>
-     * This method sets the timeout in milliseconds of idle time on the connection.
-     * The timeout is reset every time data is received from the connection or data is flushed
-     * using <code>response.flushBuffer()</code>. If a timeout occurs, the 
-     * <code>error(HttpServletRequest, HttpServletResponse)</code> method is invoked. The 
-     * web application SHOULD NOT attempt to reuse the request and response objects after a timeout
-     * as the <code>error(HttpServletRequest, HttpServletResponse)</code> method indicates.<br/>
-     * This method should not be called asynchronously, as that will have no effect.
-     * 
-     * @param timeout The timeout in milliseconds for this connection, must be a positive value, larger than 0
-     * @throws IOException An IOException may be thrown to indicate an IO error, 
-     *         or that the EOF has been reached on the connection
-     * @throws ServletException An exception has occurred, as specified by the root
-     *         cause
-     * @throws UnsupportedOperationException if per connection timeout is not supported, either at all or at this phase
-     *         of the invocation.
-     */
-    public void setTimeout(int timeout)
-        throws IOException, ServletException, UnsupportedOperationException;
-
-}
diff --git a/java/org/apache/catalina/CometFilter.java b/java/org/apache/catalina/CometFilter.java
deleted file mode 100644 (file)
index 55cd327..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.catalina;
-
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.ServletException;
-
-/**
- * A Comet filter, similar to regular filters, performs filtering tasks on either 
- * the request to a resource (a Comet servlet), or on the response from a resource, or both.
- * <br><br>
- * Filters perform filtering in the <code>doFilterEvent</code> method. Every Filter has access to 
- * a FilterConfig object from which it can obtain its initialization parameters, a
- * reference to the ServletContext which it can use, for example, to load resources
- * needed for filtering tasks.
- * <p>
- * Filters are configured in the deployment descriptor of a web application
- * <p>
- * Examples that have been identified for this design are<br>
- * 1) Authentication Filters <br>
- * 2) Logging and Auditing Filters <br>
- * 3) Image conversion Filters <br>
- * 4) Data compression Filters <br>
- * 5) Encryption Filters <br>
- * 6) Tokenizing Filters <br>
- * 7) Filters that trigger resource access events <br>
- * 8) XSL/T filters <br>
- * 9) Mime-type chain Filter <br>
- * <br>
- * 
- * @author Remy Maucherat
- * @author Filip Hanik
- */
-public interface CometFilter extends Filter {
-
-    
-    /**
-     * The <code>doFilterEvent</code> method of the CometFilter is called by the container
-     * each time a request/response pair is passed through the chain due
-     * to a client event for a resource at the end of the chain. The CometFilterChain passed in to this
-     * method allows the Filter to pass on the event to the next entity in the
-     * chain.<p>
-     * A typical implementation of this method would follow the following pattern:- <br>
-     * 1. Examine the request<br>
-     * 2. Optionally wrap the request object contained in the event with a custom implementation to
-     * filter content or headers for input filtering and pass a CometEvent instance containing
-     * the wrapped request to the next filter<br>
-     * 3. Optionally wrap the response object contained in the event with a custom implementation to
-     * filter content or headers for output filtering and pass a CometEvent instance containing
-     * the wrapped request to the next filter<br>
-     * 4. a) <strong>Either</strong> invoke the next entity in the chain using the CometFilterChain object (<code>chain.doFilterEvent()</code>), <br>   
-     * 4. b) <strong>or</strong> not pass on the request/response pair to the next entity in the filter chain to block the event processing<br>
-     * 5. Directly set fields on the response after invocation of the next entity in the filter chain.
-     * 
-     * @param event the event that is being processed. Another event may be passed along the chain.
-     * @param chain 
-     * @throws IOException
-     * @throws ServletException
-     */
-    public void doFilterEvent(CometEvent event, CometFilterChain chain)
-        throws IOException, ServletException;
-    
-
-}
diff --git a/java/org/apache/catalina/CometFilterChain.java b/java/org/apache/catalina/CometFilterChain.java
deleted file mode 100644 (file)
index f0632fc..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.catalina;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-
-/**
- * A CometFilterChain is an object provided by the servlet container to the developer
- * giving a view into the invocation chain of a filtered event for a resource. Filters
- * use the CometFilterChain to invoke the next filter in the chain, or if the calling filter
- * is the last filter in the chain, to invoke the resource at the end of the chain.
- * 
- * @author Remy Maucherat
- * @author Filip Hanik
- */
-public interface CometFilterChain {
-
-    
-    /**
-     * Causes the next filter in the chain to be invoked, or if the calling filter is the last filter
-     * in the chain, causes the resource at the end of the chain to be invoked.
-     *
-     * @param event the event to pass along the chain.
-     */
-    public void doFilterEvent(CometEvent event) throws IOException, ServletException;
-    
-
-}
diff --git a/java/org/apache/catalina/CometProcessor.java b/java/org/apache/catalina/CometProcessor.java
deleted file mode 100644 (file)
index 38e9f3b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.catalina;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.Servlet;
-
-/**
- * This interface should be implemented by servlets which would like to handle
- * asynchronous IO, receiving events when data is available for reading, and
- * being able to output data without the need for being invoked by the container.
- * Note: When this interface is implemented, the service method of the servlet will
- * never be called, and will be replaced with a begin event.
- */
-public interface CometProcessor extends Servlet{
-
-    /**
-     * Process the given Comet event.
-     * 
-     * @param event The Comet event that will be processed
-     * @throws IOException
-     * @throws ServletException
-     */
-    public void event(CometEvent event)
-        throws IOException, ServletException;
-
-}
index 4143170..e2a29fc 100644 (file)
@@ -22,6 +22,7 @@ package org.apache.catalina;
 import java.io.IOException;
 import javax.servlet.ServletException;
 
+import org.apache.catalina.comet.CometEvent;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 
diff --git a/java/org/apache/catalina/comet/CometEvent.java b/java/org/apache/catalina/comet/CometEvent.java
new file mode 100644 (file)
index 0000000..29a884a
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * 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.catalina.comet;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * The CometEvent interface.
+ * 
+ * @author Filip Hanik
+ * @author Remy Maucherat
+ */
+public interface CometEvent {
+
+    /**
+     * Enumeration describing the major events that the container can invoke 
+     * the CometProcessors event() method with
+     * BEGIN - will be called at the beginning 
+     *  of the processing of the connection. It can be used to initialize any relevant 
+     *  fields using the request and response objects. Between the end of the processing 
+     *  of this event, and the beginning of the processing of the end or error events,
+     *  it is possible to use the response object to write data on the open connection.
+     *  Note that the response object and dependent OutputStream and Writer are still 
+     *  not synchronized, so when they are accessed by multiple threads, 
+     *  synchronization is mandatory. After processing the initial event, the request 
+     *  is considered to be committed.
+     * READ - This indicates that input data is available, and that one read can be made
+     *  without blocking. The available and ready methods of the InputStream or
+     *  Reader may be used to determine if there is a risk of blocking: the servlet
+     *  should read while data is reported available. When encountering a read error, 
+     *  the servlet should report it by propagating the exception properly. Throwing 
+     *  an exception will cause the error event to be invoked, and the connection 
+     *  will be closed. 
+     *  Alternately, it is also possible to catch any exception, perform clean up
+     *  on any data structure the servlet may be using, and using the close method
+     *  of the event. It is not allowed to attempt reading data from the request 
+     *  object outside of the execution of this method.
+     * END - End may be called to end the processing of the request. Fields that have
+     *  been initialized in the begin method should be reset. After this event has
+     *  been processed, the request and response objects, as well as all their dependent
+     *  objects will be recycled and used to process other requests. End will also be 
+     *  called when data is available and the end of file is reached on the request input
+     *  (this usually indicates the client has pipelined a request).
+     * ERROR - Error will be called by the container in the case where an IO exception
+     *  or a similar unrecoverable error occurs on the connection. Fields that have
+     *  been initialized in the begin method should be reset. After this event has
+     *  been processed, the request and response objects, as well as all their dependent
+     *  objects will be recycled and used to process other requests.
+     */
+    public enum EventType {BEGIN, READ, END, ERROR}
+    
+    
+    /**
+     * Event details
+     * TIMEOUT - the connection timed out (sub type of ERROR); note that this ERROR type is not fatal, and
+     *   the connection will not be closed unless the servlet uses the close method of the event
+     * CLIENT_DISCONNECT - the client connection was closed (sub type of ERROR)
+     * IOEXCEPTION - an IO exception occurred, such as invalid content, for example, an invalid chunk block (sub type of ERROR)
+     * WEBAPP_RELOAD - the webapplication is being reloaded (sub type of END)
+     * SERVER_SHUTDOWN - the server is shutting down (sub type of END)
+     * SESSION_END - the servlet ended the session (sub type of END)
+     */
+    public enum EventSubType { TIMEOUT, CLIENT_DISCONNECT, IOEXCEPTION, WEBAPP_RELOAD, SERVER_SHUTDOWN, SESSION_END }
+    
+    
+    /**
+     * Returns the HttpServletRequest.
+     * 
+     * @return HttpServletRequest
+     */
+    public HttpServletRequest getHttpServletRequest();
+    
+    /**
+     * Returns the HttpServletResponse.
+     * 
+     * @return HttpServletResponse
+     */
+    public HttpServletResponse getHttpServletResponse();
+    
+    /**
+     * Returns the event type.
+     * 
+     * @return EventType
+     */
+    public EventType getEventType();
+    
+    /**
+     * Returns the sub type of this event.
+     * 
+     * @return EventSubType
+     */
+    public EventSubType getEventSubType();
+    
+    /**
+     * Ends the Comet session. This signals to the container that 
+     * the container wants to end the comet session. This will send back to the
+     * client a notice that the server has no more data to send as part of this
+     * request. The servlet should perform any needed cleanup as if it had received
+     * an END or ERROR event. 
+     * 
+     * @throws IOException if an IO exception occurs
+     */
+    public void close() throws IOException;
+    
+    /**
+     * Sets the timeout for this Comet connection. Please NOTE, that the implementation 
+     * of a per connection timeout is OPTIONAL and MAY NOT be implemented.<br/>
+     * This method sets the timeout in milliseconds of idle time on the connection.
+     * The timeout is reset every time data is received from the connection or data is flushed
+     * using <code>response.flushBuffer()</code>. If a timeout occurs, the 
+     * <code>error(HttpServletRequest, HttpServletResponse)</code> method is invoked. The 
+     * web application SHOULD NOT attempt to reuse the request and response objects after a timeout
+     * as the <code>error(HttpServletRequest, HttpServletResponse)</code> method indicates.<br/>
+     * This method should not be called asynchronously, as that will have no effect.
+     * 
+     * @param timeout The timeout in milliseconds for this connection, must be a positive value, larger than 0
+     * @throws IOException An IOException may be thrown to indicate an IO error, 
+     *         or that the EOF has been reached on the connection
+     * @throws ServletException An exception has occurred, as specified by the root
+     *         cause
+     * @throws UnsupportedOperationException if per connection timeout is not supported, either at all or at this phase
+     *         of the invocation.
+     */
+    public void setTimeout(int timeout)
+        throws IOException, ServletException, UnsupportedOperationException;
+
+}
diff --git a/java/org/apache/catalina/comet/CometFilter.java b/java/org/apache/catalina/comet/CometFilter.java
new file mode 100644 (file)
index 0000000..2b69bc4
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * 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.catalina.comet;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.ServletException;
+
+/**
+ * A Comet filter, similar to regular filters, performs filtering tasks on either 
+ * the request to a resource (a Comet servlet), or on the response from a resource, or both.
+ * <br><br>
+ * Filters perform filtering in the <code>doFilterEvent</code> method. Every Filter has access to 
+ * a FilterConfig object from which it can obtain its initialization parameters, a
+ * reference to the ServletContext which it can use, for example, to load resources
+ * needed for filtering tasks.
+ * <p>
+ * Filters are configured in the deployment descriptor of a web application
+ * <p>
+ * Examples that have been identified for this design are<br>
+ * 1) Authentication Filters <br>
+ * 2) Logging and Auditing Filters <br>
+ * 3) Image conversion Filters <br>
+ * 4) Data compression Filters <br>
+ * 5) Encryption Filters <br>
+ * 6) Tokenizing Filters <br>
+ * 7) Filters that trigger resource access events <br>
+ * 8) XSL/T filters <br>
+ * 9) Mime-type chain Filter <br>
+ * <br>
+ * 
+ * @author Remy Maucherat
+ * @author Filip Hanik
+ */
+public interface CometFilter extends Filter {
+
+    
+    /**
+     * The <code>doFilterEvent</code> method of the CometFilter is called by the container
+     * each time a request/response pair is passed through the chain due
+     * to a client event for a resource at the end of the chain. The CometFilterChain passed in to this
+     * method allows the Filter to pass on the event to the next entity in the
+     * chain.<p>
+     * A typical implementation of this method would follow the following pattern:- <br>
+     * 1. Examine the request<br>
+     * 2. Optionally wrap the request object contained in the event with a custom implementation to
+     * filter content or headers for input filtering and pass a CometEvent instance containing
+     * the wrapped request to the next filter<br>
+     * 3. Optionally wrap the response object contained in the event with a custom implementation to
+     * filter content or headers for output filtering and pass a CometEvent instance containing
+     * the wrapped request to the next filter<br>
+     * 4. a) <strong>Either</strong> invoke the next entity in the chain using the CometFilterChain object (<code>chain.doFilterEvent()</code>), <br>   
+     * 4. b) <strong>or</strong> not pass on the request/response pair to the next entity in the filter chain to block the event processing<br>
+     * 5. Directly set fields on the response after invocation of the next entity in the filter chain.
+     * 
+     * @param event the event that is being processed. Another event may be passed along the chain.
+     * @param chain 
+     * @throws IOException
+     * @throws ServletException
+     */
+    public void doFilterEvent(CometEvent event, CometFilterChain chain)
+        throws IOException, ServletException;
+    
+
+}
diff --git a/java/org/apache/catalina/comet/CometFilterChain.java b/java/org/apache/catalina/comet/CometFilterChain.java
new file mode 100644 (file)
index 0000000..b4ca50e
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.catalina.comet;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+
+/**
+ * A CometFilterChain is an object provided by the servlet container to the developer
+ * giving a view into the invocation chain of a filtered event for a resource. Filters
+ * use the CometFilterChain to invoke the next filter in the chain, or if the calling filter
+ * is the last filter in the chain, to invoke the resource at the end of the chain.
+ * 
+ * @author Remy Maucherat
+ * @author Filip Hanik
+ */
+public interface CometFilterChain {
+
+    
+    /**
+     * Causes the next filter in the chain to be invoked, or if the calling filter is the last filter
+     * in the chain, causes the resource at the end of the chain to be invoked.
+     *
+     * @param event the event to pass along the chain.
+     */
+    public void doFilterEvent(CometEvent event) throws IOException, ServletException;
+    
+
+}
diff --git a/java/org/apache/catalina/comet/CometProcessor.java b/java/org/apache/catalina/comet/CometProcessor.java
new file mode 100644 (file)
index 0000000..a652129
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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.catalina.comet;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.Servlet;
+
+/**
+ * This interface should be implemented by servlets which would like to handle
+ * asynchronous IO, receiving events when data is available for reading, and
+ * being able to output data without the need for being invoked by the container.
+ * Note: When this interface is implemented, the service method of the servlet will
+ * never be called, and will be replaced with a begin event.
+ */
+public interface CometProcessor extends Servlet{
+
+    /**
+     * Process the given Comet event.
+     * 
+     * @param event The Comet event that will be processed
+     * @throws IOException
+     * @throws ServletException
+     */
+    public void event(CometEvent event)
+        throws IOException, ServletException;
+
+}
index 0da2f56..051d566 100644 (file)
@@ -24,7 +24,7 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.tomcat.util.res.StringManager;
 
 public class CometEventImpl implements CometEvent {
index 2aabdc7..16c1d42 100644 (file)
@@ -24,11 +24,11 @@ import java.util.EnumSet;
 
 import javax.servlet.SessionTrackingMode;
 
-import org.apache.catalina.CometEvent;
 import org.apache.catalina.Context;
 import org.apache.catalina.Globals;
 import org.apache.catalina.Wrapper;
 import org.apache.tomcat.util.res.StringManager;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.catalina.core.AsyncContextImpl;
 import org.apache.catalina.util.URLEncoder;
 import org.apache.coyote.ActionCode;
index 2b577a9..49da22a 100644 (file)
@@ -32,12 +32,12 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.catalina.CometEvent;
-import org.apache.catalina.CometFilter;
-import org.apache.catalina.CometFilterChain;
-import org.apache.catalina.CometProcessor;
 import org.apache.catalina.Globals;
 import org.apache.catalina.InstanceEvent;
+import org.apache.catalina.comet.CometEvent;
+import org.apache.catalina.comet.CometFilter;
+import org.apache.catalina.comet.CometFilterChain;
+import org.apache.catalina.comet.CometProcessor;
 import org.apache.catalina.security.SecurityUtil;
 import org.apache.catalina.util.InstanceSupport;
 import org.apache.tomcat.util.res.StringManager;
index b8b981c..6a450e6 100644 (file)
@@ -23,9 +23,9 @@ import javax.servlet.DispatcherType;
 import javax.servlet.Servlet;
 import javax.servlet.ServletRequest;
 
-import org.apache.catalina.CometFilter;
 import org.apache.catalina.Globals;
 import org.apache.catalina.Wrapper;
+import org.apache.catalina.comet.CometFilter;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.deploy.FilterMap;
 
index 9e8a008..5b91e3e 100644 (file)
@@ -27,10 +27,10 @@ import javax.servlet.ServletRequestEvent;
 import javax.servlet.ServletRequestListener;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.catalina.CometEvent;
 import org.apache.catalina.Container;
 import org.apache.catalina.Globals;
 import org.apache.catalina.Wrapper;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.tomcat.util.res.StringManager;
index b2df268..320720e 100644 (file)
@@ -24,8 +24,8 @@ import java.io.IOException;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.catalina.CometEvent;
 import org.apache.catalina.Host;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.tomcat.util.res.StringManager;
index 9dd2433..f22b948 100644 (file)
@@ -27,10 +27,10 @@ import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.catalina.CometEvent;
 import org.apache.catalina.Context;
 import org.apache.catalina.Globals;
 import org.apache.catalina.Wrapper;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.catalina.connector.ClientAbortException;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
index 88c72f3..d4d377c 100644 (file)
@@ -29,10 +29,10 @@ import javax.servlet.ServletException;
 import javax.servlet.UnavailableException;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.catalina.CometEvent;
-import org.apache.catalina.CometProcessor;
 import org.apache.catalina.Context;
 import org.apache.catalina.Globals;
+import org.apache.catalina.comet.CometEvent;
+import org.apache.catalina.comet.CometProcessor;
 import org.apache.catalina.connector.ClientAbortException;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
index cc3febc..ffb252d 100644 (file)
@@ -26,8 +26,8 @@ import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-import org.apache.catalina.CometEvent;
-import org.apache.catalina.CometFilterChain;
+import org.apache.catalina.comet.CometEvent;
+import org.apache.catalina.comet.CometFilterChain;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
index 6778b58..0b4c12d 100644 (file)
@@ -26,8 +26,8 @@ import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-import org.apache.catalina.CometEvent;
-import org.apache.catalina.CometFilterChain;
+import org.apache.catalina.comet.CometEvent;
+import org.apache.catalina.comet.CometFilterChain;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
index 97f9b95..2499dc5 100644 (file)
@@ -30,9 +30,9 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.catalina.CometEvent;
-import org.apache.catalina.CometFilter;
-import org.apache.catalina.CometFilterChain;
+import org.apache.catalina.comet.CometEvent;
+import org.apache.catalina.comet.CometFilter;
+import org.apache.catalina.comet.CometFilterChain;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
index a928164..0800ed1 100644 (file)
@@ -30,13 +30,13 @@ import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpSessionEvent;
 import javax.servlet.http.HttpSessionListener;
 
-import org.apache.catalina.CometEvent;
-import org.apache.catalina.CometProcessor;
 import org.apache.catalina.Context;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.comet.CometEvent;
+import org.apache.catalina.comet.CometProcessor;
 import org.apache.catalina.connector.CometEventImpl;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
index 524b536..a5f41fc 100644 (file)
@@ -27,7 +27,6 @@ import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.servlet.ServletException;
 
-import org.apache.catalina.CometEvent;
 import org.apache.catalina.Contained;
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
@@ -36,6 +35,7 @@ import org.apache.catalina.Host;
 import org.apache.catalina.Pipeline;
 import org.apache.catalina.Valve;
 import org.apache.catalina.Wrapper;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.core.ContainerBase;
index dfb81b3..f0ce85b 100644 (file)
@@ -24,8 +24,8 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.catalina.CometEvent;
-import org.apache.catalina.CometProcessor;
+import org.apache.catalina.comet.CometEvent;
+import org.apache.catalina.comet.CometProcessor;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.json.JSONArray;
index 3705e1f..b03f7a8 100644 (file)
@@ -22,7 +22,7 @@ import java.util.Map;
 import java.util.Queue;
 import java.util.concurrent.ConcurrentLinkedQueue;
 
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.json.JSONObject;
 import org.apache.cometd.bayeux.Bayeux;
 import org.apache.cometd.bayeux.Client;
index 9f6036e..a813abf 100644 (file)
@@ -28,7 +28,7 @@ import java.util.Date;
 import java.text.SimpleDateFormat;
 import javax.servlet.ServletException;
 
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.tomcat.bayeux.HttpError;
 
 import org.apache.juli.logging.Log;
index c617180..203d94d 100644 (file)
@@ -18,7 +18,7 @@ package org.apache.tomcat.bayeux;
 
 import org.json.JSONObject;
 import org.apache.tomcat.bayeux.request.MetaHandshakeRequest;
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.json.JSONException;
 import org.apache.tomcat.bayeux.request.MetaConnectRequest;
 import org.apache.tomcat.bayeux.request.MetaDisconnectRequest;
index e7d33c0..f8d6882 100644 (file)
@@ -20,7 +20,7 @@ import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.catalina.tribes.util.Arrays;
 import org.apache.catalina.tribes.util.UUIDGenerator;
 import org.apache.cometd.bayeux.Bayeux;
index 2eacdbc..f2f509a 100644 (file)
@@ -20,7 +20,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import javax.servlet.ServletException;
 
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.tomcat.bayeux.HttpError;
 import org.apache.tomcat.bayeux.BayeuxException;
 import org.apache.tomcat.bayeux.BayeuxRequest;
index b3dde94..78bf7b4 100644 (file)
@@ -20,7 +20,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import javax.servlet.ServletException;
 
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.tomcat.bayeux.HttpError;
 import org.apache.tomcat.bayeux.BayeuxException;
 import org.apache.tomcat.bayeux.BayeuxRequest;
index 0883ae9..593cfef 100644 (file)
@@ -20,7 +20,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import javax.servlet.ServletException;
 
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.tomcat.bayeux.HttpError;
 import org.apache.tomcat.bayeux.BayeuxException;
 import org.apache.tomcat.bayeux.BayeuxRequest;
index b6af0b2..af42d09 100644 (file)
@@ -22,7 +22,7 @@ import java.util.Iterator;
 import java.util.List;
 import javax.servlet.ServletException;
 
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.tomcat.bayeux.HttpError;
 import org.apache.tomcat.bayeux.BayeuxException;
 import org.apache.tomcat.bayeux.BayeuxRequest;
index e8b3e16..62e4c8f 100644 (file)
@@ -22,7 +22,7 @@ import java.util.Iterator;
 import java.util.List;
 import javax.servlet.ServletException;
 
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.tomcat.bayeux.HttpError;
 import org.apache.tomcat.bayeux.BayeuxException;
 import org.apache.tomcat.bayeux.BayeuxRequest;
index 017d181..b714d11 100644 (file)
@@ -20,7 +20,7 @@ import java.io.IOException;
 import java.util.HashMap;
 import javax.servlet.ServletException;
 
-import org.apache.catalina.CometEvent;
+import org.apache.catalina.comet.CometEvent;
 import org.apache.tomcat.bayeux.HttpError;
 import org.apache.tomcat.bayeux.BayeuxException;
 import org.apache.tomcat.bayeux.BayeuxRequest;
index 4cc4c53..4cb28fe 100644 (file)
@@ -58,7 +58,7 @@
   <subsection name="CometEvent">
   
   <p>
-    Servlets which implement the <code>org.apache.catalina.CometProcessor</code>
+    Servlets which implement the <code>org.apache.catalina.comet.CometProcessor</code>
     interface will have their event method invoked rather than the usual service
     method, according to the event which occurred. The event object gives
     access to the usual request and response objects, which may be used in the
index 8028f40..8e24cbf 100644 (file)
@@ -24,8 +24,8 @@ import java.io.InputStream;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 
-import org.apache.catalina.CometEvent;
-import org.apache.catalina.CometProcessor;
+import org.apache.catalina.comet.CometEvent;
+import org.apache.catalina.comet.CometProcessor;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;