|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface EntityDelegate
Entity delegates are EntityFS' mechanism of having an extensible entity
implementation without having to modify the entity objects themselves.
(Remember that since object identity is important for entities, they must not
be proxied by, for instance, capability implementations.) The
EntityImplementation
implementations take care of implementing the
entity aspects of each entity type, and they never have to be touched by
capability providers, other than when they want to introduce entirely new
entity types. Entity implementations delegate responsibility for the aspects
closer to what the different entity types actually do (open a file, etc) to
their chain of entity delegates. Capability providers extend the
functionality of existing entity types by inserting new entity delegate
implementations in the entity's delegate chain.
An entity delegate implementation is either the implementation of a delegate
for a certain entity type, or a capability provider's implementation of
extended functionality for an existing entity type. In the first case, the
delegate implementation uses the entity's
EntityAdapter
to do its work, in the second
case it mostly uses its proxied delegate, but it can also use entity adapters
if the capability is such that it can make assumptions about the backend
implementation. (Some capabilities require certain backend implementations.)
The delegate also can make callbacks to the entity object that owns
it, but they should only be made to methods that don't do any entity locking.
A capability that requires another capability to work can get that
capability's implementation through the
getDelegateOfTypeOrNull(Class)
method. It is up to each capability
implementation to decide which API it wants to publish to other capabilities.
The entity implementation takes care of (at least) the following before calling its delegate chain:
EntityAdapter
.EntityAdapter
to perform its work.
FileSystemDelegate
Method Summary | |
---|---|
boolean |
canRead()
Check with the backend to see if this entity can be read. |
boolean |
canWrite()
Check with the backend to see if this entity can be written to. |
Set<EntityView> |
copy(DirectoryImplementation targetDir,
String targetName,
boolean preserveAttrs,
List<EntityAttributeSetter> asl,
EntityLock[] setupLocks)
Copy the entity. |
void |
copyAttributes(DirectoryImplementation targetParent,
EntityImplementation target)
Copy entity attributes from this entity to the target. |
boolean |
exists()
Does the entity really exist in the backend? This is used by some EntityValidityControlStrategy :s. |
EntityDelegate |
getDelegateOfTypeOrNull(Class<? extends EntityDelegate> c)
Get an instance of a specific delegate type from the chain of delegates. |
EntityAdapter |
getEntityAdapter()
Get the underlying EntityAdapter . |
FileSystemImplementation |
getFileSystem()
Get the file system that owns this delegate's entity. |
long |
getLastModified()
Get the last time that the entity was modified. |
String |
getName()
Get the entity's name. |
EntityImplementation |
getOwner()
Get the owner of this delegate. |
void |
init()
This method is called after the entire entity object has been fully created, but before it is published. |
boolean |
isReadOnly()
Does the delegate or a delegate proxy make this entity read only? |
void |
rename(String oldName,
DirectoryImplementation targetDir,
String newName)
Rename and/or move the entity. |
void |
setLastModified(long t)
Set the time of last modification for the entity. |
void |
setOwner(EntityImplementation owner)
This is set when the entity object is created. |
Method Detail |
---|
EntityDelegate getDelegateOfTypeOrNull(Class<? extends EntityDelegate> c)
c
- The delegate type.
null
if no such delegate can be
found.void setOwner(EntityImplementation owner)
owner
- The owning entity object.init()
EntityImplementation getOwner()
FileSystemImplementation getFileSystem()
EntityAdapter getEntityAdapter()
EntityAdapter
. This should only be called by
delegate proxies that introduce entirely new entity types.
boolean exists()
EntityValidityControlStrategy
:s.
true
if the entity exists in the backend.boolean canRead()
true
if the backend can be read.boolean canWrite()
If isReadOnly()
returns true
, this method should always
return false
. (The opposite is not true, however.)
true
if the backend can be written to.boolean isReadOnly()
This method is invoked frequently and should execute fast. It is only invoked for read/write file systems.
true
if the delegate has made the entity read only.long getLastModified()
void setLastModified(long t)
t
- A time stamp.void rename(String oldName, DirectoryImplementation targetDir, String newName) throws FileSystemException
oldName
- The old name,targetDir
- The new parent directory.newName
- The new name.
FileSystemException
- On errors.Set<EntityView> copy(DirectoryImplementation targetDir, String targetName, boolean preserveAttrs, List<EntityAttributeSetter> asl, EntityLock[] setupLocks)
targetDir
- The target directory of the new entity. This directory
may be in another file system.targetName
- The name of the new entity.preserveAttrs
- Should entity attributes be copied to the target
entity?asl
- A list of EntityAttributeSetter
:s that are run just
after the target entity has been created, before the setupLocks
are released. This may be null
. This may only be non-null
if preserveAttrs
is true
.setupLocks
- Exception to the rule that the delegate should not
bother with locking. This is here so that the delegate can release locks
used to set up the target entity before data is copied to it. This method
is responsible for unlocking this lock regardless of whether it is
successful or fails.
Set
are real entities, not views.void copyAttributes(DirectoryImplementation targetParent, EntityImplementation target)
targetParent
- The parent directory of the target. This is null
if target
is a root directory of a file system. Otherwise
it is locked for writing.target
- The target entity to copy attributes to. Locked for
writing.void init()
Implementations are required to call init
on proxied delegates
and on entity adapters.
String getName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |