FileDocCategorySizeDatePackage
FilterDispatcherCompatWeblogic61.javaAPI DocExample4093Mon Jul 23 13:26:38 BST 2007org.apache.struts2.dispatcher

FilterDispatcherCompatWeblogic61

public class FilterDispatcherCompatWeblogic61 extends FilterDispatcher
When running Weblogic Server 6.1, this class should be specified in web.xml instead of {@link FilterDispatcher}.

This class properly handles the weblogic.jar handling of servlet filters. There is one serious incompatibility, and that is that while {@link FilterDispatcher#init(FilterConfig)} throws a {@link ServletException}, this class's method {@link #setFilterConfig(FilterConfig)} does not throw the exception. Since {@link #setFilterConfig(FilterConfig)} invokes {@link FilterDispatcher#init(FilterConfig)}, the setter must "swallow" the exception. This it does by logging the exception as an error.

Fields Summary
private static Log
log
Constructors Summary
Methods Summary
public javax.servlet.FilterConfiggetFilterConfig()
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

        return super.getFilterConfig();
    
protected javax.servlet.ServletContextgetServletContext(javax.servlet.http.HttpSession session)
answers the servlet context.

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 returns the servlet context from the singleton that was setup by {@link #setFilterConfig(FilterConfig)}.

param
session the HTTP session. Not used
return
the servlet context.

        ServletContextSingleton singleton =
                ServletContextSingleton.getInstance();
        return singleton.getServletContext();
    
public voidsetFilterConfig(javax.servlet.FilterConfig filterConfig)
dummy setter for {@link #filterConfig}; this method sets up the {@link org.apache.struts2.config.ServletContextSingleton} with the servlet context from the filter configuration.

This is needed by Weblogic Server 6.1 because it uses a slightly obsolete Servlet 2.3-minus spec whose {@link Filter} interface requires this method.

param
filterConfig the filter configuration.


                                                           
        
        try {
            init(filterConfig);
        } catch (ServletException se) {
            log.error("Couldn't set the filter configuration in this filter", se);
        }

        ServletContextSingleton singleton = ServletContextSingleton.getInstance();
        singleton.setServletContext(filterConfig.getServletContext());