spring-webmvc-portlet

org.springframework.web.portlet.handler
Class SimplePortletPostProcessor

java.lang.Object
  extended by org.springframework.web.portlet.handler.SimplePortletPostProcessor
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, PortletConfigAware, PortletContextAware

public class SimplePortletPostProcessor
extends java.lang.Object
implements org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, PortletContextAware, PortletConfigAware

Bean post-processor 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 initialization styles.

Alternatively, consider wrapping a Portlet with Spring's PortletWrappingController. This is particularly appropriate for existing Portlet classes, allowing to specify Portlet initialization parameters etc.

Since:
2.0
Author:
Juergen Hoeller, John A. Lewis
See Also:
Portlet, PortletConfig, SimplePortletHandlerAdapter, GenericPortletBean, PortletWrappingController

Constructor Summary
SimplePortletPostProcessor()
           
 
Method Summary
 java.lang.Object postProcessAfterInitialization(java.lang.Object bean, java.lang.String beanName)
           
 void postProcessBeforeDestruction(java.lang.Object bean, java.lang.String beanName)
           
 java.lang.Object postProcessBeforeInitialization(java.lang.Object bean, java.lang.String beanName)
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePortletPostProcessor

public SimplePortletPostProcessor()
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(javax.portlet.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
Parameters:
portletContext - PortletContext object to be used by this object

setPortletConfig

public void setPortletConfig(javax.portlet.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

postProcessBeforeInitialization

public java.lang.Object postProcessBeforeInitialization(java.lang.Object bean,
                                                        java.lang.String beanName)
                                                 throws org.springframework.beans.BeansException
Specified by:
postProcessBeforeInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
Throws:
org.springframework.beans.BeansException

postProcessAfterInitialization

public java.lang.Object postProcessAfterInitialization(java.lang.Object bean,
                                                       java.lang.String beanName)
                                                throws org.springframework.beans.BeansException
Specified by:
postProcessAfterInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
Throws:
org.springframework.beans.BeansException

postProcessBeforeDestruction

public void postProcessBeforeDestruction(java.lang.Object bean,
                                         java.lang.String beanName)
                                  throws org.springframework.beans.BeansException
Specified by:
postProcessBeforeDestruction in interface org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
Throws:
org.springframework.beans.BeansException

spring-webmvc-portlet