@Component(value="blCustomerStateRefresher") public class CustomerStateRefresher extends Object implements org.springframework.context.ApplicationListener<CustomerPersistedEvent>
ApplicationListener
responsible for updating CustomerState
as well as invalidating the session-based
customer, if one existed previously. For instance, when originally browsing the catalog a Customer is created but only
stored in session and retrieved from session on subsequent requests. However, once the Customer has been persisted
(like when they add something to the cart) then this component is responsible for updating CustomerState
as well
as invalidating the session-based customer.Constructor and Description |
---|
CustomerStateRefresher() |
Modifier and Type | Method and Description |
---|---|
void |
onApplicationEvent(CustomerPersistedEvent event)
Removes the complete
Customer stored in session and adds a new session variable for just the customer ID. |
protected void |
resetTransientFields(Customer preMergedCustomer,
Customer postMergedCustomer)
After a JPA merge occurs, there is a new object created representing the merged changes.
|
public void onApplicationEvent(CustomerPersistedEvent event)
Customer
stored in session and adds a new session variable for just the customer ID. This
should occur once the session-based Customer
(all anonymous Customers start out this way) has been persisted.
Also updates CustomerState
with the persisted Customer
so that it will always represent the most
up-to-date version that is in the database
onApplicationEvent
in interface org.springframework.context.ApplicationListener<CustomerPersistedEvent>
request
- databaseCustomer
- protected void resetTransientFields(Customer preMergedCustomer, Customer postMergedCustomer)
preMergedCustome
- postMergedCustomer
- Copyright © 2019. All rights reserved.