org.riotfamily.common.web.interceptor
Class ChainedHandlerInterceptor

java.lang.Object
  extended by org.riotfamily.common.web.interceptor.ChainedHandlerInterceptor
All Implemented Interfaces:
InitializingBean, HandlerInterceptor

public class ChainedHandlerInterceptor
extends Object
implements HandlerInterceptor, InitializingBean

HandlerInterceptor that delegates calls to a list of interceptors. Supported interceptor types are HandlerInterceptor and WebRequestInterceptor.

Since:
6.5
Author:
Felix Gnass [fgnass at neteye dot de]
See Also:
setInterceptors(List)

Constructor Summary
ChainedHandlerInterceptor()
           
 
Method Summary
protected  HandlerInterceptor adaptInterceptor(Object interceptor)
          Adapt the given interceptor object to the HandlerInterceptor interface.
 void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
          Delegates the call to all configured interceptors.
 void afterPropertiesSet()
          Calls the initInterceptors() method.
protected  void initInterceptors()
          Initialize the specified interceptors, adapting them where necessary.
 void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
          Delegates the call to all configured interceptors.
 boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
          Delegates the call to all configured interceptors.
 void setInterceptors(List<HandlerInterceptor> interceptors)
          Set the interceptors to apply in a chain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChainedHandlerInterceptor

public ChainedHandlerInterceptor()
Method Detail

setInterceptors

public void setInterceptors(List<HandlerInterceptor> interceptors)
Set the interceptors to apply in a chain.

Supported interceptor types are HandlerInterceptor and WebRequestInterceptor.

Parameters:
interceptors - array of handler interceptors, or null if none
See Also:
HandlerInterceptor, WebRequestInterceptor

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Calls the initInterceptors() method.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

initInterceptors

protected void initInterceptors()
Initialize the specified interceptors, adapting them where necessary.

See Also:
setInterceptors(java.util.List), adaptInterceptor(java.lang.Object)

adaptInterceptor

protected HandlerInterceptor adaptInterceptor(Object interceptor)
Adapt the given interceptor object to the HandlerInterceptor interface.

Supported interceptor types are HandlerInterceptor and WebRequestInterceptor. Each given WebRequestInterceptor will be wrapped in a WebRequestHandlerInterceptorAdapter. Can be overridden in subclasses.

Parameters:
interceptor - the specified interceptor object
Returns:
the interceptor wrapped as HandlerInterceptor
See Also:
HandlerInterceptor, WebRequestInterceptor, WebRequestHandlerInterceptorAdapter

preHandle

public boolean preHandle(HttpServletRequest request,
                         HttpServletResponse response,
                         Object handler)
                  throws Exception
Delegates the call to all configured interceptors. If an interceptor returns false the chain is not further processes and the method returns false itself. Otherwise true is returned after all interceptors have been called.

Specified by:
preHandle in interface HandlerInterceptor
Throws:
Exception

postHandle

public void postHandle(HttpServletRequest request,
                       HttpServletResponse response,
                       Object handler,
                       ModelAndView modelAndView)
                throws Exception
Delegates the call to all configured interceptors.

Specified by:
postHandle in interface HandlerInterceptor
Throws:
Exception

afterCompletion

public void afterCompletion(HttpServletRequest request,
                            HttpServletResponse response,
                            Object handler,
                            Exception ex)
                     throws Exception
Delegates the call to all configured interceptors.

Specified by:
afterCompletion in interface HandlerInterceptor
Throws:
Exception