Class GenericFilterBean

    • Field Detail

      • logger

        protected final Log logger
        Logger available to subclasses
    • Method Detail

      • setBeanName

        public void setBeanName​(String beanName)
        Stores the bean name as defined in the Spring bean factory.

        Only relevant in case of initialization as bean, to have a name as fallback to the filter name usually provided by a FilterConfig instance.

        Specified by:
        setBeanName in interface BeanNameAware
        Parameters:
        beanName - the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils.originalBeanName(String) method to extract the original bean name (without suffix), if desired.
        See Also:
        BeanNameAware, getFilterName()
      • setEnvironment

        public void setEnvironment​(Environment environment)
        Set the Environment that this filter runs in.

        Any environment set here overrides the StandardServletEnvironment provided by default.

        This Environment object is used only for resolving placeholders in resource paths passed into init-parameters for this filter. If no init-params are used, this Environment can be essentially ignored.

        Specified by:
        setEnvironment in interface EnvironmentAware
      • destroy

        public void destroy()
        Subclasses may override this to perform custom filter shutdown.

        Note: This method will be called from standard filter destruction as well as filter bean destruction in a Spring application context.

        This default implementation is empty.

        Specified by:
        destroy in interface DisposableBean
        Specified by:
        destroy in interface Filter
      • addRequiredProperty

        protected final void addRequiredProperty​(String property)
        Subclasses can invoke this method to specify that this property (which must match a JavaBean property they expose) is mandatory, and must be supplied as a config parameter. This should be called from the constructor of a subclass.

        This method is only relevant in case of traditional initialization driven by a FilterConfig instance.

        Parameters:
        property - name of the required property
      • init

        public final void init​(FilterConfig filterConfig)
                        throws ServletException
        Standard way of initializing this filter. Map config parameters onto bean properties of this filter, and invoke subclass initialization.
        Specified by:
        init in interface Filter
        Parameters:
        filterConfig - the configuration for this filter
        Throws:
        ServletException - if bean properties are invalid (or required properties are missing), or if subclass initialization fails.
        See Also:
        initFilterBean()
      • initFilterBean

        protected void initFilterBean()
                               throws ServletException
        Subclasses may override this to perform custom initialization. All bean properties of this filter will have been set before this method is invoked.

        Note: This method will be called from standard filter initialization as well as filter bean initialization in a Spring application context. Filter name and ServletContext will be available in both cases.

        This default implementation is empty.

        Throws:
        ServletException - if subclass initialization fails
        See Also:
        getFilterName(), getServletContext()
      • getFilterConfig

        public final FilterConfig getFilterConfig()
        Make the FilterConfig of this filter available, if any. Analogous to GenericServlet's getServletConfig().

        Public to resemble the getFilterConfig() method of the Servlet Filter version that shipped with WebLogic 6.1.

        Returns:
        the FilterConfig instance, or null if none available
        See Also:
        GenericServlet.getServletConfig()