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
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionDefaultOfferMaxUseStatusManager
(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 Summary
Modifier and TypeMethodDescriptionprotected OfferCodeRepository<com.broadleafcommerce.data.tracking.core.Trackable>
protected com.broadleafcommerce.data.tracking.core.cache.CacheInvalidationNotificationImmediateSender
protected com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager
int
getOrder()
protected OfferRepository<com.broadleafcommerce.data.tracking.core.Trackable>
void
onApplicationEvent
(com.broadleafcommerce.data.tracking.core.service.MutationNotifyEvent event) void
updateStatusForOffer
(Offer offer, String status, boolean invalidateIfApplicable) Set the status for an offer in the persistence store.void
updateStatusForOfferCode
(OfferCode offerCode, String status, boolean invalidateIfApplicable) Set the status for an offerCode in the persistence store.
-
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
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 interfaceOfferMaxUseStatusManager
- Parameters:
offer
- The target offerstatus
- The status for the offerinvalidateIfApplicable
- 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 interfaceOfferMaxUseStatusManager
- Parameters:
offerCode
- The target offerCodestatus
- The status for the offerCodeinvalidateIfApplicable
- 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 interfaceorg.springframework.context.ApplicationListener<com.broadleafcommerce.data.tracking.core.service.MutationNotifyEvent>
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceorg.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()
-