java.lang.Object | |
↳ | org.springframework.web.filter.GenericFilterBean |
Known Direct Subclasses |
Simple base implementation of javax.servlet.Filter which treats
its config parameters (init-param
entries within the
filter
tag in web.xml
) as bean properties.
A handy superclass for any type of filter. Type conversion of config parameters is automatic, with the corresponding setter method getting invoked with the converted value. It is also possible for subclasses to specify required properties. Parameters without matching bean property setter will simply be ignored.
This filter leaves actual filtering to subclasses, which have to
implement the doFilter(ServletRequest, ServletResponse, FilterChain)
method.
This generic filter base class has no dependency on the Spring
ApplicationContext
concept.
Filters usually don't load their own context but rather access service
beans from the Spring root application context, accessible via the
filter's ServletContext
(see
WebApplicationContextUtils
).
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
logger | Logger available to subclasses |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Calls the
initFilterBean() method that might
contain custom initialization of a subclass. | |||||||||||
Subclasses may override this to perform custom filter shutdown.
| |||||||||||
Make the FilterConfig of this filter available, if any.
| |||||||||||
Standard way of initializing this filter.
| |||||||||||
Stores the bean name as defined in the Spring bean factory.
| |||||||||||
Set the
Environment that this object runs in.
Any environment set here overrides the | |||||||||||
Stores the ServletContext that the bean factory runs in.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
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.
| |||||||||||
Make the name of this filter available to subclasses.
| |||||||||||
Make the ServletContext of this filter available to subclasses.
| |||||||||||
Initialize the BeanWrapper for this GenericFilterBean,
possibly with custom editors.
| |||||||||||
Subclasses may override this to perform custom initialization.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
javax.servlet.Filter
| |||||||||||
From interface
org.springframework.beans.factory.BeanNameAware
| |||||||||||
From interface
org.springframework.beans.factory.DisposableBean
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
| |||||||||||
From interface
org.springframework.context.EnvironmentAware
| |||||||||||
From interface
org.springframework.web.context.ServletContextAware
|
Logger available to subclasses
Calls the initFilterBean()
method that might
contain custom initialization of a subclass.
Only relevant in case of initialization as bean, where the
standard init(FilterConfig)
method won't be called.
ServletException |
---|
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.
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.
null
if none availableStandard way of initializing this filter. Map config parameters onto bean properties of this filter, and invoke subclass initialization.
filterConfig | the configuration for this filter |
---|
ServletException | if bean properties are invalid (or required properties are missing), or if subclass initialization fails. |
---|
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.
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. |
---|
Set the Environment
that this object runs in.
Any environment set here overrides the DefaultWebEnvironment
provided by default.
Stores the ServletContext that the bean factory runs in.
Only relevant in case of initialization as bean, to have a ServletContext as fallback to the context usually provided by a FilterConfig instance.
servletContext | ServletContext object to be used by this object |
---|
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.
property | name of the required property |
---|
Make the name of this filter available to subclasses.
Analogous to GenericServlet's getServletName()
.
Takes the FilterConfig's filter name by default. If initialized as bean in a Spring application context, it falls back to the bean name as defined in the bean factory.
null
if none availableMake the ServletContext of this filter available to subclasses.
Analogous to GenericServlet's getServletContext()
.
Takes the FilterConfig's ServletContext by default. If initialized as bean in a Spring application context, it falls back to the ServletContext that the bean factory runs in.
null
if none availableInitialize the BeanWrapper for this GenericFilterBean, possibly with custom editors.
This default implementation is empty.
bw | the BeanWrapper to initialize |
---|
BeansException | if thrown by BeanWrapper methods |
---|
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.
ServletException | if subclass initialization fails |
---|