类 SimplePortletPostProcessor
- java.lang.Object
- org.springframework.web.portlet.handler.SimplePortletPostProcessor
- 所有已实现的接口:
Aware
,BeanPostProcessor
,DestructionAwareBeanPostProcessor
,PortletConfigAware
,PortletContextAware
public class SimplePortletPostProcessor extends Object implements DestructionAwareBeanPostProcessor, PortletContextAware, PortletConfigAware
BeanPostProcessor
that applies initialization and destruction callbacks to beans that implement thePortlet
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.- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, John A. Lewis
- 另请参阅:
Portlet
,PortletConfig
,SimplePortletHandlerAdapter
,GenericPortletBean
,PortletWrappingController
构造器概要
构造器 构造器 说明 SimplePortletPostProcessor()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Object
postProcessAfterInitialization(Object bean, String beanName)
Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks (like InitializingBean'safterPropertiesSet
or a custom init-method).void
postProcessBeforeDestruction(Object bean, String beanName)
Apply this BeanPostProcessor to the given bean instance before its destruction, e.g. invoking custom destruction callbacks.Object
postProcessBeforeInitialization(Object bean, String beanName)
Apply this BeanPostProcessor to the given new bean instance before any bean initialization callbacks (like InitializingBean'safterPropertiesSet
or a custom init-method).boolean
requiresDestruction(Object bean)
Determine whether the given bean instance requires destruction by this post-processor.void
setPortletConfig(PortletConfig portletConfig)
Set the PortletConfigthat this object runs in.void
setPortletContext(PortletContext portletContext)
Set the PortletContext that this object runs in.void
setUseSharedPortletConfig(boolean useSharedPortletConfig)
Set whether to use the shared PortletConfig object passed in throughsetPortletConfig
, if available.
构造器详细资料
SimplePortletPostProcessor
public SimplePortletPostProcessor()
方法详细资料
setUseSharedPortletConfig
public void setUseSharedPortletConfig(boolean useSharedPortletConfig)
Set whether to use the shared PortletConfig object passed in throughsetPortletConfig
, 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.
setPortletContext
public void setPortletContext(PortletContext portletContext)
从接口复制的说明: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.
- 指定者:
setPortletContext
在接口中PortletContextAware
- 参数:
portletContext
- PortletContext object to be used by this object
setPortletConfig
public void setPortletConfig(PortletConfig portletConfig)
从接口复制的说明: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.
- 指定者:
setPortletConfig
在接口中PortletConfigAware
- 参数:
portletConfig
- PortletConfig object to be used by this object
postProcessBeforeInitialization
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
从接口复制的说明:BeanPostProcessor
Apply this BeanPostProcessor to the given new bean instance before any bean initialization callbacks (like InitializingBean'safterPropertiesSet
or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.- 指定者:
postProcessBeforeInitialization
在接口中BeanPostProcessor
- 参数:
bean
- the new bean instancebeanName
- the name of the bean- 返回:
- the bean instance to use, either the original or a wrapped one; if
null
, no subsequent BeanPostProcessors will be invoked - 抛出:
BeansException
- in case of errors- 另请参阅:
InitializingBean.afterPropertiesSet()
postProcessAfterInitialization
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
从接口复制的说明:BeanPostProcessor
Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks (like InitializingBean'safterPropertiesSet
or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.In case of a FactoryBean, this callback will be invoked for both the FactoryBean instance and the objects created by the FactoryBean (as of Spring 2.0). The post-processor can decide whether to apply to either the FactoryBean or created objects or both through corresponding
bean instanceof FactoryBean
checks.This callback will also be invoked after a short-circuiting triggered by a
InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation(java.lang.Class<?>, java.lang.String)
method, in contrast to all other BeanPostProcessor callbacks.- 指定者:
postProcessAfterInitialization
在接口中BeanPostProcessor
- 参数:
bean
- the new bean instancebeanName
- the name of the bean- 返回:
- the bean instance to use, either the original or a wrapped one; if
null
, no subsequent BeanPostProcessors will be invoked - 抛出:
BeansException
- in case of errors- 另请参阅:
InitializingBean.afterPropertiesSet()
,FactoryBean
postProcessBeforeDestruction
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException
从接口复制的说明:DestructionAwareBeanPostProcessor
Apply this BeanPostProcessor to the given bean instance before its destruction, e.g. invoking custom destruction callbacks.Like DisposableBean's
destroy
and a custom destroy method, this callback will only apply to beans which the container fully manages the lifecycle for. This is usually the case for singletons and scoped beans.- 指定者:
postProcessBeforeDestruction
在接口中DestructionAwareBeanPostProcessor
- 参数:
bean
- the bean instance to be destroyedbeanName
- the name of the bean- 抛出:
BeansException
- in case of errors- 另请参阅:
DisposableBean.destroy()
,AbstractBeanDefinition.setDestroyMethodName(String)
requiresDestruction
public boolean requiresDestruction(Object bean)
从接口复制的说明:DestructionAwareBeanPostProcessor
Determine whether the given bean instance requires destruction by this post-processor.NOTE: Even as a late addition, this method has been introduced on
DestructionAwareBeanPostProcessor
itself instead of on a SmartDABPP subinterface. This allows existingDestructionAwareBeanPostProcessor
implementations to easily providerequiresDestruction
logic while retaining compatibility with Spring <4.3, and it is also an easier onramp to declaringrequiresDestruction
as a Java 8 default method in Spring 5.If an implementation of
DestructionAwareBeanPostProcessor
does not provide a concrete implementation of this method, Spring's invocation mechanism silently assumes a method returningtrue
(the effective default before 4.3, and the to-be-default in the Java 8 method in Spring 5).- 指定者:
requiresDestruction
在接口中DestructionAwareBeanPostProcessor
- 参数:
bean
- the bean instance to check- 返回:
true
ifDestructionAwareBeanPostProcessor.postProcessBeforeDestruction(java.lang.Object, java.lang.String)
is supposed to be called for this bean instance eventually, orfalse
if not needed