1 package com.opensymphony.webwork.dispatcher; 2 3 import com.opensymphony.xwork.ActionContext; 4 import com.opensymphony.xwork.interceptor.component.ComponentManager; 5 6 import javax.servlet.*; 7 import java.io.IOException ; 8 9 32 public class ActionContexCleanUp implements Filter { 33 private static final String CLEANUP_PRESENT = "__cleanup_present"; 34 35 public void init(FilterConfig filterConfig) throws ServletException { 36 } 37 38 public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException , ServletException { 39 try { 40 req.setAttribute(CLEANUP_PRESENT, Boolean.TRUE); 41 chain.doFilter(req, res); 42 req.setAttribute(CLEANUP_PRESENT, Boolean.FALSE); 43 } finally { 44 cleanUp(req); 45 } 46 } 47 48 protected static void cleanUp(ServletRequest req) { 49 Boolean dontClean = (Boolean ) req.getAttribute(CLEANUP_PRESENT); 51 if (dontClean != null && dontClean.booleanValue()) { 52 return; 53 } 54 55 ComponentManager componentManager = (ComponentManager) req.getAttribute(ComponentManager.COMPONENT_MANAGER_KEY); 57 if (componentManager != null) { 58 componentManager.dispose(); 59 } 60 61 ActionContext.setContext(null); 63 } 64 65 public void destroy() { 66 } 67 } 68 | Popular Tags |