public class SimplePortletPostProcessor extends Object implements DestructionAwareBeanPostProcessor, PortletContextAware, PortletConfigAware
BeanPostProcessor
that applies initialization and destruction
callbacks to beans that implement the Portlet
interface.
After initialization of the bean instance, the Portlet init
method will be called with a PortletConfig
that contains the bean name of the Portlet and the PortletContext that it is running in.
Before destruction of the bean instance, the Portlet destroy
will be called.
Note that this post-processor does not support Portlet initialization parameters. Bean instances that implement the Portlet interface are supposed to be configured like any other Spring bean, that is, through constructor arguments or bean properties.
For reuse of a Portlet implementation in a plain Portlet container and as a bean in a Spring context, consider
deriving from Spring's GenericPortletBean
base class that applies Portlet
initialization parameters as bean properties, supporting both the standard Portlet and the Spring bean initialization
style.
Alternatively, consider wrapping a Portlet with Spring's PortletWrappingController
. This is particularly appropriate for existing
Portlet classes, allowing to specify Portlet initialization parameters etc.
Portlet
,
PortletConfig
,
SimplePortletHandlerAdapter
,
GenericPortletBean
,
PortletWrappingController
Constructor and Description |
---|
SimplePortletPostProcessor() |
Modifier and Type | Method and Description |
---|---|
Object |
postProcessAfterInitialization(Object bean,
String beanName) |
void |
postProcessBeforeDestruction(Object bean,
String beanName) |
Object |
postProcessBeforeInitialization(Object bean,
String beanName) |
boolean |
requiresDestruction(Object bean) |
void |
setPortletConfig(javax.portlet.PortletConfig portletConfig)
Set the PortletConfigthat this object runs in.
|
void |
setPortletContext(javax.portlet.PortletContext portletContext)
Set the PortletContext that this object runs in.
|
void |
setUseSharedPortletConfig(boolean useSharedPortletConfig)
Set whether to use the shared PortletConfig object passed in through
setPortletConfig , if available. |
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
postProcessAfterInitialization
in interface BeanPostProcessor
BeansException
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException
postProcessBeforeDestruction
in interface DestructionAwareBeanPostProcessor
BeansException
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
postProcessBeforeInitialization
in interface BeanPostProcessor
BeansException
public boolean requiresDestruction(Object bean)
requiresDestruction
in interface DestructionAwareBeanPostProcessor
public void setPortletConfig(javax.portlet.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 setPortletContext(javax.portlet.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
portletContext
- PortletContext object to be used by this objectpublic 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.
Copyright © 2019 Liferay, Inc.. All rights reserved.