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
DefaultTransitionHandlerfor this entity. - Add the transition handler to the list of handlers.
- Author:
- Chad Harchar (charchar)
-
Constructor Summary
ConstructorsConstructorDescriptionTransitionHandlerFactory(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.ApplicationContextprotected org.springframework.context.ApplicationEventPublisherprotected TrackableBehaviorUtilgetBusinessDomain(org.springframework.data.mapping.PersistentEntity<?, ?> entity, Class<?> type) protected CommonCatalogService<Catalog>protected WorkflowRequestCompletionNotifierprotected DomainMapperManagerprotected List<org.springframework.data.mapping.PersistentEntity<?,?>> We only want to haveTransitionHandlerinstances for most-derived persisted domain types.protected com.broadleafcommerce.common.extension.TypeFactoryprotected com.broadleafcommerce.common.messaging.notification.MessageSerializationHelperprotected org.springframework.data.mapping.context.MappingContext<?,?> protected com.broadleafcommerce.common.messaging.notification.NotificationManagerprotected Optional<TransitionHandler>getOrCreateTransitionHandler(Class<?> type, Class<?> businessDomain) protected PropagationManagerprotected RepositoryUtilityprotected com.broadleafcommerce.common.messaging.repository.ResourceLockRepository<?,?> protected com.broadleafcommerce.common.extension.data.DataRouteReferenceprotected SingleIndexRequestMessageFactoryprotected Optional<TransitionHandler>getTransitionHandler(org.springframework.data.mapping.PersistentEntity<?, ?> entity) protected com.broadleafcommerce.common.extension.TypeFactoryprotected WorkflowMappervoidsetApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher) voidsetCatalogService(CommonCatalogService<Catalog> commonCatalogService) voidsetPropagationManager(PropagationManager propagationManager) voidsetTypeFactory(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:
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
-
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)
-