org.springframework.datastore.engine
Class LockableEntityPersister

java.lang.Object
  extended by org.springframework.datastore.engine.EntityPersister
      extended by org.springframework.datastore.engine.LockableEntityPersister
All Implemented Interfaces:
EntityInterceptorAware, Persister
Direct Known Subclasses:
AbstractKeyValueEntityPesister

public abstract class LockableEntityPersister
extends EntityPersister

Interface for entity persisters that support locking

Since:
1.0

Field Summary
static int DEFAULT_TIMEOUT
           
 
Fields inherited from class org.springframework.datastore.engine.EntityPersister
interceptors, proxyFactory, session
 
Constructor Summary
LockableEntityPersister(MappingContext mappingContext, PersistentEntity entity, Session session)
           
 
Method Summary
abstract  boolean isLocked(Object o)
          Return whether an object is locked or not
abstract  Object lock(Serializable id)
          Locks an object for the given identifier returning the locked instance
abstract  Object lock(Serializable id, int timeout)
          Acquire a lock using the given identifier and timeout delay
abstract  void unlock(Object o)
          Unlocks a locked object
 
Methods inherited from class org.springframework.datastore.engine.EntityPersister
addEntityInterceptor, createEntityAccess, delete, delete, deleteEntities, deleteEntity, getMappingContext, getObjectIdentifier, getPersistentEntity, getProxyFactory, getType, persist, persist, persistEntities, persistEntity, retrieve, retrieveAll, retrieveAll, retrieveAllEntities, retrieveAllEntities, retrieveEntity, setEntityInterceptors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.datastore.engine.Persister
createQuery, proxy, refresh
 

Field Detail

DEFAULT_TIMEOUT

public static int DEFAULT_TIMEOUT
Constructor Detail

LockableEntityPersister

public LockableEntityPersister(MappingContext mappingContext,
                               PersistentEntity entity,
                               Session session)
Method Detail

lock

public abstract Object lock(Serializable id)
                     throws org.springframework.dao.CannotAcquireLockException
Locks an object for the given identifier returning the locked instance

Parameters:
id - The identifier
Returns:
The locked object
Throws:
org.springframework.dao.CannotAcquireLockException - Thrown if a lock couldn't be acquired before the default timeout elapsed

lock

public abstract Object lock(Serializable id,
                            int timeout)
                     throws org.springframework.dao.CannotAcquireLockException
Acquire a lock using the given identifier and timeout delay

Parameters:
id - the identifier
timeout - the amount of time to wait before giving up
Returns:
The locked object
Throws:
org.springframework.dao.CannotAcquireLockException

isLocked

public abstract boolean isLocked(Object o)
Return whether an object is locked or not

Parameters:
o - The object
Returns:
True if it is locked

unlock

public abstract void unlock(Object o)
Unlocks a locked object

Parameters:
o - The object to unlock