Commits

Anonymous committed 158db3c

Issue number: WW-300 - removed setFilterConfig() and getFilterConfig(); added getServletContext() so that subclasses can retrieve their own servlet context.

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@41573baa09-0c28-0410-bef9-dab3c582ae83

Comments (0)

Files changed (1)

src/java/com/opensymphony/webwork/lifecycle/RequestLifecycleFilter.java

 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
 /**
  *
- *
+ * @author scottnelsonsmith@yahoo.com added {@link getServletContext(HttpSession)}.
  * @author joew@thoughtworks.com
  * @author $Author$
  * @version $Revision$
     //~ Static fields/initializers /////////////////////////////////////////////
 
     private static final Log log = LogFactory.getLog(RequestLifecycleFilter.class);
-
+    
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    /**
-     * This method is required by Weblogic 6.1 SP4
-     * instead of {@link init(FilterConfig)} because
-     * they defined this as a required method just before
-     * the Servlet 2.3 specification was finalized.
-     *
-     * @param filterConfig the filter configuration for this filter
-     */
-    public final void setFilterConfig(FilterConfig filterConfig) throws ServletException {
-        init(filterConfig);
-    }
-
-    /**
-     * This method is required by Weblogic 6.1 SP4 because
-     * they defined this as a required method just before
-     * the Servlet 2.3 specification was finalized.
-     *
-     * @return the filter's filter configuration
-     */
-    public FilterConfig getFilterConfig() {
-        return null;
-    }
-
     public void destroy() {
     }
-
+    
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
         ComponentManager container = new DefaultComponentManager();
 
 
             container.setFallback(fallback);
 
-            ComponentConfiguration config = (ComponentConfiguration) session.getServletContext().getAttribute("ComponentConfiguration");
+            ComponentConfiguration config = (ComponentConfiguration) getServletContext(session).getAttribute("ComponentConfiguration");
 
             config.configure(container, "request");
 
             container.dispose();
         }
     }
+    
+    /**
+     * answers the servlet context.
+     * <p>
+     * Servlet 2.3 specifies that this can be retrieved from
+     * the session.  Unfortunately, weblogic.jar can only retrieve
+     * the servlet context from the filter config.  Hence, this method
+     * enables subclasses to retrieve the servlet context from other
+     * sources.
+     * 
+     * @param session the HTTP session where, in Servlet 2.3, the
+     *          servlet context can be retrieved
+     * @return the servlet context.
+     */
+    protected ServletContext getServletContext(HttpSession session)
+    {
+        return session.getServletContext();
+    }
 
     public void init(FilterConfig filterConfig) throws ServletException {
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.