|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jsecurity.web.servlet.ServletContextSupport
org.jsecurity.web.servlet.OncePerRequestFilter
org.jsecurity.web.servlet.AdviceFilter
public abstract class AdviceFilter
A Servlet Filter that enables AOP-style advice for a SerlvetRequest via
preHandle,
postHandle,
and afterCompletion
hooks.
| Field Summary |
|---|
| Fields inherited from class org.jsecurity.web.servlet.OncePerRequestFilter |
|---|
ALREADY_FILTERED_SUFFIX, filterConfig |
| Fields inherited from class org.jsecurity.web.servlet.ServletContextSupport |
|---|
HTTP_SESSION_MODE, JSECURITY_SESSION_MODE, SESSION_MODE_CONTEXT_PARAM_NAME |
| Constructor Summary | |
|---|---|
AdviceFilter()
|
|
| Method Summary | |
|---|---|
void |
afterCompletion(ServletRequest request,
ServletResponse response,
Exception exception)
Called in all cases in a finally block even if preHandle returns
false or if an exception is thrown during filter chain processing. |
protected void |
cleanup(ServletRequest request,
ServletResponse response,
Exception existing)
Executes cleanup logic in the finally code block in the
doFilterInternal
implementation. |
void |
doFilterInternal(ServletRequest request,
ServletResponse response,
FilterChain chain)
Actually implements the chain execution logic, utilizing pre,
post, and
after
advice hooks. |
protected void |
executeChain(ServletRequest request,
ServletResponse response,
FilterChain chain)
Actually executes the specified filter chain by calling chain.doFilter(request,response);. |
protected void |
postHandle(ServletRequest request,
ServletResponse response)
Allows 'post' advice logic to be called, but only if no exception occurs during filter chain execution. |
protected boolean |
preHandle(ServletRequest request,
ServletResponse response)
Returns true if the filter chain should be allowed to continue, false otherwise. |
| Methods inherited from class org.jsecurity.web.servlet.OncePerRequestFilter |
|---|
destroy, doFilter, getAlreadyFilteredAttributeName, getFilterConfig, getName, init, onFilterConfigSet, setFilterConfig, setName, shouldNotFilter |
| Methods inherited from class org.jsecurity.web.servlet.ServletContextSupport |
|---|
bind, getAttribute, getContextInitParam, getServletContext, removeAttribute, setAttribute, setServletContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AdviceFilter()
| Method Detail |
|---|
protected boolean preHandle(ServletRequest request,
ServletResponse response)
throws Exception
true if the filter chain should be allowed to continue, false otherwise.
It is called before the chain is actually consulted/executed.
The default implementation returns true always and exists as a template method for subclasses.
request - the incoming ServletRequestresponse - the outgoing ServletResponse
true if the filter chain should be allowed to continue, false otherwise.
Exception - if there is any error.
protected void postHandle(ServletRequest request,
ServletResponse response)
throws Exception
executeChain throws an exception, this method will never be called. Be aware of
this when implementing logic. Most resource 'cleanup' behavior is often done in the
afterCompletion(request,response,exception)
implementation, which is guaranteed to be called for every request, even when the chain processing throws
an Exception.
The default implementation does nothing (no-op) and exists as a template method for subclasses.
request - the incoming ServletRequestresponse - the outgoing ServletResponse
Exception - if an error occurs.
public void afterCompletion(ServletRequest request,
ServletResponse response,
Exception exception)
throws Exception
finally block even if preHandle returns
false or if an exception is thrown during filter chain processing. Can be used for resource
cleanup if so desired.
The default implementation does nothing (no-op) and exists as a template method for subclasses.
request - the incoming ServletRequestresponse - the outgoing ServletResponseexception - any exception thrown during preHandle, executeChain,
or postHandle execution, or null if no exception was thrown
(i.e. the chain processed successfully).
Exception - if an error occurs.
protected void executeChain(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws Exception
chain.doFilter(request,response);.
Can be overridden by subclasses for custom logic.
request - the incoming ServletRequestresponse - the outgoing ServletResponsechain - the filter chain to execute
Exception - if there is any error executing the chain.
public void doFilterInternal(ServletRequest request,
ServletResponse response,
FilterChain chain)
throws ServletException,
IOException
pre,
post, and
after
advice hooks.
doFilterInternal in class OncePerRequestFilterrequest - the incoming ServletRequestresponse - the outgoing ServletResponsechain - the filter chain to execute
ServletException - if a servlet-related error occurs
IOException - if an IO error occurs
protected void cleanup(ServletRequest request,
ServletResponse response,
Exception existing)
throws ServletException,
IOException
finally code block in the
doFilterInternal
implementation.
This implementation specifically calls
afterCompletion
as well as handles any exceptions properly.
request - the incoming ServletRequestresponse - the outgoing ServletResponseexisting - any exception that might have occurred while executing the FilterChain or
pre or post advice, or null if the pre/chain/post excution did not throw an Exception.
ServletException - if any exception other than an IOException is thrown.
IOException - if the pre/chain/post execution throw an IOException
|
JSecurity | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||