Spring Framework

org.springframework.web.portlet.handler
Class WebRequestHandlerInterceptorAdapter

java.lang.Object
  extended by org.springframework.web.portlet.handler.WebRequestHandlerInterceptorAdapter
All Implemented Interfaces:
HandlerInterceptor

public class WebRequestHandlerInterceptorAdapter
extends java.lang.Object
implements HandlerInterceptor

Adapter that implements the Portlet HandlerInterceptor interface and wraps an underlying WebRequestInterceptor.

NOTE: The WebRequestInterceptor is by default only applied to the Portlet render phase, which is dealing with preparing and rendering a Portlet view. The Portlet action phase will only be intercepted with WebRequestInterceptor calls if the renderPhaseOnly flag is explicitly set to false. In general, it is recommended to use the Portlet-specific HandlerInterceptor mechanism for differentiating between action and render interception.

Since:
2.0
Author:
Juergen Hoeller
See Also:
WebRequestInterceptor, HandlerInterceptor

Constructor Summary
WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor)
          Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor, applying to the render phase only.
WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor, boolean renderPhaseOnly)
          Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.
 
Method Summary
 void afterActionCompletion(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response, java.lang.Object handler, java.lang.Exception ex)
          Callback after completion of request processing in the action phase, that is, after rendering the view.
 void afterEventCompletion(javax.portlet.EventRequest request, javax.portlet.EventResponse response, java.lang.Object handler, java.lang.Exception ex)
          Callback after completion of request processing in the action phase, that is, after rendering the view.
 void afterRenderCompletion(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, java.lang.Object handler, java.lang.Exception ex)
          Callback after completion of request processing, that is, after rendering the view.
 void afterResourceCompletion(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response, java.lang.Object handler, java.lang.Exception ex)
          Callback after completion of request processing, that is, after rendering the view.
 void postHandleRender(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, java.lang.Object handler, ModelAndView modelAndView)
          Intercept the execution of a handler in the render phase.
 void postHandleResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response, java.lang.Object handler, ModelAndView modelAndView)
          Intercept the execution of a handler in the render phase.
 boolean preHandleAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response, java.lang.Object handler)
          Intercept the execution of a handler in the action phase.
 boolean preHandleEvent(javax.portlet.EventRequest request, javax.portlet.EventResponse response, java.lang.Object handler)
          Intercept the execution of a handler in the action phase.
 boolean preHandleRender(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, java.lang.Object handler)
          Intercept the execution of a handler in the render phase.
 boolean preHandleResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response, java.lang.Object handler)
          Intercept the execution of a handler in the render phase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebRequestHandlerInterceptorAdapter

public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor)
Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor, applying to the render phase only.

Parameters:
requestInterceptor - the WebRequestInterceptor to wrap

WebRequestHandlerInterceptorAdapter

public WebRequestHandlerInterceptorAdapter(WebRequestInterceptor requestInterceptor,
                                           boolean renderPhaseOnly)
Create a new WebRequestHandlerInterceptorAdapter for the given WebRequestInterceptor.

Parameters:
requestInterceptor - the WebRequestInterceptor to wrap
renderPhaseOnly - whether to apply to the render phase only (true) or to the action phase as well (false)
Method Detail

preHandleAction

public boolean preHandleAction(javax.portlet.ActionRequest request,
                               javax.portlet.ActionResponse response,
                               java.lang.Object handler)
                        throws java.lang.Exception
Description copied from interface: HandlerInterceptor
Intercept the execution of a handler in the action phase.

Called after a HandlerMapping determines an appropriate handler object to handle an ActionRequest, but before said HandlerAdapter actually invokes the handler.

DispatcherPortlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can decide to abort the execution chain, typically throwing an exception or writing a custom response.

Specified by:
preHandleAction in interface HandlerInterceptor
Parameters:
request - current portlet action request
response - current portlet action response
handler - chosen handler to execute, for type and/or instance evaluation
Returns:
true if the execution chain should proceed with the next interceptor or the handler itself. Else, DispatcherPortlet assumes that this interceptor has already dealt with the response itself
Throws:
java.lang.Exception - in case of errors

afterActionCompletion

public void afterActionCompletion(javax.portlet.ActionRequest request,
                                  javax.portlet.ActionResponse response,
                                  java.lang.Object handler,
                                  java.lang.Exception ex)
                           throws java.lang.Exception
Description copied from interface: HandlerInterceptor
Callback after completion of request processing in the action phase, that is, after rendering the view. Will be called on any outcome of handler execution, thus allowing for proper resource cleanup.

Note: Will only be called if this interceptor's HandlerInterceptor.preHandleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) method has successfully completed and returned true!

Specified by:
afterActionCompletion in interface HandlerInterceptor
Parameters:
request - current portlet action request
response - current portlet action response
handler - chosen handler to execute, for type and/or instance examination
ex - exception thrown on handler execution, if any (only included as additional context information for the case where a handler threw an exception; request execution may have failed even when this argument is null)
Throws:
java.lang.Exception - in case of errors

preHandleRender

public boolean preHandleRender(javax.portlet.RenderRequest request,
                               javax.portlet.RenderResponse response,
                               java.lang.Object handler)
                        throws java.lang.Exception
Description copied from interface: HandlerInterceptor
Intercept the execution of a handler in the render phase.

Called after a HandlerMapping determines an appropriate handler object to handle a RenderRequest, but before said HandlerAdapter actually invokes the handler.

DispatcherPortlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can decide to abort the execution chain, typically throwing an exception or writing a custom response.

Specified by:
preHandleRender in interface HandlerInterceptor
Parameters:
request - current portlet render request
response - current portlet render response
handler - chosen handler to execute, for type and/or instance evaluation
Returns:
true if the execution chain should proceed with the next interceptor or the handler itself. Else, DispatcherPortlet assumes that this interceptor has already dealt with the response itself
Throws:
java.lang.Exception - in case of errors

postHandleRender

public void postHandleRender(javax.portlet.RenderRequest request,
                             javax.portlet.RenderResponse response,
                             java.lang.Object handler,
                             ModelAndView modelAndView)
                      throws java.lang.Exception
Description copied from interface: HandlerInterceptor
Intercept the execution of a handler in the render phase.

Called after a HandlerAdapter actually invoked the handler, but before the DispatcherPortlet renders the view. Can thus expose additional model objects to the view via the given ModelAndView.

DispatcherPortlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can post-process an execution, getting applied in inverse order of the execution chain.

Specified by:
postHandleRender in interface HandlerInterceptor
Parameters:
request - current portlet render request
response - current portlet render response
handler - chosen handler to execute, for type and/or instance examination
modelAndView - the ModelAndView that the handler returned (can also be null)
Throws:
java.lang.Exception - in case of errors

afterRenderCompletion

public void afterRenderCompletion(javax.portlet.RenderRequest request,
                                  javax.portlet.RenderResponse response,
                                  java.lang.Object handler,
                                  java.lang.Exception ex)
                           throws java.lang.Exception
Description copied from interface: HandlerInterceptor
Callback after completion of request processing, that is, after rendering the view. Will be called on any outcome of handler execution, thus allowing for proper resource cleanup.

Note: Will only be called if this interceptor's HandlerInterceptor.preHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) method has successfully completed and returned true!

Specified by:
afterRenderCompletion in interface HandlerInterceptor
Parameters:
request - current portlet render request
response - current portlet render response
handler - chosen handler to execute, for type and/or instance examination
ex - exception thrown on handler execution, if any
Throws:
java.lang.Exception - in case of errors

preHandleResource

public boolean preHandleResource(javax.portlet.ResourceRequest request,
                                 javax.portlet.ResourceResponse response,
                                 java.lang.Object handler)
                          throws java.lang.Exception
Description copied from interface: HandlerInterceptor
Intercept the execution of a handler in the render phase.

Called after a HandlerMapping determines an appropriate handler object to handle a RenderRequest, but before said HandlerAdapter actually invokes the handler.

DispatcherPortlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can decide to abort the execution chain, typically throwing an exception or writing a custom response.

Specified by:
preHandleResource in interface HandlerInterceptor
Parameters:
request - current portlet render request
response - current portlet render response
handler - chosen handler to execute, for type and/or instance evaluation
Returns:
true if the execution chain should proceed with the next interceptor or the handler itself. Else, DispatcherPortlet assumes that this interceptor has already dealt with the response itself
Throws:
java.lang.Exception - in case of errors

postHandleResource

public void postHandleResource(javax.portlet.ResourceRequest request,
                               javax.portlet.ResourceResponse response,
                               java.lang.Object handler,
                               ModelAndView modelAndView)
                        throws java.lang.Exception
Description copied from interface: HandlerInterceptor
Intercept the execution of a handler in the render phase.

Called after a HandlerAdapter actually invoked the handler, but before the DispatcherPortlet renders the view. Can thus expose additional model objects to the view via the given ModelAndView.

DispatcherPortlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can post-process an execution, getting applied in inverse order of the execution chain.

Specified by:
postHandleResource in interface HandlerInterceptor
Parameters:
request - current portlet render request
response - current portlet render response
handler - chosen handler to execute, for type and/or instance examination
modelAndView - the ModelAndView that the handler returned (can also be null)
Throws:
java.lang.Exception - in case of errors

afterResourceCompletion

public void afterResourceCompletion(javax.portlet.ResourceRequest request,
                                    javax.portlet.ResourceResponse response,
                                    java.lang.Object handler,
                                    java.lang.Exception ex)
                             throws java.lang.Exception
Description copied from interface: HandlerInterceptor
Callback after completion of request processing, that is, after rendering the view. Will be called on any outcome of handler execution, thus allowing for proper resource cleanup.

Note: Will only be called if this interceptor's HandlerInterceptor.preHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) method has successfully completed and returned true!

Specified by:
afterResourceCompletion in interface HandlerInterceptor
Parameters:
request - current portlet render request
response - current portlet render response
handler - chosen handler to execute, for type and/or instance examination
ex - exception thrown on handler execution, if any
Throws:
java.lang.Exception - in case of errors

preHandleEvent

public boolean preHandleEvent(javax.portlet.EventRequest request,
                              javax.portlet.EventResponse response,
                              java.lang.Object handler)
                       throws java.lang.Exception
Description copied from interface: HandlerInterceptor
Intercept the execution of a handler in the action phase.

Called after a HandlerMapping determines an appropriate handler object to handle an ActionRequest, but before said HandlerAdapter actually invokes the handler.

DispatcherPortlet processes a handler in an execution chain, consisting of any number of interceptors, with the handler itself at the end. With this method, each interceptor can decide to abort the execution chain, typically throwing an exception or writing a custom response.

Specified by:
preHandleEvent in interface HandlerInterceptor
Parameters:
request - current portlet action request
response - current portlet action response
handler - chosen handler to execute, for type and/or instance evaluation
Returns:
true if the execution chain should proceed with the next interceptor or the handler itself. Else, DispatcherPortlet assumes that this interceptor has already dealt with the response itself
Throws:
java.lang.Exception - in case of errors

afterEventCompletion

public void afterEventCompletion(javax.portlet.EventRequest request,
                                 javax.portlet.EventResponse response,
                                 java.lang.Object handler,
                                 java.lang.Exception ex)
                          throws java.lang.Exception
Description copied from interface: HandlerInterceptor
Callback after completion of request processing in the action phase, that is, after rendering the view. Will be called on any outcome of handler execution, thus allowing for proper resource cleanup.

Note: Will only be called if this interceptor's HandlerInterceptor.preHandleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) method has successfully completed and returned true!

Specified by:
afterEventCompletion in interface HandlerInterceptor
Parameters:
request - current portlet action request
response - current portlet action response
handler - chosen handler to execute, for type and/or instance examination
ex - exception thrown on handler execution, if any (only included as additional context information for the case where a handler threw an exception; request execution may have failed even when this argument is null)
Throws:
java.lang.Exception - in case of errors

Spring Framework