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 createTransitionHandlersfor 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
DefaultTransitionHandlerfor this entity. - Add the transition handler to the list of handlers.
- Author:
- Chad Harchar (charchar)
-
-
Constructor Summary
Constructors Constructor Description 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)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)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<TransitionHandler>customizeHandlers(List<TransitionHandler> handlers)protected org.springframework.context.ApplicationContextgetApplicationContext()protected TrackableBehaviorUtilgetBehaviorUtil()protected Optional<Class<?>>getBusinessDomain(org.springframework.data.mapping.PersistentEntity<?,?> entity, Class<?> type)protected CommonCatalogService<Catalog>getCommonCatalogService()protected WorkflowRequestCompletionNotifiergetCompletionNotifier()protected DomainMapperManagergetDomainMapper()protected List<org.springframework.data.mapping.PersistentEntity<?,?>>getEligiblePersistentEntities()We only want to haveTransitionHandlerinstances for most-derived persisted domain types.protected com.broadleafcommerce.common.extension.TypeFactorygetFactory()protected com.broadleafcommerce.common.messaging.notification.MessageSerializationHelpergetHelper()protected org.springframework.data.mapping.context.MappingContext<?,?>getMappingContext()protected com.broadleafcommerce.common.messaging.notification.NotificationManagergetNotificationManager()protected Optional<TransitionHandler>getOrCreateTransitionHandler(Class<?> type, Class<?> businessDomain)protected PropagationManagergetPropagationManager()protected RepositoryUtilitygetRepositories()protected com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,?>getResourceLockRepository()protected com.broadleafcommerce.common.extension.data.DataRouteReferencegetRouteReference()protected SingleIndexRequestMessageFactorygetSingleIndexRequestMessageFactory()protected Optional<TransitionHandler>getTransitionHandler(org.springframework.data.mapping.PersistentEntity<?,?> entity)protected com.broadleafcommerce.common.extension.TypeFactorygetTypeFactory()protected WorkflowMappergetWorkflowMapper()voidsetCatalogService(CommonCatalogService<Catalog> commonCatalogService)voidsetPropagationManager(PropagationManager propagationManager)voidsetTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
-
Constructor Detail
-
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)
-
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 Detail
-
setCatalogService
@Autowired(required=false) public void setCatalogService(CommonCatalogService<Catalog> commonCatalogService)
-
customizeHandlers
public List<TransitionHandler> customizeHandlers(List<TransitionHandler> handlers)
- Specified by:
customizeHandlersin interfaceTransitionHandlerCustomizer
-
getEligiblePersistentEntities
protected List<org.springframework.data.mapping.PersistentEntity<?,?>> getEligiblePersistentEntities()
We only want to haveTransitionHandlerinstances 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
MappingContextand 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)
-
-