Class DefaultOfferMaxUseStatusManager

java.lang.Object
com.broadleafcommerce.promotion.offer.service.DefaultOfferMaxUseStatusManager
All Implemented Interfaces:
OfferMaxUseStatusManager, EventListener, org.springframework.context.ApplicationListener<com.broadleafcommerce.data.tracking.core.service.MutationNotifyEvent>, org.springframework.core.Ordered

public class DefaultOfferMaxUseStatusManager extends Object implements OfferMaxUseStatusManager, org.springframework.context.ApplicationListener<com.broadleafcommerce.data.tracking.core.service.MutationNotifyEvent>, org.springframework.core.Ordered
  • Constructor Details

    • DefaultOfferMaxUseStatusManager

      public DefaultOfferMaxUseStatusManager(OfferRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, OfferCodeRepository<com.broadleafcommerce.data.tracking.core.Trackable> codeRepository, com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager manager, com.broadleafcommerce.data.tracking.core.cache.CacheInvalidationNotificationImmediateSender invalidationSender)
  • Method Details

    • updateStatusForOffer

      public void updateStatusForOffer(Offer offer, String status, boolean invalidateIfApplicable)
      Description copied from interface: OfferMaxUseStatusManager
      Set the status for an offer in the persistence store. This should also invalidate any active caches containing the offer that feed into max usage detection. This latter step guarantees the latest status is being consumed by the system. Note, this method is called under load (possibly with duplicate update requests), so measures are taken to make sure cache invalidation messages are only sent if the status is actually changed (ignoring duplicates).
      Specified by:
      updateStatusForOffer in interface OfferMaxUseStatusManager
      Parameters:
      offer - The target offer
      status - The status for the offer
      invalidateIfApplicable - Send a cache invalidation message for the offer. Is only effective is cache is currently enabled.
    • updateStatusForOfferCode

      public void updateStatusForOfferCode(OfferCode offerCode, String status, boolean invalidateIfApplicable)
      Description copied from interface: OfferMaxUseStatusManager
      Set the status for an offerCode in the persistence store. This should also invalidate any active caches containing the offerCode that feed into max usage detection. This latter step guarantees the latest status is being consumed by the system. Note, this method is called under load (possibly with duplicate update requests), so measures are taken to make sure cache invalidation messages are only sent if the status is actually changed (ignoring duplicates).
      Specified by:
      updateStatusForOfferCode in interface OfferMaxUseStatusManager
      Parameters:
      offerCode - The target offerCode
      status - The status for the offerCode
      invalidateIfApplicable - Send a cache invalidation message for the offerCode. Is only effective is cache is currently enabled.
    • onApplicationEvent

      public void onApplicationEvent(com.broadleafcommerce.data.tracking.core.service.MutationNotifyEvent event)
      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<com.broadleafcommerce.data.tracking.core.service.MutationNotifyEvent>
    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface org.springframework.core.Ordered
    • getRepository

      @NonNull protected OfferRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()
    • getCodeRepository

      @NonNull protected OfferCodeRepository<com.broadleafcommerce.data.tracking.core.Trackable> getCodeRepository()
    • getManager

      @NonNull protected com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager getManager()
    • getInvalidationSender

      @Nullable protected com.broadleafcommerce.data.tracking.core.cache.CacheInvalidationNotificationImmediateSender getInvalidationSender()