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
ConstructorDescriptionJpaNotificationStateService
(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 TypeMethodDescriptionstatic JpaNotificationStateService
get()
com.broadleafcommerce.common.messaging.notification.domain.NotificationState
getOrInitializeNotificationState
(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 aNotificationStateAware
implementing entity instance, retrieve the list ofNotificationState
instances associated.void
saveFrom
(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, javax.persistence.EntityManager em) Persist all theNotificationState
instances built up in the entity'sNotificationStateAware.getNotificationStates()
related list.void
setApplicationContext
(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
-
setApplicationContext
public void setApplicationContext(@NonNull org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContext
in 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:
getOrInitializeNotificationState
in interfacecom.broadleafcommerce.common.messaging.notification.NotificationStateService
- Overrides:
getOrInitializeNotificationState
in 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 aNotificationStateAware
implementing entity instance, retrieve the list ofNotificationState
instances 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 moreNotificationState
instances.- Returns:
- The list of resolved
NotificationState
instances.
-
saveFrom
public void saveFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, javax.persistence.EntityManager em) Persist all theNotificationState
instances 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 withNotificationStateAware
implementing 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. SeeJpaDataRoute
for more information.- Parameters:
stateAware
- The entity to review for anyNotificationState
instances to persist.em
- The entity manager to use for the persistence.
-