Polishing

This commit is contained in:
Juergen Hoeller
2014-10-29 22:44:59 +01:00
parent 4927c9054f
commit 1146d5ba1d
31 changed files with 447 additions and 455 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,36 +74,32 @@ import javax.portlet.ResourceResponse;
*
* <p><b>Action Request:</b><p>
* <ol>
* <li>{@code DispatcherPortlet} maps the action request to a particular handler
* and assembles a handler execution chain consisting of the handler that
* is to be invoked and all of the {@code HandlerInterceptor}
* instances that apply to the request.</li>
* <li>{@link HandlerInterceptor#preHandleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) preHandleAction(..)}
* is called; if the invocation of this method returns {@code true} then
* this workflow continues</li>
* <li>The target handler handles the action request (via
* {@link HandlerAdapter#handleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) HandlerAdapter.handleAction(..)})</li>
* <li>{@link HandlerInterceptor#afterActionCompletion(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object, Exception) afterActionCompletion(..)}
* is called</li>
* <li>{@code DispatcherPortlet} maps the action request to a particular handler and
* assembles a handler execution chain consisting of the handler that is to be invoked
* and all of the {@code HandlerInterceptor} instances that apply to the request.</li>
* <li>{@link HandlerInterceptor#preHandleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) preHandleAction(..)}
* is called; if the invocation of this method returns {@code true} then this workflow continues.</li>
* <li>The target handler handles the action request (via
* {@link HandlerAdapter#handleAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object) HandlerAdapter.handleAction(..)}).</li>
* <li>{@link HandlerInterceptor#afterActionCompletion(javax.portlet.ActionRequest, javax.portlet.ActionResponse, Object, Exception) afterActionCompletion(..)}
* is called.</li>
* </ol>
*
* <p><b>Render Request:</b><p>
* <ol>
* <li>{@code DispatcherPortlet} maps the render request to a particular handler
* and assembles a handler execution chain consisting of the handler that
* is to be invoked and all of the {@code HandlerInterceptor}
* instances that apply to the request.</li>
* <li>{@link HandlerInterceptor#preHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) preHandleRender(..)}
* is called; if the invocation of this method returns {@code true} then
* this workflow continues</li>
* <li>The target handler handles the render request (via
* {@link HandlerAdapter#handleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) HandlerAdapter.handleRender(..)})</li>
* <li>{@link HandlerInterceptor#postHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, ModelAndView) postHandleRender(..)}
* is called</li>
* <li>If the {@code HandlerAdapter} returned a {@code ModelAndView},
* then {@code DispatcherPortlet} renders the view accordingly
* <li>{@link HandlerInterceptor#afterRenderCompletion(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, Exception) afterRenderCompletion(..)}
* is called</li>
* <li>{@code DispatcherPortlet} maps the render request to a particular handler and
* assembles a handler execution chain consisting of the handler that is to be invoked
* and all of the {@code HandlerInterceptor} instances that apply to the request.</li>
* <li>{@link HandlerInterceptor#preHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) preHandleRender(..)}
* is called; if the invocation of this method returns {@code true} then this workflow continues.</li>
* <li>The target handler handles the render request (via
* {@link HandlerAdapter#handleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object) HandlerAdapter.handleRender(..)}).</li>
* <li>{@link HandlerInterceptor#postHandleRender(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, ModelAndView) postHandleRender(..)}
* is called.</li>
* <li>If the {@code HandlerAdapter} returned a {@code ModelAndView}, then
* {@code DispatcherPortlet} renders the view accordingly.
* <li>{@link HandlerInterceptor#afterRenderCompletion(javax.portlet.RenderRequest, javax.portlet.RenderResponse, Object, Exception) afterRenderCompletion(..)}
* is called.</li>
* </ol>
*
* @author Juergen Hoeller
@@ -151,8 +147,7 @@ public interface HandlerInterceptor {
* request execution may have failed even when this argument is {@code null})
* @throws Exception in case of errors
*/
void afterActionCompletion(
ActionRequest request, ActionResponse response, Object handler, Exception ex)
void afterActionCompletion(ActionRequest request, ActionResponse response, Object handler, Exception ex)
throws Exception;
/**
@@ -191,8 +186,7 @@ public interface HandlerInterceptor {
* (can also be {@code null})
* @throws Exception in case of errors
*/
void postHandleRender(
RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView)
void postHandleRender(RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView)
throws Exception;
/**
@@ -208,8 +202,7 @@ public interface HandlerInterceptor {
* @param ex exception thrown on handler execution, if any
* @throws Exception in case of errors
*/
void afterRenderCompletion(
RenderRequest request, RenderResponse response, Object handler, Exception ex)
void afterRenderCompletion(RenderRequest request, RenderResponse response, Object handler, Exception ex)
throws Exception;
/**
@@ -248,8 +241,7 @@ public interface HandlerInterceptor {
* (can also be {@code null})
* @throws Exception in case of errors
*/
void postHandleResource(
ResourceRequest request, ResourceResponse response, Object handler, ModelAndView modelAndView)
void postHandleResource(ResourceRequest request, ResourceResponse response, Object handler, ModelAndView modelAndView)
throws Exception;
/**
@@ -265,11 +257,9 @@ public interface HandlerInterceptor {
* @param ex exception thrown on handler execution, if any
* @throws Exception in case of errors
*/
void afterResourceCompletion(
ResourceRequest request, ResourceResponse response, Object handler, Exception ex)
void afterResourceCompletion(ResourceRequest request, ResourceResponse response, Object handler, Exception ex)
throws Exception;
/**
* Intercept the execution of a handler in the action phase.
* <p>Called after a HandlerMapping determines an appropriate handler object
@@ -305,8 +295,7 @@ public interface HandlerInterceptor {
* request execution may have failed even when this argument is {@code null})
* @throws Exception in case of errors
*/
void afterEventCompletion(
EventRequest request, EventResponse response, Object handler, Exception ex)
void afterEventCompletion(EventRequest request, EventResponse response, Object handler, Exception ex)
throws Exception;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,69 +41,69 @@ import org.springframework.web.portlet.util.PortletUtils;
* <p><b><a name="workflow">Workflow
* (<a href="Controller.html#workflow">and that defined by interface</a>):</b><br>
* <ol>
* <li>If this is an action request, {@link #handleActionRequest handleActionRequest}
* will be called by the DispatcherPortlet once to perform the action defined by this
* controller.</li>
* <li>If a session is required, try to get it (PortletException if not found).</li>
* <li>Call method {@link #handleActionRequestInternal handleActionRequestInternal},
* (optionally synchronizing around the call on the PortletSession),
* which should be overridden by extending classes to provide actual functionality to
* perform the desired action of the controller. This will be executed only once.</li>
* <li>For a straight render request, or the render phase of an action request (assuming the
* same controller is called for the render phase -- see tip below),
* {@link #handleRenderRequest handleRenderRequest} will be called by the DispatcherPortlet
* repeatedly to render the display defined by this controller.</li>
* <li>If a session is required, try to get it (PortletException if none found).</li>
* <li>It will control caching as defined by the cacheSeconds property.</li>
* <li>Call method {@link #handleRenderRequestInternal handleRenderRequestInternal},
* (optionally synchronizing around the call on the PortletSession),
* which should be overridden by extending classes to provide actual functionality to
* return {@link org.springframework.web.portlet.ModelAndView ModelAndView} objects.
* This will be executed repeatedly as the portal updates the current displayed page.</li>
* <li>If this is an action request, {@link #handleActionRequest handleActionRequest}
* will be called by the DispatcherPortlet once to perform the action defined by this
* controller.</li>
* <li>If a session is required, try to get it (PortletException if not found).</li>
* <li>Call method {@link #handleActionRequestInternal handleActionRequestInternal},
* (optionally synchronizing around the call on the PortletSession),
* which should be overridden by extending classes to provide actual functionality to
* perform the desired action of the controller. This will be executed only once.</li>
* <li>For a straight render request, or the render phase of an action request (assuming the
* same controller is called for the render phase -- see tip below),
* {@link #handleRenderRequest handleRenderRequest} will be called by the DispatcherPortlet
* repeatedly to render the display defined by this controller.</li>
* <li>If a session is required, try to get it (PortletException if none found).</li>
* <li>It will control caching as defined by the cacheSeconds property.</li>
* <li>Call method {@link #handleRenderRequestInternal handleRenderRequestInternal},
* (optionally synchronizing around the call on the PortletSession),
* which should be overridden by extending classes to provide actual functionality to
* return {@link org.springframework.web.portlet.ModelAndView ModelAndView} objects.
* This will be executed repeatedly as the portal updates the current displayed page.</li>
* </ol>
*
* <p><b><a name="config">Exposed configuration properties</a>
* (<a href="Controller.html#config">and those defined by interface</a>):</b><br>
* <table border="1">
* <tr>
* <td><b>name</b></th>
* <td><b>default</b></td>
* <td><b>description</b></td>
* </tr>
* <tr>
* <td>requireSession</td>
* <td>false</td>
* <td>whether a session should be required for requests to be able to
* be handled by this controller. This ensures, derived controller
* can - without fear of Nullpointers - call request.getSession() to
* retrieve a session. If no session can be found while processing
* the request, a PortletException will be thrown</td>
* </tr>
* <tr>
* <td>synchronizeOnSession</td>
* <td>false</td>
* <td>whether the calls to {@code handleRenderRequestInternal} and
* {@code handleRenderRequestInternal} should be
* synchronized around the PortletSession, to serialize invocations
* from the same client. No effect if there is no PortletSession.
* </td>
* </tr>
* <tr>
* <td>cacheSeconds</td>
* <td>-1</td>
* <td>indicates the amount of seconds to specify caching is allowed in
* the render response generatedby this request. 0 (zero) will indicate
* no caching is allowed at all, -1 (the default) will not override the
* portlet configuration and any positive number will cause the render
* response to declare the amount indicated as seconds to cache the content</td>
* </tr>
* <tr>
* <td>renderWhenMinimized</td>
* <td>false</td>
* <td>whether should be rendered when the portlet is in a minimized state --
* will return null for the ModelandView when the portlet is minimized
* and this is false</td>
* </tr>
* <tr>
* <td><b>name</b></th>
* <td><b>default</b></td>
* <td><b>description</b></td>
* </tr>
* <tr>
* <td>requireSession</td>
* <td>false</td>
* <td>whether a session should be required for requests to be able to
* be handled by this controller. This ensures, derived controller
* can - without fear of Nullpointers - call request.getSession() to
* retrieve a session. If no session can be found while processing
* the request, a PortletException will be thrown</td>
* </tr>
* <tr>
* <td>synchronizeOnSession</td>
* <td>false</td>
* <td>whether the calls to {@code handleRenderRequestInternal} and
* {@code handleRenderRequestInternal} should be synchronized around
* the PortletSession, to serialize invocations from the same client.
* No effect if there is no PortletSession.
* </td>
* </tr>
* <tr>
* <td>cacheSeconds</td>
* <td>-1</td>
* <td>indicates the amount of seconds to specify caching is allowed in
* the render response generatedby this request. 0 (zero) will indicate
* no caching is allowed at all, -1 (the default) will not override the
* portlet configuration and any positive number will cause the render
* response to declare the amount indicated as seconds to cache the content</td>
* </tr>
* <tr>
* <td>renderWhenMinimized</td>
* <td>false</td>
* <td>whether should be rendered when the portlet is in a minimized state --
* will return null for the ModelandView when the portlet is minimized
* and this is false</td>
* </tr>
* </table>
*
* <p><b>TIP:</b> The controller mapping will be run twice by the PortletDispatcher for

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,42 +22,37 @@ import javax.portlet.RenderResponse;
import org.springframework.web.portlet.ModelAndView;
/**
* <p>Trivial controller that always returns a named view. The view
* can be configured using an exposed configuration property. This
* controller offers an alternative to sending a request straight to a view
* such as a JSP. The advantage here is that the client is not exposed to
* the concrete view technology but rather just to the controller URL;
* the concrete view will be determined by the ViewResolver.</p>
* Trivial controller that always returns a named view. The view can be configured
* using an exposed configuration property. This controller offers an alternative
* to sending a request straight to a view such as a JSP. The advantage here is
* that the client is not exposed to the concrete view technology but rather just
* to the controller URL; the concrete view will be determined by the ViewResolver.
*
* <p><b><a name="workflow">Workflow
* (<a href="AbstractController.html#workflow">and that defined by superclass</a>):</b><br>
* (<a href="AbstractController.html#workflow">and that defined by superclass</a>):</b>
* <ol>
* <li>Render request is received by the controller</li>
* <li>call to {@link #handleRenderRequestInternal handleRenderRequestInternal} which
* just returns the view, named by the configuration property
* {@code viewName}. Nothing more, nothing less</li>
* <li>Render request is received by the controller</li>
* <li>call to {@link #handleRenderRequestInternal handleRenderRequestInternal} which
* just returns the view, named by the configuration property {@code viewName}.</li>
* </ol>
* </p>
*
* <p>This controller does not handle action requests.</p>
* <p>This controller does not handle action requests.
*
* <p><b><a name="config">Exposed configuration properties</a>
* (<a href="AbstractController.html#config">and those defined by superclass</a>):</b><br>
* (<a href="AbstractController.html#config">and those defined by superclass</a>):</b>
* <table border="1">
* <tr>
* <td><b>name</b></td>
* <td><b>default</b></td>
* <td><b>description</b></td>
* </tr>
* <tr>
* <td>viewName</td>
* <td><i>null</i></td>
* <td>the name of the view the viewResolver will use to forward to
* (if this property is not set, an exception will be thrown during
* initialization)</td>
* </tr>
* <tr>
* <td><b>name</b></td>
* <td><b>default</b></td>
* <td><b>description</b></td>
* </tr>
* <tr>
* <td>viewName</td>
* <td><i>null</i></td>
* <td>the name of the view the viewResolver will use to forward to (if this property
* is not set, an exception will be thrown during initialization)</td>
* </tr>
* </table>
* </p>
*
* @author John A. Lewis
* @since 2.0