Class TransitionHandlerFactory
java.lang.Object
com.broadleafcommerce.data.tracking.core.messaging.TransitionHandlerFactory
- All Implemented Interfaces:
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 Summary
ConstructorDescriptionTransitionHandlerFactory
(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, org.springframework.context.ApplicationEventPublisher applicationEventPublisher) -
Method Summary
Modifier and TypeMethodDescriptioncustomizeHandlers
(List<TransitionHandler> handlers) protected org.springframework.context.ApplicationContext
protected org.springframework.context.ApplicationEventPublisher
protected TrackableBehaviorUtil
getBusinessDomain
(org.springframework.data.mapping.PersistentEntity<?, ?> entity, Class<?> type) protected CommonCatalogService<Catalog>
protected WorkflowRequestCompletionNotifier
protected DomainMapperManager
protected List<org.springframework.data.mapping.PersistentEntity<?,
?>> We only want to haveTransitionHandler
instances for most-derived persisted domain types.protected com.broadleafcommerce.common.extension.TypeFactory
protected com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper
protected org.springframework.data.mapping.context.MappingContext<?,
?> protected com.broadleafcommerce.common.messaging.notification.NotificationManager
protected Optional<TransitionHandler>
getOrCreateTransitionHandler
(Class<?> type, Class<?> businessDomain) protected PropagationManager
protected RepositoryUtility
protected com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,
?> protected com.broadleafcommerce.common.extension.data.DataRouteReference
protected SingleIndexRequestMessageFactory
protected Optional<TransitionHandler>
getTransitionHandler
(org.springframework.data.mapping.PersistentEntity<?, ?> entity) protected com.broadleafcommerce.common.extension.TypeFactory
protected WorkflowMapper
void
setApplicationEventPublisher
(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) void
setCatalogService
(CommonCatalogService<Catalog> commonCatalogService) void
setPropagationManager
(PropagationManager propagationManager) void
setTypeFactory
(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
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
- Specified by:
customizeHandlers
in interfaceTransitionHandlerCustomizer
-
getEligiblePersistentEntities
protected List<org.springframework.data.mapping.PersistentEntity<?,?>> getEligiblePersistentEntities()We only want to haveTransitionHandler
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
-
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
-
getWorkflowMapper
-
getApplicationContext
protected org.springframework.context.ApplicationContext getApplicationContext() -
getDomainMapper
-
getResourceLockRepository
protected com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,?> getResourceLockRepository() -
getNotificationManager
protected com.broadleafcommerce.common.messaging.notification.NotificationManager getNotificationManager() -
getCompletionNotifier
-
getFactory
protected com.broadleafcommerce.common.extension.TypeFactory getFactory() -
getHelper
protected com.broadleafcommerce.common.messaging.notification.MessageSerializationHelper getHelper() -
getRepositories
-
getCommonCatalogService
-
getSingleIndexRequestMessageFactory
-
getPropagationManager
-
setPropagationManager
-
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)
-