|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.filter.GenericFilterBean org.springframework.web.filter.OncePerRequestFilter
Filter base class that guarantees to be just executed once per request, on any servlet container. It provides a doFilterInternal method with HttpServletRequest and HttpServletResponse arguments.
How to identify that a request is already filtered is determined by the getAlreadyFilteredAttributeName method. The default implementation is based on the class name of the concrete filter, but this can be made more specific by overriding that method in subclasses.
doFilterInternal(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain)
,
getAlreadyFilteredAttributeName()
Field Summary | |
static java.lang.String |
ALREADY_FILTERED_SUFFIX
Suffix that gets appended to the actual class name for the "already filtered" request attribute. |
Fields inherited from class org.springframework.web.filter.GenericFilterBean |
logger |
Constructor Summary | |
OncePerRequestFilter()
|
Method Summary | |
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain filterChain)
This doFilter implementation stores a request attribute for "already filtered", proceeding without filtering again if the attribute is already there. |
protected abstract void |
doFilterInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain filterChain)
Same contract as for doFilter, but guaranteed to be just invoked once per request. |
protected java.lang.String |
getAlreadyFilteredAttributeName()
Return the name of the request attribute that identifies that a request is already filtered. |
protected boolean |
shouldNotFilter(javax.servlet.http.HttpServletRequest request)
Can return true to avoid filtering of the given request. |
Methods inherited from class org.springframework.web.filter.GenericFilterBean |
addRequiredProperty, destroy, getFilterConfig, getFilterName, getServletContext, init, initFilterBean |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String ALREADY_FILTERED_SUFFIX
getAlreadyFilteredAttributeName()
,
Constant Field ValuesConstructor Detail |
public OncePerRequestFilter()
Method Detail |
public final void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain filterChain) throws javax.servlet.ServletException, java.io.IOException
javax.servlet.ServletException
java.io.IOException
getAlreadyFilteredAttributeName()
,
shouldNotFilter(javax.servlet.http.HttpServletRequest)
,
doFilterInternal(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, javax.servlet.FilterChain)
protected java.lang.String getAlreadyFilteredAttributeName()
Subclasses can override this to get more specific identification. For example, a certain filter class could be applied multiple times but with different configuration: The attribute name should identify the particular configuration then.
ALREADY_FILTERED_SUFFIX
protected boolean shouldNotFilter(javax.servlet.http.HttpServletRequest request) throws javax.servlet.ServletException
request
- current HTTP request
javax.servlet.ServletException
- in case of errorsprotected abstract void doFilterInternal(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain filterChain) throws javax.servlet.ServletException, java.io.IOException
javax.servlet.ServletException
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |