Interface NativeMethodEntityExtensionHandler<T>

All Superinterfaces:
ExtensionHandler

public interface NativeMethodEntityExtensionHandler<T> extends ExtensionHandler

Extension handler used for contributions to native Object methods on entity like equals() clone() and hashCode(). It is possible that dynamically weaved in columns from embeddables need to contribute to those methods.

Managers that implement this handler should add themselves to the blEntityExtensionManagers list:

 
 <bean id="myEntityExtensionManagers" class="org.springframework.beans.factory.config.MapFactoryBean">
       <property name="sourceMap">
           <map>
               <entry key="blSomeEntityExtensionManager" value-ref="blSomeEntityExtensionManager"/>
           </map>
       </property>
   </bean>

   <bean class="org.broadleafcommerce.common.extensibility.context.merge.LateStageMergeBeanPostProcessor">
       <property name="collectionRef" value="myEntityExtensionManagers"/>
       <property name="targetRef" value="blEntityExtensionManagers"/>
   </bean>
 
 

These blEntityExtensionManagers are added onto the BroadleafRequestContext with BroadleafRequestContext.getAdditionalProperties(). Native methods can use that to pull it off

Example use case is in SiteImpl.clone() as well as CategoryImpl#getAllChildCategoryXrefs()

Author:
Phillip Verheyden (phillipuniverse)
  • Method Details

    • contributeClone

      void contributeClone(T from, T to)
      Contributes additional properties to a cloned instance. Implementors should take properties from from and copy them over to to
      Parameters:
      from - the original instance that is being cloned
      to - the instance that from is being cloned to
    • contributeEquals

      void contributeEquals(T original, T test, ExtensionResultHolder<Boolean> result)
      Contributes additional equals() checks. Dynamically weaved properties should check between original and test and store the result in result.
      Parameters:
      original - the instance being checked for equals (the 'this' side of equals)
      test - the instance being compared to original for equality
      result - where the result should be stored if this extension manager
    • contributeHashCode

      void contributeHashCode(T entity, int precomputedHashCode, ExtensionResultHolder<Integer> result)
      Contributes more properties to build an object's hashCode().
      Parameters:
      entity - the entity whose hashCode is being computed
      precomputedHashCode - the hashCode precomputed from the existing properties on entity
      result - where the final hashCode() should be stored