Class AbstractFilter
java.lang.Object
org.apache.shiro.web.servlet.ServletContextSupport
org.apache.shiro.web.servlet.AbstractFilter
- All Implemented Interfaces:
javax.servlet.Filter
- Direct Known Subclasses:
NameableFilter
Base abstract Filter simplifying Filter initialization and
access to init parameters.
Subclass initialization logic should be performed by overriding the onFilterConfigSet() template method.
FilterChain execution logic (the
Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain) method
is left to subclasses.- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected javax.servlet.FilterConfigFilterConfig provided by the Servlet container at start-up. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Default no-op implementation that can be overridden by subclasses for custom cleanup behavior.javax.servlet.FilterConfigReturns the servlet container specifiedFilterConfiginstance provided atstartup.protected StringgetInitParam(String paramName) Returns the value for the namedinit-param, ornullif there was noinit-paramspecified by that name.final voidinit(javax.servlet.FilterConfig filterConfig) Sets the filter'sfilterConfigand then immediately callsonFilterConfigSet()to trigger any processing a subclass might wish to perform.protected voidTemplate method to be overridden by subclasses to perform initialization logic at start-up.voidsetFilterConfig(javax.servlet.FilterConfig filterConfig) Sets the FilterConfig and theServletContextas attributes of this class for use by subclasses.Methods inherited from class org.apache.shiro.web.servlet.ServletContextSupport
getContextAttribute, getContextInitParam, getServletContext, removeContextAttribute, setContextAttribute, setServletContext, toString, toStringBuilderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface javax.servlet.Filter
doFilter
-
Field Details
-
filterConfig
FilterConfig provided by the Servlet container at start-up.
-
-
Constructor Details
-
AbstractFilter
public AbstractFilter()
-
-
Method Details
-
getFilterConfig
Returns the servlet container specifiedFilterConfiginstance provided atstartup.- Returns:
- the servlet container specified
FilterConfiginstance provided at start-up.
-
setFilterConfig
Sets the FilterConfig and theServletContextas attributes of this class for use by subclasses. That is:this.filterConfig = filterConfig; setServletContext(filterConfig.getServletContext());
- Parameters:
filterConfig- the FilterConfig instance provided by the Servlet container at start-up.
-
getInitParam
Returns the value for the namedinit-param, ornullif there was noinit-paramspecified by that name.- Parameters:
paramName- the name of theinit-param- Returns:
- the value for the named
init-param, ornullif there was noinit-paramspecified by that name.
-
init
public final void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException Sets the filter'sfilterConfigand then immediately callsonFilterConfigSet()to trigger any processing a subclass might wish to perform.- Specified by:
initin interfacejavax.servlet.Filter- Parameters:
filterConfig- the servlet container supplied FilterConfig instance.- Throws:
javax.servlet.ServletException- ifonFilterConfigSet()throws an Exception.
-
onFilterConfigSet
Template method to be overridden by subclasses to perform initialization logic at start-up. TheServletContextandFilterConfigwill be accessible (and non-null) at the time this method is invoked via thegetServletContext()andgetFilterConfig()methods respectively.init-paramvalues may be conveniently obtained via thegetInitParam(String)method.- Throws:
Exception- if the subclass has an error upon initialization.
-
destroy
Default no-op implementation that can be overridden by subclasses for custom cleanup behavior.- Specified by:
destroyin interfacejavax.servlet.Filter
-