org.springframework.web.portlet.mvc

## Class PortletWrappingController

- java.lang.Object
- - org.springframework.context.support.ApplicationObjectSupport
  - - org.springframework.web.portlet.context.PortletApplicationObjectSupport
    - - org.springframework.web.portlet.handler.PortletContentGenerator
      - - org.springframework.web.portlet.mvc.AbstractController
        - - org.springframework.web.portlet.mvc.PortletWrappingController

- All Implemented Interfaces:
    Aware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, PortletConfigAware, PortletContextAware, Controller, EventAwareController, ResourceAwareController

      public class PortletWrappingController
      extends AbstractController
      implements ResourceAwareController, EventAwareController, BeanNameAware, InitializingBean, DisposableBean, PortletContextAware, PortletConfigAware

  `Controller` implementation that wraps a portlet instance which it manages internally. Such a wrapped portlet is not known outside of this controller; its entire lifecycle is covered here.

  Useful to invoke an existing portlet via Spring's dispatching infrastructure, for example to apply Spring `HandlerInterceptors` to its requests.

  Example:

      <bean id="wrappingController" class="org.springframework.web.portlet.mvc.PortletWrappingController">
         <property name="portletClass">
           <value>org.springframework.web.portlet.sample.HelloWorldPortlet</value>
         </property>
         <property name="portletName">
           <value>hello-world</value>
         </property>
         <property name="initParameters">
           <props>
             <prop key="config">/WEB-INF/hello-world-portlet-config.xml</prop>
           </props>
         </property>
       </bean>

  Since:
    2.0
  Author:
    Juergen Hoeller, John A. Lewis

- - ### Field Summary

    - ### Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

      `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PortletWrappingController()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()` Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
    `void` | `destroy()` Invoked by a BeanFactory on destruction of a singleton.
    `protected void` | `handleActionRequestInternal(ActionRequest request, ActionResponse response)` Subclasses are meant to override this method if the controller is expected to handle action requests.
    `void` | `handleEventRequest(EventRequest request, EventResponse response)` Process the event request.
    `protected ModelAndView` | `handleRenderRequestInternal(RenderRequest request, RenderResponse response)` Subclasses are meant to override this method if the controller is expected to handle render requests.
    `ModelAndView` | `handleResourceRequest(ResourceRequest request, ResourceResponse response)` Process the resource request and return a ModelAndView object which the DispatcherPortlet will render.
    `void` | `setBeanName(String name)` Set the name of the bean in the bean factory that created this bean.
    `void` | `setInitParameters(Map<String,String> initParameters)` Specify init parameters for the portlet to wrap, as name-value pairs.
    `void` | `setPortletClass(Class portletClass)` Set the class of the Portlet to wrap.
    `void` | `setPortletConfig(PortletConfig portletConfig)` Set the PortletConfigthat this object runs in.
    `void` | `setPortletContext(PortletContext portletContext)` Set the PortletContext that this object runs in.
    `void` | `setPortletName(String portletName)` Set the name of the Portlet to wrap.
    `void` | `setUseSharedPortletConfig(boolean useSharedPortletConfig)` Set whether to use the shared PortletConfig object passed in through `setPortletConfig`, if available.

    - ### Methods inherited from class org.springframework.web.portlet.mvc.AbstractController

      `handleActionRequest, handleRenderRequest, isRenderWhenMinimized, isSynchronizeOnSession, setRenderWhenMinimized, setSynchronizeOnSession`

    - ### Methods inherited from class org.springframework.web.portlet.handler.PortletContentGenerator

      `applyCacheSeconds, cacheForSeconds, check, checkAndPrepare, checkAndPrepare, getCacheSeconds, isRequireSession, preventCaching, setCacheSeconds, setRequireSession`

    - ### Methods inherited from class org.springframework.web.portlet.context.PortletApplicationObjectSupport

      `getPortletContext, getTempDir, isContextRequired`

    - ### Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

      `getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, requiredContextClass, setApplicationContext`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### PortletWrappingController

          public PortletWrappingController()

  - ### Method Detail

    - #### setUseSharedPortletConfig

          public void setUseSharedPortletConfig(boolean useSharedPortletConfig)

      Set whether to use the shared PortletConfig object passed in through `setPortletConfig`, if available.

      Default is "true". Turn this setting to "false" to pass in a mock PortletConfig object with the bean name as portlet name, holding the current PortletContext.

      See Also:
        `setPortletConfig(javax.portlet.PortletConfig)`

    - #### setPortletContext

          public void setPortletContext(PortletContext portletContext)

      Description copied from interface: `PortletContextAware`
      Set the PortletContext that this object runs in.

      Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked after ApplicationContextAware's setApplicationContext.

      Specified by:
        `setPortletContext` in interface `PortletContextAware`
      Overrides:
        `setPortletContext` in class `PortletApplicationObjectSupport`
      Parameters:
        `portletContext` - PortletContext object to be used by this object

    - #### setPortletConfig

          public void setPortletConfig(PortletConfig portletConfig)

      Description copied from interface: `PortletConfigAware`
      Set the PortletConfigthat this object runs in.

      Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked after ApplicationContextAware's setApplicationContext.

      Specified by:
        `setPortletConfig` in interface `PortletConfigAware`
      Parameters:
        `portletConfig` - PortletConfig object to be used by this object

    - #### setPortletClass

          public void setPortletClass(Class portletClass)

      Set the class of the Portlet to wrap. Needs to implement `javax.portlet.Portlet`.
      See Also:
        `Portlet`

    - #### setPortletName

          public void setPortletName(String portletName)

      Set the name of the Portlet to wrap. Default is the bean name of this controller.

    - #### setInitParameters

          public void setInitParameters(Map<String,String> initParameters)

      Specify init parameters for the portlet to wrap, as name-value pairs.

    - #### setBeanName

          public void setBeanName(String name)

      Description copied from interface: `BeanNameAware`
      Set the name of the bean in the bean factory that created this bean.

      Invoked after population of normal bean properties but before an init callback such as `InitializingBean.afterPropertiesSet()` or a custom init-method.

      Specified by:
        `setBeanName` in interface `BeanNameAware`
      Parameters:
        `name` - the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the `BeanFactoryUtils.originalBeanName(String)` method to extract the original bean name (without suffix), if desired.

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws Exception

      Description copied from interface: `InitializingBean`
      Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

      This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

      Specified by:
        `afterPropertiesSet` in interface `InitializingBean`
      Throws:
        `Exception` - in the event of misconfiguration (such as failure to set an essential property) or if initialization fails.

    - #### handleActionRequestInternal

          protected void handleActionRequestInternal(ActionRequest request,
                                         ActionResponse response)
                                              throws Exception

      Description copied from class: `AbstractController`
      Subclasses are meant to override this method if the controller is expected to handle action requests. The contract is the same as for `handleActionRequest`.

      The default implementation throws a PortletException.

      Overrides:
        `handleActionRequestInternal` in class `AbstractController`
      Throws:
        `Exception`
      See Also:
        `AbstractController.handleActionRequest(javax.portlet.ActionRequest, javax.portlet.ActionResponse)`, `AbstractController.handleRenderRequestInternal(javax.portlet.RenderRequest, javax.portlet.RenderResponse)`

    - #### handleRenderRequestInternal

          protected ModelAndView handleRenderRequestInternal(RenderRequest request,
                                                 RenderResponse response)
                                                      throws Exception

      Description copied from class: `AbstractController`
      Subclasses are meant to override this method if the controller is expected to handle render requests. The contract is the same as for `handleRenderRequest`.

      The default implementation throws a PortletException.

      Overrides:
        `handleRenderRequestInternal` in class `AbstractController`
      Throws:
        `Exception`
      See Also:
        `AbstractController.handleRenderRequest(javax.portlet.RenderRequest, javax.portlet.RenderResponse)`, `AbstractController.handleActionRequestInternal(javax.portlet.ActionRequest, javax.portlet.ActionResponse)`

    - #### handleResourceRequest

          public ModelAndView handleResourceRequest(ResourceRequest request,
                                           ResourceResponse response)
                                             throws Exception

      Description copied from interface: `ResourceAwareController`
      Process the resource request and return a ModelAndView object which the DispatcherPortlet will render. A `null` return value is not an error: It indicates that this object completed request processing itself, thus there is no ModelAndView to render.
      Specified by:
        `handleResourceRequest` in interface `ResourceAwareController`
      Parameters:
        `request` - current portlet resource request
        `response` - current portlet resource response
      Returns:
        a ModelAndView to render, or null if handled directly
      Throws:
        `Exception` - in case of errors

    - #### handleEventRequest

          public void handleEventRequest(EventRequest request,
                                EventResponse response)
                                  throws Exception

      Description copied from interface: `EventAwareController`
      Process the event request. There is nothing to return.
      Specified by:
        `handleEventRequest` in interface `EventAwareController`
      Parameters:
        `request` - current portlet event request
        `response` - current portlet event response
      Throws:
        `Exception` - in case of errors

    - #### destroy

          public void destroy()

      Description copied from interface: `DisposableBean`
      Invoked by a BeanFactory on destruction of a singleton.
      Specified by:
        `destroy` in interface `DisposableBean`