Class CartStateRefresher
java.lang.Object
org.broadleafcommerce.core.web.order.CartStateRefresher
- All Implemented Interfaces:
EventListener,org.springframework.context.ApplicationListener<org.broadleafcommerce.core.order.domain.OrderPersistedEvent>
@Component("blCartStateRefresher")
public class CartStateRefresher
extends Object
implements org.springframework.context.ApplicationListener<org.broadleafcommerce.core.order.domain.OrderPersistedEvent>
ApplicationListener responsible for updating CartState with a new version that was persisted.- Author:
- Phillip Verheyden (phillipuniverse)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonApplicationEvent(org.broadleafcommerce.core.order.domain.OrderPersistedEvent event) ResetsCartStatewith the newly persisted Order.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
CartStateRefresher
public CartStateRefresher()
-
-
Method Details
-
onApplicationEvent
public void onApplicationEvent(org.broadleafcommerce.core.order.domain.OrderPersistedEvent event) 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<org.broadleafcommerce.core.order.domain.OrderPersistedEvent>
-