@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 |
|---|---|
Customer |
getAnonymousCustomer(org.springframework.web.context.request.WebRequest request)
Returns the anonymous customer that was saved in session.
|
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)
Implementors can subclass to change how anonymous customers are created. Note that this method is intended to actually create the anonymous
customer if one does not exist. If you are looking to just get the current anonymous customer (if it exists) then instead use the
getAnonymousCustomer(WebRequest) method.
The intended behavior of this method is as follows:
Customer on the sessionCustomer)Customer in sessionrequest - #getAnonymousCustomer(WebRequest)},
#getAnonymousCustomerAttributeName()},
#getAnonymousCustomerIdAttributeName()}public Customer getAnonymousCustomer(org.springframework.web.context.request.WebRequest request)
request - the current request#getAnonymousCustomerSessionAttributeName()},
#getAnonymousCustomerIdSessionAttributeName()}public static String getAnonymousCustomerSessionAttributeName()
#getAnonymousCustomerIdAttributeName()
should be used instead.Customer that has not been persisted to the database yetpublic static String getAnonymousCustomerIdSessionAttributeName()
Returns the session attribute to store the anonymous customer ID. This session attribute should be used to track
anonymous customers that have not registered but have state in the database. When users first visit the Broadleaf
site, a new 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 © 2014. All Rights Reserved.