@Service(value="blCheckoutService") public class CheckoutServiceImpl extends Object implements CheckoutService
Modifier and Type | Field and Description |
---|---|
protected Processor<CheckoutSeed,CheckoutSeed> |
checkoutWorkflow |
protected static ConcurrentMap<Long,Object> |
lockMap
Map of locks for given order ids.
|
protected OrderService |
orderService |
Constructor and Description |
---|
CheckoutServiceImpl() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
hasOrderBeenCompleted(Order order)
Checks if the order has already been gone through the checkout workflow.
|
CheckoutResponse |
performCheckout(Order order)
Checks out an order by executing the blCheckoutWorkflow.
|
protected Object |
putLock(Long orderId)
Get an object to lock on for the given order id
|
protected void |
removeLock(Long orderId)
Done with processing the given orderId, remove the lock from the map
|
protected Processor<CheckoutSeed,CheckoutSeed> checkoutWorkflow
protected OrderService orderService
protected static ConcurrentMap<Long,Object> lockMap
public CheckoutResponse performCheckout(Order order) throws CheckoutException
CheckoutService
Checks out an order by executing the blCheckoutWorkflow. The order is saved both before and after the workflow is executed so that activities can modify the various entities on and related to the order.
This method is also thread-safe; 2 requests cannot attempt to check out the same order
performCheckout
in interface CheckoutService
order
- the order to be checked outCheckoutException
- if there are any exceptions while executing any of the activities in the workflow (assuming
that the workflow does not already have a preconfigured error handler) or if the given order has already been
checked out (in Broadleaf terms this means the order has already been changed to OrderStatus.SUBMITTED
)protected boolean hasOrderBeenCompleted(Order order)
order
- protected Object putLock(Long orderId)
orderId
- protected void removeLock(Long orderId)
orderId
- Copyright © 2019. All rights reserved.