com.googlecode.webutilities.filters.common
Class AbstractFilter
java.lang.Object
com.googlecode.webutilities.filters.common.AbstractFilter
- All Implemented Interfaces:
- IgnoreAcceptContext, javax.servlet.Filter
- Direct Known Subclasses:
- CharacterEncodingFilter, ClosureCompilerFilter, CompressionFilter, ModulesFilter, NewModulesFilter, ResponseCacheFilter, YUIMinFilter
public abstract class AbstractFilter
- extends Object
- implements javax.servlet.Filter, IgnoreAcceptContext
Common AbstractFilter - infra filter code to be used by other filters
through inheritance
This is to have following infra init parameters to all the filter
- ignoreURLPattern - to ignore the URLs matching this regex
- acceptURLPattern - to process the URLs matching this regex (ignore precedes)
- ignoreMIMEPattern - to ignore if the response mime matches this regex
- acceptMIMEPattern - to process if the response mime matches this regex (ignore precedes)
- ignoreUAPattern - to ignore if request user agent name matches this regex
- acceptUAPattern - to process if request user agent name matches this regex
This filter implements IgnoreAcceptContext with the help of above init parameters and provides
easy api for inherited filters to know if given req/res to be ignored or processes.
- Version:
- 1.0
- Author:
- rpatil
- See Also:
IgnoreAcceptContext
|
Field Summary |
protected javax.servlet.FilterConfig |
filterConfig
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.servlet.Filter |
doFilter |
filterConfig
protected javax.servlet.FilterConfig filterConfig
AbstractFilter
public AbstractFilter()
init
public void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.ServletException
- Specified by:
init in interface javax.servlet.Filter
- Throws:
javax.servlet.ServletException
isURLAccepted
public boolean isURLAccepted(String url)
- Specified by:
isURLAccepted in interface IgnoreAcceptContext
- Parameters:
url - - request URL string without query parameters
- Returns:
- isAccepted - true if given URL has to be processed
isMIMEAccepted
public boolean isMIMEAccepted(String mimeType)
- Specified by:
isMIMEAccepted in interface IgnoreAcceptContext
- Parameters:
mimeType - - contentType of the chained response
- Returns:
- isAccepted - true if it is to be processed by this filter
isUserAgentAccepted
public boolean isUserAgentAccepted(String userAgent)
- Specified by:
isUserAgentAccepted in interface IgnoreAcceptContext
- Parameters:
userAgent - - requesting user agent string
- Returns:
- isAccepted - true if request by given user agent has to be processed/filtered.
destroy
public void destroy()
- Specified by:
destroy in interface javax.servlet.Filter
Copyright © 2011. All Rights Reserved.