public abstract class AbstractMergeBeanPostProcessor extends Object implements org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.context.ApplicationContextAware
Contains useful processing code for merge bean post processors. The BeanPostProcessor instances can be used to merge additional collection members into collections declared elsewhere. In effect, this allows an implementer to only declare the collection members they're currently interested in cause those members to be merged into a larger, pre-existing list. This is more desirable than a traditional, comprehensive override that would require re-declaring the original bean and all of its members in addition to the current members being considered.
This code demonstrates using one of the concrete implementations, LateStageMergeBeanPostProcessor. The
basic usage pattern is to specify the id of the collection you want to merge (collectionRef) and the id
of the pre-existing, target collection (targetRef) that should receive the merge collection. The collection
can be represented using ListFactoryBean, SetFactoryBean or MapFactoryBean.
<bean class="org.broadleafcommerce.common.extensibility.context.merge.LateStageMergeBeanPostProcessor">
<property name="collectionRef" value="blPriceListRuleBuilderFieldServices"/>
<property name="targetRef" value="blRuleBuilderFieldServices"/>
</bean>
<bean id="blPriceListRuleBuilderFieldServices" class="org.springframework.beans.factory.config.ListFactoryBean">
<property name="sourceList">
<list>
<ref bean="blPricingContextFieldService"/>
</list>
</property>
</bean>
LateStageMergeBeanPostProcessor,
EarlyStageMergeBeanPostProcessor| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.context.ApplicationContext |
applicationContext |
protected String |
collectionRef |
protected static org.apache.commons.logging.Log |
LOG |
protected Placement |
placement |
protected int |
position |
protected MergeBeanStatusProvider |
statusProvider |
protected String |
targetRef |
| Constructor and Description |
|---|
AbstractMergeBeanPostProcessor() |
| Modifier and Type | Method and Description |
|---|---|
String |
getCollectionRef()
Retrieve the id of the collection to be merged
|
Placement |
getPlacement()
The position in the target collection to place the merge.
|
int |
getPosition()
If a placement of type Placement.SPECIFIC is used, then this is the integer position in the target
target collection at which the merge will be performed.
|
MergeBeanStatusProvider |
getStatusProvider()
Gets the status provider that is configured for this post processor
|
String |
getTargetRef()
Retrieve the id of the collection to receive the merge
|
Object |
postProcessAfterInitialization(Object bean,
String beanName) |
Object |
postProcessBeforeInitialization(Object bean,
String beanName) |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setCollectionRef(String collectionRef)
Set the id of the collection to be merged
|
void |
setPlacement(Placement placement)
The position in the target collection to place the merge.
|
void |
setPosition(int position)
If a placement of type Placement.SPECIFIC is used, then this is the integer position in the target
target collection at which the merge will be performed.
|
void |
setStatusProvider(MergeBeanStatusProvider statusProvider)
Sets the MergeBeanStatusProvider, which controls whether or not this post processor is activated.
|
void |
setTargetRef(String targetRef)
Set the id of the collection to receive the merge
|
protected static final org.apache.commons.logging.Log LOG
protected String collectionRef
protected String targetRef
protected Placement placement
protected int position
protected org.springframework.context.ApplicationContext applicationContext
protected MergeBeanStatusProvider statusProvider
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic Object postProcessAfterInitialization(Object bean, String beanName) throws org.springframework.beans.BeansException
postProcessAfterInitialization in interface org.springframework.beans.factory.config.BeanPostProcessororg.springframework.beans.BeansExceptionpublic Object postProcessBeforeInitialization(Object bean, String beanName) throws org.springframework.beans.BeansException
postProcessBeforeInitialization in interface org.springframework.beans.factory.config.BeanPostProcessororg.springframework.beans.BeansExceptionpublic String getCollectionRef()
public void setCollectionRef(String collectionRef)
collectionRef - the id of the collection to be mergedpublic String getTargetRef()
public void setTargetRef(String targetRef)
targetRef - the id of the collection receiving the mergepublic Placement getPlacement()
public void setPlacement(Placement placement)
placement - the position in the target collection to place the mergepublic int getPosition()
public void setPosition(int position)
position - the specific position in the target collectionpublic MergeBeanStatusProvider getStatusProvider()
public void setStatusProvider(MergeBeanStatusProvider statusProvider)
statusProvider - Copyright © 2015. All Rights Reserved.