Class TransitionHandlerFactory

java.lang.Object
com.broadleafcommerce.data.tracking.core.messaging.TransitionHandlerFactory
All Implemented Interfaces:
TransitionHandlerCustomizer

public class TransitionHandlerFactory extends Object implements TransitionHandlerCustomizer
Used to create TransitionHandlers for sandboxable entities and delegate to them when a sandbox message is received. Sandboxable entities are marked with @TrackableExtension(TrackableBehavior.SANDBOX). Transition handlers are created in the following way:
  • Retrieve all entities
  • Filter out any non-sandboxable entities
  • For each entity, get the business domain name. For example, `JpaProduct.java` has the method `getBusinessDomainType()` which points to `Product.class`
  • Using the entity persisted-domain name, construct a name by lowercasing the first letter and appending `TransitionHandler`. To follow the previous example, it would be `jpaProductTransitionHandler`
  • Check if there is already a bean with that name created and use that. This allows overriding these Transition Handlers with custom behavior.
  • If there is no bean created, construct a new Transition Handler using DefaultTransitionHandler for this entity.
  • Add the transition handler to the list of handlers.
Author:
Chad Harchar (charchar)
  • Constructor Details

    • TransitionHandlerFactory

      public TransitionHandlerFactory(com.broadleafcommerce.common.extension.data.DataRouteReference routeReference, org.springframework.data.mapping.context.MappingContext<?,?> mappingContext, TrackableBehaviorUtil behaviorUtil, WorkflowMapper workflowMapper, org.springframework.context.ApplicationContext applicationContext, DomainMapperManager domainMapper, com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,?> resourceLockRepository, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager, WorkflowRequestCompletionNotifier completionNotifier, com.broadleafcommerce.common.extension.TypeFactory factory, com.broadleafcommerce.common.messaging.notification.NotificationStateService notificationStateService, com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper helper, RepositoryUtility repositories, CommonCatalogService<Catalog> commonCatalogService, SingleIndexRequestMessageFactory singleIndexRequestMessageFactory, PropagationManager propagationManager, com.broadleafcommerce.common.extension.TypeFactory typeFactory, org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
    • TransitionHandlerFactory

      public TransitionHandlerFactory(com.broadleafcommerce.common.extension.data.DataRouteReference routeReference, org.springframework.data.mapping.context.MappingContext<?,?> mappingContext, TrackableBehaviorUtil behaviorUtil, WorkflowMapper workflowMapper, org.springframework.context.ApplicationContext applicationContext, DomainMapperManager domainMapper, com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,?> resourceLockRepository, com.broadleafcommerce.common.messaging.notification.NotificationManager notificationManager, WorkflowRequestCompletionNotifier completionNotifier, com.broadleafcommerce.common.extension.TypeFactory factory, com.broadleafcommerce.common.messaging.notification.NotificationStateService notificationStateService, com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper helper, RepositoryUtility repositories, SingleIndexRequestMessageFactory singleIndexRequestMessageFactory)
  • Method Details

    • setCatalogService

      @Autowired(required=false) public void setCatalogService(CommonCatalogService<Catalog> commonCatalogService)
    • customizeHandlers

      public List<TransitionHandler> customizeHandlers(List<TransitionHandler> handlers)
      Specified by:
      customizeHandlers in interface TransitionHandlerCustomizer
    • getEligiblePersistentEntities

      protected List<org.springframework.data.mapping.PersistentEntity<?,?>> getEligiblePersistentEntities()
      We only want to have TransitionHandler instances for most-derived persisted domain types. If an entity is extended, we want to create a handler for the extended domain, not the base class.

      By default, this method will obtain all persistent entities from the MappingContext and subsequently filter to only the most-derived types. For example, if the base type JpaSomething has an extension JpaExtendedSomething, only JpaExtendedSomething will have a handler created.

      Returns:
      a filtered list of the most-derived persisted entity types
    • getTransitionHandler

      protected Optional<TransitionHandler> getTransitionHandler(org.springframework.data.mapping.PersistentEntity<?,?> entity)
    • getBusinessDomain

      protected Optional<Class<?>> getBusinessDomain(org.springframework.data.mapping.PersistentEntity<?,?> entity, Class<?> type)
    • getOrCreateTransitionHandler

      protected Optional<TransitionHandler> getOrCreateTransitionHandler(Class<?> type, Class<?> businessDomain)
    • getRouteReference

      protected com.broadleafcommerce.common.extension.data.DataRouteReference getRouteReference()
    • getMappingContext

      protected org.springframework.data.mapping.context.MappingContext<?,?> getMappingContext()
    • getBehaviorUtil

      protected TrackableBehaviorUtil getBehaviorUtil()
    • getWorkflowMapper

      protected WorkflowMapper getWorkflowMapper()
    • getApplicationContext

      protected org.springframework.context.ApplicationContext getApplicationContext()
    • getDomainMapper

      protected DomainMapperManager getDomainMapper()
    • getResourceLockRepository

      protected com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,?> getResourceLockRepository()
    • getNotificationManager

      protected com.broadleafcommerce.common.messaging.notification.NotificationManager getNotificationManager()
    • getCompletionNotifier

      protected WorkflowRequestCompletionNotifier getCompletionNotifier()
    • getFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getFactory()
    • getHelper

      protected com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper getHelper()
    • getRepositories

      protected RepositoryUtility getRepositories()
    • getCommonCatalogService

      protected CommonCatalogService<Catalog> getCommonCatalogService()
    • getSingleIndexRequestMessageFactory

      protected SingleIndexRequestMessageFactory getSingleIndexRequestMessageFactory()
    • getPropagationManager

      protected PropagationManager getPropagationManager()
    • setPropagationManager

      @Autowired public void setPropagationManager(@Nullable PropagationManager propagationManager)
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • setTypeFactory

      @Autowired public void setTypeFactory(@Nullable com.broadleafcommerce.common.extension.TypeFactory typeFactory)
    • getApplicationEventPublisher

      protected org.springframework.context.ApplicationEventPublisher getApplicationEventPublisher()
    • setApplicationEventPublisher

      @Autowired public void setApplicationEventPublisher(@Nullable org.springframework.context.ApplicationEventPublisher applicationEventPublisher)