|
|||||||||
| Home >> All >> net >> sf >> acegisecurity >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
net.sf.acegisecurity.util
Class FilterChainProxy

java.lang.Objectnet.sf.acegisecurity.util.FilterChainProxy
- All Implemented Interfaces:
- org.springframework.context.ApplicationContextAware, javax.servlet.Filter, org.springframework.beans.factory.InitializingBean
- public class FilterChainProxy
- extends java.lang.Object
- implements javax.servlet.Filter, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware
- extends java.lang.Object
Delegates Filter requests to a list of Spring-managed beans.
The FilterChainProxy is loaded via a standard FilterToBeanProxy declaration in
web.xml. FilterChainProxy will then pass init(FilterConfig) 55 , destroy() 55 , #doInit() and doFilter(ServletRequest, ServletResponse, FilterChain) 55 invocations
through to each Filter defined against
FilterChainProxy.
FilterChainProxy is configured using a standard net.sf.acegisecurity.intercept.web.FilterInvocationDefinitionSource. Each
possible URI pattern that FilterChainProxy should service must
be entered. The first matching URI pattern located by
FilterInvocationDefinitionSource for a given request will be
used to define all of the Filters that apply to that request.
NB: This means you must put most specific URI patterns at the top of the
list, and ensure all Filters that should apply for a given URI
pattern are entered against the respective entry. The
FilterChainProxy will not iterate the remainder of the URI
patterns to locate additional Filters. The
FilterInvocationDefinitionSource described the applicable URI
pattern to fire the filter chain, followed by a list of configuration
attributes. Each configuration attribute's ConfigAttribute.getAttribute()>ConfigAttribute.getAttribute() 55 corresponds to a bean
name that is available from the application context.
FilterChainProxy respects normal handling of
Filters that elect not to call Filter.doFilter(javax.servlet.ServletRequest,
javax.servlet.ServletResponse, javax.servlet.FilterChain)>Filter.doFilter(javax.servlet.ServletRequest,
javax.servlet.ServletResponse, javax.servlet.FilterChain) 55 , in that the
remainder of the origial or FilterChainProxy-declared filter
chain will not be called.
It is particularly noted the Filter lifecycle mismatch between
the servlet container and IoC container. As per FilterToBeanProxy JavaDocs, we recommend you
allow the IoC container to manage lifecycle instead of the servlet
container. By default the FilterToBeanProxy will never call
this class' init(FilterConfig) 55 and destroy() 55 methods,
meaning each of the filters defined against
FilterInvocationDefinitionSource will not be called. If you do
need your filters to be initialized and destroyed, please set the
lifecycle initialization parameter against the
FilterToBeanProxy to specify servlet container lifecycle
management.
- Version:
- $Id: FilterChainProxy.java,v 1.4 2005/04/15 01:21:41 luke_t Exp $
| Nested Class Summary | |
private class |
FilterChainProxy.VirtualFilterChain
A FilterChain that records whether or not FilterChain.doFilter(javax.servlet.ServletRequest,
javax.servlet.ServletResponse)>FilterChain.doFilter(javax.servlet.ServletRequest,
javax.servlet.ServletResponse) 55 is called. |
| Field Summary | |
private org.springframework.context.ApplicationContext |
applicationContext
|
private net.sf.acegisecurity.intercept.web.FilterInvocationDefinitionSource |
filterInvocationDefinitionSource
|
private static org.apache.commons.logging.Log |
logger
|
| Constructor Summary | |
FilterChainProxy()
|
|
| Method Summary | |
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware). |
void |
destroy()
Called by the web container to indicate to a filter that it is being taken out of service. |
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
The doFilter method of the Filter is called by the container
each time a request/response pair is passed through the chain due
to a client request for a resource at the end of the chain. |
net.sf.acegisecurity.intercept.web.FilterInvocationDefinitionSource |
getFilterInvocationDefinitionSource()
|
void |
init(javax.servlet.FilterConfig filterConfig)
Called by the web container to indicate to a filter that it is being placed into service. |
private javax.servlet.Filter[] |
obtainAllDefinedFilters()
Obtains all of the unique Filter instances registered
against the FilterInvocationDefinitionSource. |
private javax.servlet.Filter[] |
obtainAllDefinedFilters(net.sf.acegisecurity.ConfigAttributeDefinition configAttributeDefinition)
Obtains all of the Filter instances registered against the
specified ConfigAttributeDefinition. |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in. |
void |
setFilterInvocationDefinitionSource(net.sf.acegisecurity.intercept.web.FilterInvocationDefinitionSource filterInvocationDefinitionSource)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
logger
private static final org.apache.commons.logging.Log logger
applicationContext
private org.springframework.context.ApplicationContext applicationContext
filterInvocationDefinitionSource
private net.sf.acegisecurity.intercept.web.FilterInvocationDefinitionSource filterInvocationDefinitionSource
| Constructor Detail |
FilterChainProxy
public FilterChainProxy()
| Method Detail |
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
- Description copied from interface:
org.springframework.context.ApplicationContextAware - Set the ApplicationContext that this object runs in.
Normally this call will be used to initialize the object.
Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked after ResourceLoaderAware's setResourceLoader.
- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
setFilterInvocationDefinitionSource
public void setFilterInvocationDefinitionSource(net.sf.acegisecurity.intercept.web.FilterInvocationDefinitionSource filterInvocationDefinitionSource)
getFilterInvocationDefinitionSource
public net.sf.acegisecurity.intercept.web.FilterInvocationDefinitionSource getFilterInvocationDefinitionSource()
afterPropertiesSet
public void afterPropertiesSet()
throws java.lang.Exception
- Description copied from interface:
org.springframework.beans.factory.InitializingBean - Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
destroy
public void destroy()
- Description copied from interface:
javax.servlet.Filter - Called by the web container to indicate to a filter that it is being taken out of service. This
method is only called once all threads within the filter's doFilter method have exited or after
a timeout period has passed. After the web container calls this method, it will not call the
doFilter method again on this instance of the filter.
This method gives the filter an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the filter's current state in memory.- Specified by:
destroyin interfacejavax.servlet.Filter
doFilter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletException
- Description copied from interface:
javax.servlet.Filter - The
doFiltermethod of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. The FilterChain passed in to this method allows the Filter to pass on the request and response to the next entity in the chain.A typical implementation of this method would follow the following pattern:-
1. Examine the request
2. Optionally wrap the request object with a custom implementation to filter content or headers for input filtering
3. Optionally wrap the response object with a custom implementation to filter content or headers for output filtering
4. a) Either invoke the next entity in the chain using the FilterChain object (chain.doFilter()),
4. b) or not pass on the request/response pair to the next entity in the filter chain to block the request processing
5. Directly set headers on the response after invocation of the next entity in the filter chain.- Specified by:
doFilterin interfacejavax.servlet.Filter
init
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
- Description copied from interface:
javax.servlet.Filter - Called by the web container to indicate to a filter that it is being placed into
service. The servlet container calls the init method exactly once after instantiating the
filter. The init method must complete successfully before the filter is asked to do any
filtering work.
The web container cannot place the filter into service if the init method either
1.Throws a ServletException
2.Does not return within a time period defined by the web container- Specified by:
initin interfacejavax.servlet.Filter
obtainAllDefinedFilters
private javax.servlet.Filter[] obtainAllDefinedFilters()
- Obtains all of the unique
Filterinstances registered against theFilterInvocationDefinitionSource.This is useful in ensuring a
Filteris not initialized or destroyed twice.
obtainAllDefinedFilters
private javax.servlet.Filter[] obtainAllDefinedFilters(net.sf.acegisecurity.ConfigAttributeDefinition configAttributeDefinition)
- Obtains all of the
Filterinstances registered against the specifiedConfigAttributeDefinition.
|
|||||||||
| Home >> All >> net >> sf >> acegisecurity >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
net.sf.acegisecurity.util.FilterChainProxy