public interface LockStrategy<P extends Product,U extends User>
LockStrategy.Lock
SaleStrategy and OrderStrategy would be typical consumers of this Strategy; as opposed to other Strategies
that find direct business use cases.| Modifier and Type | Interface and Description |
|---|---|
static class |
LockStrategy.Lock
An abstract concept for Locking some units
|
static class |
LockStrategy.LockException
Exception regarding
LockStrategy.Locks |
| Modifier and Type | Method and Description |
|---|---|
Collection<LockStrategy.Lock> |
getLocksForProducts(Collection<P> products)
Get
LockStrategy.Lock for a Product |
Collection<LockStrategy.Lock> |
getLocksForProducts(Collection<P> products,
U user,
String sessionId)
Get
LockStrategy.Lock for a Product |
Collection<LockStrategy.Lock> |
getLocksForUser(U user,
String sessionId)
Get the
LockStrategy.Locks for a User |
boolean |
isLockValid(LockStrategy.Lock lock)
While processing locks, check if a
LockStrategy.Lock is valid or not @ the given instance of time
By default a LockStrategy.Lock more than #minutesForLockExpire minutes is invalid. |
LockStrategy.Lock |
lockUnitsForUser(P product,
U user,
String sessionId,
Number units)
During the purchase process allow the ability to lock away certain
units for a User.
|
void |
remove(P product)
Clear entries for A Product
|
void |
unlock(Collection<LockStrategy.Lock> locks)
If a transaction was abandoned, not completed or forced out
then one can unlock it.
|
void |
unlock(LockStrategy.Lock lock)
If a transaction was abandoned, not completed or forced out
then one can unlock it.
|
void |
unlockSession(U user,
String usessionId)
Convenience/Consistent method; commonly used to Unlock all Locks for a Users session
|
LockStrategy.Lock lockUnitsForUser(P product, U user, String sessionId, Number units) throws LockStrategy.LockException
product - user - @nullable truesessionId - @nullable trueunits; - Number of units to LockLockStrategy.LockException - if unable to LockStrategy.LockCollection<LockStrategy.Lock> getLocksForUser(U user, String sessionId)
LockStrategy.Locks for a Useruser - as UCollection<LockStrategy.Lock> getLocksForProducts(Collection<P> products, U user, String sessionId)
LockStrategy.Lock for a Productproduct - as Puser - as UsessionId - as StringLockStrategy.Lock @nullable trueCollection<LockStrategy.Lock> getLocksForProducts(Collection<P> products)
LockStrategy.Lock for a Productproduct - as Puser - as UsessionId - as StringLockStrategy.Lock @nullable truevoid unlock(LockStrategy.Lock lock) throws LockStrategy.LockException
lock - as LockStrategy.LockLockStrategy.LockException - if unable to LockStrategy.Lockvoid unlock(Collection<LockStrategy.Lock> locks) throws LockStrategy.LockException
locks - as Collection of LockStrategy.LockLockStrategy.LockException - if unable to LockStrategy.Lockvoid unlockSession(U user, String usessionId)
user - as UusessionId - as Stringvoid remove(P product)
boolean isLockValid(LockStrategy.Lock lock)
LockStrategy.Lock is valid or not @ the given instance of time
By default a LockStrategy.Lock more than #minutesForLockExpire minutes is invalid.Copyright © 2018. All rights reserved.