webwork/src/main/webwork/dispatcher CleanupFilter.java,NONE,1.1 ServletDispatcher.java,1.71,1.72
[email protected] Thu, 27 May 2004 22:02:58 -0700
| Newsgroups | gmane.comp.java.open-symphony.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/opensymphony/webwork/src/main/webwork/dispatcher
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31107/src/main/webwork/dispatcher
Modified Files:
ServletDispatcher.java
Added Files:
CleanupFilter.java
Log Message:
Adding ServletFilter which will clean up ActionContext (signalling the ServletDispatcher not to do so) so that Sitemesh filters can use the ActionContext
--- NEW FILE: CleanupFilter.java ---
package webwork.dispatcher;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.servlet.*;
import java.io.IOException;
/**
* CleanupFilter can be applied to
* @author Jason Carreira
* Date: May 27, 2004 1:27:36 PM
*/
public class CleanupFilter implements Filter {
public static final String DO_NOT_CLEAN = "webwork.cleanupfilter";
private static Log LOG = LogFactory.getLog(ServletDispatcher.class);
public void destroy() {
}
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
servletRequest.setAttribute(DO_NOT_CLEAN,Boolean.TRUE);
filterChain.doFilter(servletRequest,servletResponse);
GenericDispatcher gd = (GenericDispatcher) servletRequest.getAttribute(ServletDispatcher.GENERIC_DISPATCHER_FOR_CLEANUP);
if (gd != null) {
LOG.debug("Cleaning up generic dispatcher.");
gd.finalizeContext();
}
}
public void init(FilterConfig filterConfig) throws ServletException {
}
}
Index: ServletDispatcher.java
===================================================================
RCS file: /cvsroot/opensymphony/webwork/src/main/webwork/dispatcher/ServletDispatcher.java,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -d -r1.71 -r1.72
--- ServletDispatcher.java 14 Apr 2004 00:13:02 -0000 1.71
+++ ServletDispatcher.java 28 May 2004 05:02:48 -0000 1.72
@@ -62,8 +62,9 @@
private static Integer maxSize;
private static String actionExtension;
private String encoding;
+ public static final String GENERIC_DISPATCHER_FOR_CLEANUP = "webwork.generic.dispatcher";
- // HttpServlet overrides -----------------------------------------
+ // HttpServlet overrides -----------------------------------------
/**
* Initialize dispatcher servlet
*
@@ -234,7 +235,12 @@
}
}
- gd.finalizeContext();
+ Boolean skipCleaning = (Boolean) aRequest.getAttribute(CleanupFilter.DO_NOT_CLEAN);
+ if ((skipCleaning != null) && (skipCleaning.booleanValue())) {
+ aRequest.setAttribute(GENERIC_DISPATCHER_FOR_CLEANUP, gd);
+ } else {
+ gd.finalizeContext();
+ }
}
/**
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click