/**
- * Returns the HttpServletRequest or the last HttpServletRequestWrapper if a filter was applied
+ * Returns the HttpServletRequest.
+ *
* @return HttpServletRequest
*/
public HttpServletRequest getHttpServletRequest();
/**
- * Returns the HttpServletResponse or the last HttpServletResponseWrapper
+ * Returns the HttpServletResponse.
+ *
* @return HttpServletResponse
*/
public HttpServletResponse getHttpServletResponse();
/**
- * Returns the event type
+ * Returns the event type.
+ *
* @return EventType
*/
public EventType getEventType();
/**
- * Returns
+ * 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.
- * The container may invoke event(CometEvent.END) synchronously or asynchronously
+ * 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 recieved
+ * an END or ERROR event.
+ *
* @throws IOException if an IO exception occurs
*/
public void close() throws IOException;
* 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
import java.io.IOException;
-import javax.servlet.FilterChain;
+import javax.servlet.Filter;
import javax.servlet.ServletException;
/**
- * The CometFilter interface.
+ * 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 {
+public interface CometFilter extends Filter {
- public void doFilterEvent(CometEvent event, CometFilterChain chain) throws IOException, ServletException;
+ /**
+ * 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;
}
import javax.servlet.ServletException;
/**
- * The CometFilter interface.
+ * 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;