|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.entityfs.lock.AbstractLockable
public abstract class AbstractLockable
This is an abstract base class that may be inherited by classes that want to
implement ReadLockable and
WriteLockable.
| Constructor Summary | |
|---|---|
protected |
AbstractLockable(EntityLockAdapterFactory laf,
LockAcquiringStrategy las,
Object[] lockIdentifiers)
|
| Method Summary | |
|---|---|
void |
assertIsReadLocked()
Throw an exception if this lockable object is not read locked by the current thread. |
void |
assertIsWriteLocked()
Throw an exception if this lockable object is not write locked by the current thread. |
protected LockAcquiringStrategy |
getLockAcquiringStrategy()
|
protected EntityLockAdapter |
getLockAdapter()
|
protected Lockable |
getLocked()
Get the object that will be the locked object of the locks. |
protected LogAdapter |
getLogAdapter()
Subclasses should override this to return a log adapter if they have access to one. |
EntityLock |
getReadLock()
Get the read lock without locking it. |
EntityLock |
getWriteLock()
Get the write lock without locking it. |
boolean |
isReadLockedByCurrentThread()
Is this lockable object read locked by the current thread? |
boolean |
isWriteLockedByCurrentThread()
Is this lockable object write locked by the current thread? |
EntityLock |
lock(Object identifier)
|
EntityLock |
lockForReading()
Lock object for reading and return the lock. |
EntityLock |
lockForWriting()
Lock the object for writing and return the lock. |
protected void |
logLockStack(LockTimeoutException e)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractLockable(EntityLockAdapterFactory laf,
LockAcquiringStrategy las,
Object[] lockIdentifiers)
laf - The lock adapter factory. Set to null to disable
logging.las - The lock acquiring strategy. Set to null if logging is
disabled.lockIdentifiers - An array of identifiers| Method Detail |
|---|
protected EntityLockAdapter getLockAdapter()
protected LockAcquiringStrategy getLockAcquiringStrategy()
protected LogAdapter getLogAdapter()
null (no logging).protected void logLockStack(LockTimeoutException e)
protected Lockable getLocked()
this. It may be overridden to return
something else.
this.public EntityLock lock(Object identifier)
public EntityLock getReadLock()
ReadLockableThis method always returns a lock, even if the object's file system is not locking or if the object is read only.
getReadLock in interface ReadLockablepublic EntityLock lockForReading()
ReadLockableEntityLockAdapterFactory and
LockAcquiringStrategy used. If this is called on an object that
somehow is connected to an entity object, that entity's file system's
entity lock adapter factory and lock acquiring strategy is used.
A read lock cannot be upgraded to a write lock (just like how Java's
ReadWriteLock works).
For more discussions on locks and locking, see Entity and
FileSystem.
This method always returns a lock, even if the object's file system is not locking or if the object is read only.
lockForReading in interface ReadLockablepublic EntityLock getWriteLock()
WriteLockableThis method always returns a lock, even if the object's file system is not locking or if the object is read only.
getWriteLock in interface WriteLockablepublic EntityLock lockForWriting()
WriteLockableEntityLockAdapterFactory and
LockAcquiringStrategy used. If this is called on an object that
is somehow connected to an Entity object, that entity's file
systems' lock adapter factory and lock acquiring strategy is used. A
write lock can be downgraded to a read lock (by calling
ReadLockable.lockForReading() and then releasing the write lock).
An entity in a locking read only file system may still be locked for writing.
For more discussions on locks and locking, see Entity and
FileSystem.
This method always returns a lock, even if the file system is not locking.
lockForWriting in interface WriteLockablepublic boolean isReadLockedByCurrentThread()
isReadLockedByCurrentThread in interface ReadLockableassertIsReadLocked()public boolean isWriteLockedByCurrentThread()
isWriteLockedByCurrentThread in interface WriteLockableassertIsWriteLocked()
public void assertIsReadLocked()
throws ReadLockRequiredException
ReadLockRequiredException - If this lockable object is not locked
for reading by the current thread.isReadLockedByCurrentThread()
public void assertIsWriteLocked()
throws WriteLockRequiredException
WriteLockRequiredException - If this lockable object is not locked
for writing by the current thread.isWriteLockedByCurrentThread()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||