Class CartStateRefresher
java.lang.Object
org.broadleafcommerce.core.web.order.CartStateRefresher
- All Implemented Interfaces:
EventListener,org.springframework.context.ApplicationListener<OrderPersistedEvent>
@Component("blCartStateRefresher")
public class CartStateRefresher
extends Object
implements org.springframework.context.ApplicationListener<OrderPersistedEvent>
ApplicationListener responsible for updating CartState with a new version that was persisted.- Author:
- Phillip Verheyden (phillipuniverse)
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
CartStateRefresher
public CartStateRefresher()
-
-
Method Details
-
onApplicationEvent
Resets
CartStatewith the newly persisted Order. IfCartStatewas empty, this will only update it if theOrderthat has been persisted is theOrderStatus.IN_PROCESSOrderfor the activeCustomer(as determined byCustomerState.getCustomer(). IfCartStatewas not empty, then it will be replaced only if this newly persistedOrderhas the same id.This ensures that whatever is returned from
CartState.getCart()will always be the most up-to-date database version (meaning, safe to write to the DB).- Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener<OrderPersistedEvent>
-