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>
logger
Constructor and Description |
---|
PortletWrappingController() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
void |
destroy()
Invoked by the containing
BeanFactory on destruction of a bean. |
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(java.lang.String name)
Set the name of the bean in the bean factory that created this bean.
|
void |
setInitParameters(java.util.Map<java.lang.String,java.lang.String> initParameters)
Specify init parameters for the portlet to wrap,
as name-value pairs.
|
void |
setPortletClass(java.lang.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(java.lang.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. |
handleActionRequest, handleRenderRequest, isRenderWhenMinimized, isSynchronizeOnSession, setRenderWhenMinimized, setSynchronizeOnSession
applyCacheSeconds, cacheForSeconds, check, checkAndPrepare, checkAndPrepare, getCacheSeconds, isRequireSession, preventCaching, setCacheSeconds, setRequireSession
getPortletContext, getTempDir, isContextRequired
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, requiredContextClass, setApplicationContext
public void setUseSharedPortletConfig(boolean useSharedPortletConfig)
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.
public void setPortletContext(PortletContext portletContext)
PortletContextAware
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.
setPortletContext
in interface PortletContextAware
setPortletContext
in class PortletApplicationObjectSupport
portletContext
- PortletContext object to be used by this objectpublic void setPortletConfig(PortletConfig portletConfig)
PortletConfigAware
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.
setPortletConfig
in interface PortletConfigAware
portletConfig
- PortletConfig object to be used by this objectpublic void setPortletClass(java.lang.Class<?> portletClass)
javax.portlet.Portlet
.Portlet
public void setPortletName(java.lang.String portletName)
public void setInitParameters(java.util.Map<java.lang.String,java.lang.String> initParameters)
public void setBeanName(java.lang.String name)
BeanNameAware
Invoked after population of normal bean properties but before an
init callback such as InitializingBean.afterPropertiesSet()
or a custom init-method.
setBeanName
in interface BeanNameAware
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.public void afterPropertiesSet() throws java.lang.Exception
InitializingBean
BeanFactory
after it has set all bean properties
and satisfied BeanFactoryAware
, ApplicationContextAware
etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
afterPropertiesSet
in interface InitializingBean
java.lang.Exception
- in the event of misconfiguration (such as failure to set an
essential property) or if initialization fails for any other reasonprotected void handleActionRequestInternal(ActionRequest request, ActionResponse response) throws java.lang.Exception
AbstractController
handleActionRequest
.
The default implementation throws a PortletException.
handleActionRequestInternal
in class AbstractController
java.lang.Exception
AbstractController.handleActionRequest(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
,
AbstractController.handleRenderRequestInternal(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
protected ModelAndView handleRenderRequestInternal(RenderRequest request, RenderResponse response) throws java.lang.Exception
AbstractController
handleRenderRequest
.
The default implementation throws a PortletException.
handleRenderRequestInternal
in class AbstractController
java.lang.Exception
AbstractController.handleRenderRequest(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
,
AbstractController.handleActionRequestInternal(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
public ModelAndView handleResourceRequest(ResourceRequest request, ResourceResponse response) throws java.lang.Exception
ResourceAwareController
null
return value is not an error: It indicates that this
object completed request processing itself, thus there is no ModelAndView to render.handleResourceRequest
in interface ResourceAwareController
request
- current portlet resource requestresponse
- current portlet resource responsejava.lang.Exception
- in case of errorspublic void handleEventRequest(EventRequest request, EventResponse response) throws java.lang.Exception
EventAwareController
handleEventRequest
in interface EventAwareController
request
- current portlet event requestresponse
- current portlet event responsejava.lang.Exception
- in case of errorspublic void destroy()
DisposableBean
BeanFactory
on destruction of a bean.destroy
in interface DisposableBean