Class ChangeSummaryMessageFactory

  • All Implemented Interfaces:
    com.broadleafcommerce.common.messaging.notification.MessageFactory<ChangeEvent>

    public class ChangeSummaryMessageFactory
    extends Object
    implements com.broadleafcommerce.common.messaging.notification.MessageFactory<ChangeEvent>
    Creates new ChangeEvent messages based on an entity instance.
    Author:
    Jeff Fischer
    • Method Detail

      • createMessage

        public org.springframework.messaging.Message<ChangeEvent> createMessage​(Object entity,
                                                                                Map<String,​Object> attributes)
        Specified by:
        createMessage in interface com.broadleafcommerce.common.messaging.notification.MessageFactory<ChangeEvent>
      • createMessage

        public org.springframework.messaging.Message<ChangeEvent> createMessage​(Object entity)
        Specified by:
        createMessage in interface com.broadleafcommerce.common.messaging.notification.MessageFactory<ChangeEvent>
      • setVendorRefIfApplicable

        protected void setVendorRefIfApplicable​(Trackable entity,
                                                ChangeEvent changeEvent)
        If vendor processing is enabled, this will determine the vendor the entity is associated to, and set that information on the ChangeEvent.getVendorRef().
        Parameters:
        entity - the entity whose vendor association should be determined
        changeEvent - the change event being emitted as a result of persistence of this entity
      • setVendorVisibilityManagerProvider

        @Autowired
        public void setVendorVisibilityManagerProvider​(org.springframework.beans.factory.ObjectProvider<VendorVisibilityManager> vendorVisibilityManagerProvider)
        If vendor processing is enabled, this bean will be injected and used to determine which vendor a changed entity is associated to.

        We leverage ObjectProvider here since we want both optional and lazy injection. This is because ChangeSummaryMessageFactory may indirectly be a dependency of service components injected by VendorVisibilityManager and we want to avoid circular dependencies.

        See Also:
        setVendorRefIfApplicable(Trackable, ChangeEvent)
      • setContextRequestHydratorProvider

        @Autowired
        public void setContextRequestHydratorProvider​(org.springframework.beans.factory.ObjectProvider<ContextRequestHydrator> contextRequestHydratorProvider)
        If vendor processing is enabled, a ContextInfo matching each entity's tracking will need to be supplied to the methods of getVendorVisibilityManager() to ensure any fetches are correctly narrowed to the same context. This will require the ContextRequest to be hydrated, and thus hydrators need to be injected.

        If vendor processing is disabled, the hydrators are not necessary.

        We leverage ObjectProvider here since we want both optional and lazy injection. This is because ChangeSummaryMessageFactory may indirectly be a dependency of service components injected by ContextRequestHydrator implementations and we want to avoid circular dependencies.

      • setReference

        @Autowired
        public void setReference​(@Nullable
                                 com.broadleafcommerce.common.extension.data.DataRouteReference reference)
      • getReference

        @Nullable
        protected com.broadleafcommerce.common.extension.data.DataRouteReference getReference()