Class AbstractMergeBeanPostProcessor

java.lang.Object
org.broadleafcommerce.common.extensibility.context.merge.AbstractMergeBeanPostProcessor
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
EarlyStageMergeBeanPostProcessor, LateStageMergeBeanPostProcessor

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>
 
 
Author:
Jeff Fischer
See Also:
  • Field Details

    • LOG

      protected static final org.apache.commons.logging.Log LOG
    • applicationContext

      protected org.springframework.context.ApplicationContext applicationContext
    • defaultBeanPackage

      protected AbstractMergeBeanPostProcessor.BeanPackage defaultBeanPackage
  • Constructor Details

    • AbstractMergeBeanPostProcessor

      public AbstractMergeBeanPostProcessor()
  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • postProcessAfterInitialization

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

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

      protected AbstractMergeBeanPostProcessor.BeanPackage constructBeanPackage(String beanName, Map<String,Object> methodAnnotationAttributes)
    • processPackage

      protected Object processPackage(AbstractMergeBeanPostProcessor.BeanPackage beanPackage, Object bean, String beanName)
    • processPackage

      protected Object processPackage(Map<String,Object> methodAnnotationAttributes, Object bean, String beanName)
    • addMapToMap

      protected void addMapToMap(Object bean, Map sourceItem, Placement placement, int position) throws NoSuchFieldException, IllegalAccessException
      Throws:
      NoSuchFieldException
      IllegalAccessException
    • addSetToSet

      protected void addSetToSet(Object bean, Object sourceItem, Placement placement, int position) throws NoSuchFieldException, IllegalAccessException
      Throws:
      NoSuchFieldException
      IllegalAccessException
    • addItemToSet

      protected void addItemToSet(Object bean, Object sourceItem, Placement placement, int position) throws NoSuchFieldException, IllegalAccessException
      Throws:
      NoSuchFieldException
      IllegalAccessException
    • addListToList

      protected void addListToList(Object bean, Object sourceItem, Placement placement, int position) throws NoSuchFieldException, IllegalAccessException
      Throws:
      NoSuchFieldException
      IllegalAccessException
    • addItemToList

      protected void addItemToList(Object bean, Object sourceItem, Placement placement, int position) throws NoSuchFieldException, IllegalAccessException
      Throws:
      NoSuchFieldException
      IllegalAccessException
    • getCollectionRef

      @Deprecated public String getCollectionRef()
      Deprecated.
      use getSourceRef() instead
      Retrieve the id of the collection to be merged
      Returns:
      the id of the collection to be merged
    • setCollectionRef

      @Deprecated public void setCollectionRef(String collectionRef)
      Deprecated.
      Set the id of the collection to be merged
      Parameters:
      collectionRef - the id of the collection to be merged
    • getSourceRef

      public String getSourceRef()
      Retrieve the id of the collection (or individual bean) to be merged
      Returns:
      the id of the item to be merged
    • setSourceRef

      public void setSourceRef(String sourceRef)
      Set the id of the collection (or individual bean) to be merged
      Parameters:
      sourceRef - the id of the item to be merged
    • getTargetRef

      public String getTargetRef()
      Retrieve the id of the collection to receive the merge
      Returns:
      the id of the collection receiving the merge
    • setTargetRef

      public void setTargetRef(String targetRef)
      Set the id of the collection to receive the merge
      Parameters:
      targetRef - the id of the collection receiving the merge
    • getPlacement

      public Placement getPlacement()
      The position in the target collection to place the merge. This can be at the beginning, end or at an explicit position.
      Returns:
      the position in the target collection to place the merge
    • setPlacement

      public void setPlacement(Placement placement)
      The position in the target collection to place the merge. This can be at the beginning, end or at an explicit position.
      Parameters:
      placement - the position in the target collection to place the merge
    • getPosition

      public 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.
      Returns:
      the specific position in the target collection
    • setPosition

      public 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.
      Parameters:
      position - the specific position in the target collection
    • getStatusProvider

      public MergeBeanStatusProvider getStatusProvider()
      Gets the status provider that is configured for this post processor
      Returns:
      the MergeStatusBeanProvider
    • setStatusProvider

      public void setStatusProvider(MergeBeanStatusProvider statusProvider)
      Sets the MergeBeanStatusProvider, which controls whether or not this post processor is activated. If no statusProvider is set, then we will always execute.
      Parameters:
      statusProvider -