@Component(value="blCustomerStateRequestProcessor") public class CustomerStateRequestProcessor extends AbstractBroadleafWebRequestProcessor implements org.springframework.context.ApplicationEventPublisherAware
CustomerStateFilter}| Modifier and Type | Field and Description |
|---|---|
static String |
ANONYMOUS_CUSTOMER_ID_SESSION_ATTRIBUTE_NAME |
static String |
ANONYMOUS_CUSTOMER_SESSION_ATTRIBUTE_NAME |
static String |
BLC_RULE_MAP_PARAM |
protected static String |
customerRequestAttributeName |
protected CustomerService |
customerService |
protected org.springframework.context.ApplicationEventPublisher |
eventPublisher |
protected org.apache.commons.logging.Log |
logger
Logger for this class and subclasses
|
| Constructor and Description |
|---|
CustomerStateRequestProcessor() |
| Modifier and Type | Method and Description |
|---|---|
static String |
getAnonymousCustomerIdSessionAttributeName()
Returns the session attribute to store the anonymous customer ID.
|
static String |
getAnonymousCustomerSessionAttributeName()
Returns the session attribute to store the anonymous customer.
|
static String |
getCustomerRequestAttributeName()
The request-scoped attribute that should store the
Customer. |
void |
process(org.springframework.web.context.request.WebRequest request) |
Customer |
resolveAnonymousCustomer(org.springframework.web.context.request.WebRequest request)
Implementors can subclass to change how anonymous customers are created.
|
Customer |
resolveAuthenticatedCustomer(org.springframework.security.core.Authentication authentication)
Subclasses can extend to resolve other types of Authentication tokens
|
void |
setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher eventPublisher) |
static void |
setCustomerRequestAttributeName(String customerRequestAttributeName) |
postProcessprotected final org.apache.commons.logging.Log logger
public static final String BLC_RULE_MAP_PARAM
protected CustomerService customerService
protected org.springframework.context.ApplicationEventPublisher eventPublisher
protected static String customerRequestAttributeName
public static final String ANONYMOUS_CUSTOMER_SESSION_ATTRIBUTE_NAME
public static final String ANONYMOUS_CUSTOMER_ID_SESSION_ATTRIBUTE_NAME
public void process(org.springframework.web.context.request.WebRequest request)
process in interface BroadleafWebRequestProcessorpublic Customer resolveAuthenticatedCustomer(org.springframework.security.core.Authentication authentication)
authentication - public Customer resolveAnonymousCustomer(org.springframework.web.context.request.WebRequest request)
Customer on the session
- If a customer is found in session, keep using the session-based customer
- If a customer is not found in session
- Look for a customer ID in session
- If a customer ID is found in session:
Look up the customer in the database
- If no there is no customer ID in session (and thus no Customer)
1. Create a new customer
2. Put the newly-created Customer in sessionrequest - #getAnonymousCustomerAttributeName()},
#getAnonymousCustomerIdAttributeName()}public static String getAnonymousCustomerSessionAttributeName()
#getAnonymousCustomerIdAttributeName()
should be used instead.Customer that has not been persisted to the database yetpublic static String getAnonymousCustomerIdSessionAttributeName()
Customer is instantiated but is only saved in session and not persisted to the database. However,
once that user adds something to the cart, that Customer is now saved in the database and it no longer makes
sense to pull back a full Customer object from session, as any session-based Customer will be out of
date in regards to Hibernate (specifically with lists).
So, once Broadleaf detects that the session-based Customer has been persisted, it should remove the session-based
Customer and then utilize just the customer ID from session.CustomerStateRefresher}public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher eventPublisher)
setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAwarepublic static String getCustomerRequestAttributeName()
Customer.
Customer customer = (Customer) request.getAttribute(CustomerStateRequestProcessor.getCustomerRequestAttributeName()); //this is equivalent to the above invocation Customer customer = CustomerState.getCustomer();
CustomerState}public static void setCustomerRequestAttributeName(String customerRequestAttributeName)
Copyright © 2013. All Rights Reserved.