org.entityfs.lock
Interface ReadLockable

All Superinterfaces:
Lockable
All Known Subinterfaces:
Directory, DirectoryImplementation, DirectoryView, DirectoryViewImplementation, ECMetadata, EFile, EFileImplementation, Entity, EntityAcceptingEntity<T>, EntityAcceptingEntityImplementation<T>, EntityAcceptingEntityView<T>, EntityAcceptingEntityViewImplementation<T>, EntityHolder, EntityImplementation, EntityListable, EntityRepository, EntityView, EntityViewImplementation, Named, NamedReadableFile, RandomlyAccessibleFile, ReadableFile, ReadWritableFile, ReadWriteLockable, SymbolicLink, SymbolicLinkImplementation, SymbolicLinkView, SymbolicLinkViewImplementation
All Known Implementing Classes:
AbstractEntityAcceptingEntityImpl, AbstractEntityAcceptingEntityView, AbstractEntityImpl, AbstractEntityViewImpl, AbstractLockable, AbstractReadableFile, AbstractReadWritableFile, AbstractReadWriteLockableProxy, AggregatingEntityRepository, ByteArrayReadableFile, CharSequenceReadableFile, ClasspathNamedReadableFile, CompoundEntityHolder, DirectoryImpl, DirectoryViewImpl, ECMetadataImpl, FileDelegateReadWritableFileAdapter, FileImpl, FileReadableFile, GZipReadableFile, ManualEntityListable, ManualNamedReadableFile, MetadataFileAdapter, NamedReadableFileAdapter, ReadWritableFileAdapter, SymbolicLinkImpl, SymbolicLinkViewImpl, UrlReadableFile

public interface ReadLockable
extends Lockable

This interface is implemented by classes that can be locked for reading. This can for instance be an entity, or a read-enabled aspect of an entity, such as ReadableFile.

Since:
1.0
Author:
Karl Gustafsson
See Also:
WriteLockable
In_jar:
entityfs-core

Method Summary
 EntityLock getReadLock()
          Get the read lock without locking it.
 boolean isReadLockedByCurrentThread()
          Does the calling thread hold a read lock for this object? A write lock also qualifies as a read lock.
 EntityLock lockForReading()
          Lock object for reading and return the lock.
 

Method Detail

getReadLock

EntityLock getReadLock()
Get the read lock without locking it.

This method always returns a lock, even if the object's file system is not locking or if the object is read only.

Returns:
The lockable's read lock. This might be unlocked or locked by someone else.
Permissions_required:
None.

lockForReading

EntityLock lockForReading()
                          throws LockTimeoutException
Lock object for reading and return the lock. How the lock is acquired is determined by the EntityLockAdapterFactory 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.

Returns:
A locked read lock.
Throws:
LockTimeoutException - If the lock acquiring timed out. (It is up to the LockAcquiringStrategy to decide if lock acquiring can time out.)
Permissions_required:
None.

isReadLockedByCurrentThread

boolean isReadLockedByCurrentThread()
                                    throws IllegalStateException
Does the calling thread hold a read lock for this object? A write lock also qualifies as a read lock.

Returns:
true if the lockable object is read or write locked by the current thread.
Throws:
IllegalStateException - If this is called on a disconnected entity view.
Permissions_required:
None.