org.entityfs.impl
Interface EntityImplementation

All Superinterfaces:
Comparable<EntityView>, Deletable, Entity, EntityView, EntityViewImplementation, Lockable, Named, Observable, ReadLockable, ReadWriteLockable, WriteLockable
All Known Subinterfaces:
DirectoryImplementation, EFileImplementation, EntityAcceptingEntityImplementation<T>, SymbolicLinkImplementation
All Known Implementing Classes:
AbstractEntityAcceptingEntityImpl, AbstractEntityImpl, DirectoryImpl, FileImpl, SymbolicLinkImpl

public interface EntityImplementation
extends EntityViewImplementation, Entity

Implementation of an Entity. It contains methods that are only used by file system implementations; not by file system clients. An Entity object can always be cast to EntityImplementation.

All entity implementations should be designed to be proxied (see the developer's guide).

See the developer's guide for how copy should be implemented.

Entity implementations are divided into two layers; the implementation layer and the backend implementation layer (see EntityAdapter). See the developer's guide for how the layers are separated.

For the implementation layer, the objects implementing this interface implements the entity aspects of each entity type, such as object identity, locking and access controls. Implementations of behaviors of each entity type are delegated to EntityDelegate implementations. Each entity object has a chain of EntityDelegates. Capability providers can introduced new delegates in the chain.

The methods in this interface should only be used by file system and capability implementations.

Since:
1.0
Author:
Karl Gustafsson
In_jar:
entityfs-core

Method Summary
 void assertIsReadLocked()
          Entity methods call this to verify that the client has locked the entity for reading.
 void assertIsWriteLocked()
          Entity methods call this to verify that the client has locked the entity for writing.
 void assertNotReadOnly()
          Entity methods call this to verify that the file system is not read only.
 void assertOk()
          Entity methods call this to verify that the entity is ok.
 void assertParentIsReadLocked()
          Entity methods call this to verify that the client has locked the entity's parent directory for reading.
 void assertParentIsWriteLocked()
          Entity methods call this to verify that the client has locked the entity's parent directory for writing.
 void createLockInternal(Object identifier)
          This method can be used by entity delegates to create their own entity locks.
 void fireEvent(EntityEvent<?> ev)
          Use the file system's EventManager to fire an event with this entity as its sender.
 EntityDelegate getDelegate()
           
 EntityDelegate getDelegateOfType(Class<? extends EntityDelegate> c)
          Get the delegate implementation of the specified type.
 EntityDelegate getDelegateOfTypeOrNull(Class<? extends EntityDelegate> c)
          Get the delegate implementation of the specified type.
 EntityAdapter getEntityAdapter()
          This method is used by capability implementations that require a specific adapter implementation.
 void init()
          This method is called when the object has been fully created but before it is used by any clients.
 void verifyHasExecuteAccess()
          Verify that the caller has execute access to this entity.
 void verifyHasExecuteAccessToParent()
          Verify that the caller has execute access to this entity's parent directory.
 void verifyHasReadAccess()
          Verify that the caller has read access to this entity.
 void verifyHasReadAccessToParent()
          Verify that the caller has read access to this entity's parent directory.
 void verifyHasWriteAccess()
          Verify that the caller has write access to this entity.
 void verifyHasWriteAccessToParent()
          Verify that the caller has write access to this entity's parent directory.
 
Methods inherited from interface org.entityfs.impl.EntityViewImplementation
getAbsoluteLocationNoLocking, getFileSystemImplementation, getNameNoLocking, getObserverList
 
Methods inherited from interface org.entityfs.Entity
hasExecuteAccess, hasReadAccess, hasWriteAccess
 
Methods inherited from interface org.entityfs.EntityView
canRead, canWrite, copy, copy, copyAttributes, createLock, disconnect, getCapability, getFileSystem, getLastModified, getParent, getType, getViewed, getViewedEntity, isConnected, isRootDirectory, isValid, lock, rename, setLastModified, supportsCapability, touch
 
Methods inherited from interface java.lang.Comparable
compareTo
 
Methods inherited from interface org.entityfs.event.Observable
addObserver, countObservers, deleteObserver, deleteObservers
 
Methods inherited from interface org.entityfs.Named
getName
 
Methods inherited from interface org.entityfs.lock.ReadLockable
getReadLock, isReadLockedByCurrentThread, lockForReading
 
Methods inherited from interface org.entityfs.Deletable
delete, isDeleted
 
Methods inherited from interface org.entityfs.lock.WriteLockable
getWriteLock, isWriteLockedByCurrentThread, lockForWriting
 

Method Detail

getDelegate

EntityDelegate getDelegate()

getDelegateOfType

EntityDelegate getDelegateOfType(Class<? extends EntityDelegate> c)
                                 throws NoSuchDelegateException
Get the delegate implementation of the specified type. This is used by capability providers to get access to their delegates when creating capability objects.

Parameters:
c - The type of the delegate.
Returns:
The first encountered delegate of the specified type.
Throws:
NoSuchDelegateException - If the entity does not have any such delegate.
See Also:
getDelegateOfTypeOrNull(Class)

getDelegateOfTypeOrNull

EntityDelegate getDelegateOfTypeOrNull(Class<? extends EntityDelegate> c)
Get the delegate implementation of the specified type. This is used by capability providers to get access to their delegates when creating capability objects.

Parameters:
c - The type of the delegate.
Returns:
The first encountered delegate of the specified type, or null if no matching delegate can be found.
See Also:
getDelegateOfType(Class)

getEntityAdapter

EntityAdapter getEntityAdapter()
This method is used by capability implementations that require a specific adapter implementation. All other methods should go through entity delegates to use the backend adapters.

Returns:
The EntityAdapter instance for the entity.

assertIsReadLocked

void assertIsReadLocked()
                        throws ReadLockRequiredException
Entity methods call this to verify that the client has locked the entity for reading.

Throws:
ReadLockRequiredException - If the entity is not locked for reading by the calling thread.

assertParentIsReadLocked

void assertParentIsReadLocked()
                              throws ReadLockRequiredException,
                                     UnsupportedOperationException
Entity methods call this to verify that the client has locked the entity's parent directory for reading. If this is called on the root directory of a file system, nothing happens.

Throws:
ReadLockRequiredException - If the entity's parent is not locked for reading by the calling thread.
UnsupportedOperationException

assertIsWriteLocked

void assertIsWriteLocked()
                         throws WriteLockRequiredException
Entity methods call this to verify that the client has locked the entity for writing.

Throws:
WriteLockRequiredException - If the entity is not locked for writing by the calling thread.

assertParentIsWriteLocked

void assertParentIsWriteLocked()
                               throws WriteLockRequiredException,
                                      UnsupportedOperationException
Entity methods call this to verify that the client has locked the entity's parent directory for writing. If this is called on a file system's root directory, nothing happens.

Throws:
WriteLockRequiredException - If the entity's parent directory is not locked for writing by the calling thread.
UnsupportedOperationException - If this is called on the file system's root directory.

assertNotReadOnly

void assertNotReadOnly()
                       throws ReadOnlyException
Entity methods call this to verify that the file system is not read only.

Throws:
ReadOnlyException - If the file system is read only.

assertOk

void assertOk()
              throws EntityNotFoundException
Entity methods call this to verify that the entity is ok. An implementation of this method should use the file system's EntityValidityControlStrategy.

It must be verified that the entity is at least locked for reading before this method is called.

Throws:
EntityNotFoundException - If the entity has disappeared from the backend.

fireEvent

void fireEvent(EntityEvent<?> ev)
Use the file system's EventManager to fire an event with this entity as its sender.

Parameters:
ev - The event.

createLockInternal

void createLockInternal(Object identifier)
This method can be used by entity delegates to create their own entity locks. The delegate is responsible for making sure that the entity is locked for writing (or not published at all) when calling this method.

Parameters:
identifier - The lock identifier.

init

void init()
This method is called when the object has been fully created but before it is used by any clients. It should contain initialization logic that requires that the object is fully created.

Implementations are required to call init on the first delegate in their delegate chain.


verifyHasReadAccess

void verifyHasReadAccess()
                         throws AccessDeniedException
Verify that the caller has read access to this entity.

Before calling this method, make sure that the caller has at least a read lock on the entity.

Throws:
AccessDeniedException - If the caller does not have read access to this entity.
See Also:
AccessController, assertIsReadLocked(), assertIsWriteLocked(), verifyHasWriteAccess(), verifyHasExecuteAccess(), verifyHasReadAccessToParent()

verifyHasWriteAccess

void verifyHasWriteAccess()
                          throws AccessDeniedException
Verify that the caller has write access to this entity.

Before calling this method, make sure that the caller has at least a read lock on the entity.

Throws:
AccessDeniedException - If the caller does not have write access to this entity.
See Also:
AccessController, assertIsReadLocked(), assertIsWriteLocked(), verifyHasReadAccess(), verifyHasExecuteAccess(), verifyHasWriteAccessToParent()

verifyHasExecuteAccess

void verifyHasExecuteAccess()
                            throws AccessDeniedException
Verify that the caller has execute access to this entity.

Before calling this method, make sure that the caller has at least a read lock on the entity.

Throws:
AccessDeniedException - If the caller does not have execute access to this entity.
See Also:
AccessController, assertIsReadLocked(), assertIsWriteLocked(), verifyHasReadAccess(), verifyHasWriteAccess(), verifyHasExecuteAccessToParent()

verifyHasReadAccessToParent

void verifyHasReadAccessToParent()
                                 throws AccessDeniedException,
                                        EntityNotFoundException
Verify that the caller has read access to this entity's parent directory.

Before calling this method, make sure that the caller has at least a read lock on the parent entity.

Throws:
AccessDeniedException - If the caller does not have read access to this entity's parent directory.
EntityNotFoundException - If this method is called on the root directory of a file system.
See Also:
AccessController, assertParentIsReadLocked(), assertParentIsWriteLocked(), verifyHasWriteAccessToParent(), verifyHasExecuteAccessToParent(), verifyHasReadAccess()

verifyHasWriteAccessToParent

void verifyHasWriteAccessToParent()
                                  throws AccessDeniedException,
                                         EntityNotFoundException
Verify that the caller has write access to this entity's parent directory.

Before calling this method, make sure that the caller has at least a read lock on the parent entity.

Throws:
AccessDeniedException - If the caller does not have write access to this entity's parent directory.
EntityNotFoundException - If this method is called on the root directory of a file system.
See Also:
AccessController, assertParentIsReadLocked(), assertParentIsWriteLocked(), verifyHasReadAccessToParent(), verifyHasExecuteAccessToParent(), verifyHasWriteAccess()

verifyHasExecuteAccessToParent

void verifyHasExecuteAccessToParent()
                                    throws AccessDeniedException,
                                           EntityNotFoundException
Verify that the caller has execute access to this entity's parent directory.

Before calling this method, make sure that the caller has at least a read lock on the parent directory.

Throws:
AccessDeniedException - If the caller does not have execute access to this entity's parent directory.
EntityNotFoundException - If this method is called on the root directory of a file system.
See Also:
AccessController, assertParentIsReadLocked(), assertParentIsWriteLocked(), verifyHasWriteAccessToParent(), verifyHasReadAccessToParent(), verifyHasExecuteAccess()