Class JpaNotificationStateService
java.lang.Object
com.broadleafcommerce.common.messaging.notification.DefaultNotificationStateService
com.broadleafcommerce.data.tracking.jpa.messaging.notification.JpaNotificationStateService
- All Implemented Interfaces:
com.broadleafcommerce.common.messaging.notification.NotificationStateService,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
public class JpaNotificationStateService
extends com.broadleafcommerce.common.messaging.notification.DefaultNotificationStateService
implements org.springframework.context.ApplicationContextAware
The implementation for the
JpaNotificationState.- Author:
- Dima Myroniuk (dmyroniuk)
-
Constructor Summary
ConstructorsConstructorDescriptionJpaNotificationStateService(com.broadleafcommerce.common.extension.TypeFactory typeFactory, NotificationStateValueUpdater repository, com.broadleafcommerce.common.extension.data.DataRouteReference reference, List<org.springframework.orm.jpa.EntityManagerFactoryInfo> factories, org.springframework.boot.autoconfigure.cache.CacheProperties cacheProperties) -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()static JpaNotificationStateServiceget()com.broadleafcommerce.common.messaging.notification.domain.NotificationStategetOrInitializeNotificationState(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, String name) List<com.broadleafcommerce.common.messaging.notification.domain.NotificationState>readFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware) Given aNotificationStateAwareimplementing entity instance, retrieve the list ofNotificationStateinstances associated.voidsaveFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, jakarta.persistence.EntityManager em) Persist all theNotificationStateinstances built up in the entity'sNotificationStateAware.getNotificationStates()related list.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
Constructor Details
-
JpaNotificationStateService
public JpaNotificationStateService(com.broadleafcommerce.common.extension.TypeFactory typeFactory, NotificationStateValueUpdater repository, com.broadleafcommerce.common.extension.data.DataRouteReference reference, List<org.springframework.orm.jpa.EntityManagerFactoryInfo> factories, org.springframework.boot.autoconfigure.cache.CacheProperties cacheProperties)
-
-
Method Details
-
get
-
destroy
@PreDestroy public void destroy() -
setApplicationContext
public void setApplicationContext(@NonNull org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
getOrInitializeNotificationState
public com.broadleafcommerce.common.messaging.notification.domain.NotificationState getOrInitializeNotificationState(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, String name) - Specified by:
getOrInitializeNotificationStatein interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateService- Overrides:
getOrInitializeNotificationStatein classcom.broadleafcommerce.common.messaging.notification.DefaultNotificationStateService
-
readFrom
public List<com.broadleafcommerce.common.messaging.notification.domain.NotificationState> readFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware) Given aNotificationStateAwareimplementing entity instance, retrieve the list ofNotificationStateinstances associated. This is necessary in Jpa, since these instances are managed separately from the entity itself.- Parameters:
stateAware- The entity instance that may be related to one or moreNotificationStateinstances.- Returns:
- The list of resolved
NotificationStateinstances.
-
saveFrom
public void saveFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, jakarta.persistence.EntityManager em) Persist all theNotificationStateinstances built up in the entity'sNotificationStateAware.getNotificationStates()related list. This list is generally manipulated during various mapping operations during the lifecycle of a service call. Since notification state instances are managed separately from the entity itself, calling here is required to have those notification states be persisted. This method is generally called fromJpaTrackableRepository.save(Trackable, ContextInfo), or in save overrides in customized repositories that deal withNotificationStateAwareimplementing domain classes. This method also requires a valid entity manager instance be passed from the calling repository instance (either JpaTrackableRepository or custom repository fragment) in order to guarantee matching data route and transaction behavior, if applicable. SeeJpaDataRoutefor more information.- Parameters:
stateAware- The entity to review for anyNotificationStateinstances to persist.em- The entity manager to use for the persistence.
-