public class DefaultLockStrategy<P extends Product,U extends IGenericEcomUser> extends Object implements LockStrategy<P,U>
LockStrategy
LockStrategy.Lock, LockStrategy.LockException| Constructor and Description |
|---|
DefaultLockStrategy() |
| 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 |
int |
getMinutesForLockExpire()
Default time to keep a Lock alive; from last user Action
Ideally, this value should match session time out value If value is < = 0 then no locks will be applied. |
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 |
setMinutesForLockExpire(int minutesForLockExpire)
Default time to keep a Lock alive; from last user Action
Ideally, this value should match session time out value If value is < = 0 then no locks will be applied. |
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 sessionId)
Convenience/Consistent method; commonly used to Unlock all Locks for a Users session
|
public boolean isLockValid(LockStrategy.Lock lock)
LockStrategyLockStrategy.Lock is valid or not @ the given instance of time
By default a LockStrategy.Lock more than #minutesForLockExpire minutes is invalid.isLockValid in interface LockStrategy<P extends Product,U extends IGenericEcomUser>public LockStrategy.Lock lockUnitsForUser(P product, U user, String sessionId, Number units)
LockStrategylockUnitsForUser in interface LockStrategy<P extends Product,U extends IGenericEcomUser>user - @nullable truesessionId - @nullable truepublic Collection<LockStrategy.Lock> getLocksForUser(U user, String sessionId)
LockStrategyLockStrategy.Locks for a UsergetLocksForUser in interface LockStrategy<P extends Product,U extends IGenericEcomUser>user - as Upublic void unlock(LockStrategy.Lock lock) throws LockStrategy.LockException
LockStrategyunlock in interface LockStrategy<P extends Product,U extends IGenericEcomUser>lock - as LockStrategy.LockLockStrategy.LockException - if unable to LockStrategy.Lockpublic void unlock(Collection<LockStrategy.Lock> locks) throws LockStrategy.LockException
LockStrategyunlock in interface LockStrategy<P extends Product,U extends IGenericEcomUser>locks - as Collection of LockStrategy.LockLockStrategy.LockException - if unable to LockStrategy.Lockpublic void unlockSession(U user, String sessionId)
LockStrategyunlockSession in interface LockStrategy<P extends Product,U extends IGenericEcomUser>user - as UsessionId - as Stringpublic Collection<LockStrategy.Lock> getLocksForProducts(Collection<P> products, U user, String sessionId)
LockStrategyLockStrategy.Lock for a ProductgetLocksForProducts in interface LockStrategy<P extends Product,U extends IGenericEcomUser>user - as UsessionId - as StringLockStrategy.Lock @nullable truepublic Collection<LockStrategy.Lock> getLocksForProducts(Collection<P> products)
LockStrategyLockStrategy.Lock for a ProductgetLocksForProducts in interface LockStrategy<P extends Product,U extends IGenericEcomUser>LockStrategy.Lock @nullable truepublic int getMinutesForLockExpire()
public void setMinutesForLockExpire(int minutesForLockExpire)
public void remove(P product)
LockStrategyremove in interface LockStrategy<P extends Product,U extends IGenericEcomUser>Copyright © 2018. All rights reserved.