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

    Constructors
    Constructor
    Description
    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 Summary

    Modifier and Type
    Method
    Description
    void
     
    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 a NotificationStateAware implementing entity instance, retrieve the list of NotificationState instances associated.
    void
    saveFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, jakarta.persistence.EntityManager em)
    Persist all the NotificationState instances built up in the entity's NotificationStateAware.getNotificationStates() related list.
    void
    setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static JpaNotificationStateService get()
    • destroy

      @PreDestroy public void destroy()
    • setApplicationContext

      public void setApplicationContext(@NonNull org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.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 interface com.broadleafcommerce.common.messaging.notification.NotificationStateService
      Overrides:
      getOrInitializeNotificationState in class com.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 a NotificationStateAware implementing entity instance, retrieve the list of NotificationState 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 more NotificationState instances.
      Returns:
      The list of resolved NotificationState instances.
    • saveFrom

      public void saveFrom(com.broadleafcommerce.common.messaging.notification.domain.NotificationStateAware stateAware, jakarta.persistence.EntityManager em)
      Persist all the NotificationState instances built up in the entity's NotificationStateAware.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 from JpaTrackableRepository.save(Trackable, ContextInfo), or in save overrides in customized repositories that deal with NotificationStateAware 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. See JpaDataRoute for more information.
      Parameters:
      stateAware - The entity to review for any NotificationState instances to persist.
      em - The entity manager to use for the persistence.