All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.w3c.tools.resources.DirectoryResource

java.lang.Object
   |
   +----org.w3c.tools.resources.AttributeHolder
           |
           +----org.w3c.tools.resources.Resource
                   |
                   +----org.w3c.tools.resources.FramedResource
                           |
                           +----org.w3c.tools.resources.AbstractContainer
                                   |
                                   +----org.w3c.tools.resources.ContainerResource
                                           |
                                           +----org.w3c.tools.resources.DirectoryResource

public class DirectoryResource
extends ContainerResource
A simple, and reasonably efficient directory resource.


Variable Index

 o ATTR_DIRECTORY
Attribute index - The index for our directory attribute.
 o ATTR_DIRSTAMP
Attribute index - The last time we physically visited the directory.
 o ATTR_EXTENSIBLE
Attribute index - The index of wether we are extensible.
 o ATTR_INDEXER
Attribute index - The indexer to use for that directory, if any.

Constructor Index

 o DirectoryResource()

Method Index

 o createDefaultResource(String)
Create a default child resource in that container.
 o createDefaultResource(String, RequestInterface)
Try creating a default resource having the given name.
 o createDirectoryResource(String)
Create a DirectoryResource and the physical directory too.
 o createResource(String)
Create a Resource and the physical file too.
 o createResource(String, RequestInterface)
Create a Resource and the physical file too.
 o delete()
Delete this directory resource, for ever.
 o enumerateAllResourceIdentifiers()
Enumerate all available children resource identifiers.
 o enumerateResourceIdentifiers(boolean)
Enumerate all available children resource identifiers.
 o getDirectory()
Get the physical directory exported by this resource.
 o getDirStamp()
Get the absolute time at which we examined the physicall directory.
 o getExtensibleFlag()
Get the extensible flag value.
 o getIndexer(ResourceContext)
Get the indexer out of the given context.
 o index(String, Hashtable, RequestInterface)
Index a Resource.
 o initialize(Object[])
Initialize this directory resource with the given set of attributes.
 o lookup(String)
Lookup the resource having the given name in this directory.
 o reindex()
Reindex recursivly all the resources from this DirectoryResource.
 o resourceRemoved(StructureChangedEvent)
A resource is about to be removed This handles the RESOURCE_REMOVED kind of events.
 o setValue(int, Object)
Set some of this resource attribute.
 o updateDefaultChildAttributes(Hashtable)
Initialize and register a new resource into this directory.
 o verify()
Was return false (don't khow why)

Variables

 o ATTR_DIRECTORY
 protected static int ATTR_DIRECTORY
Attribute index - The index for our directory attribute.

 o ATTR_DIRSTAMP
 protected static int ATTR_DIRSTAMP
Attribute index - The last time we physically visited the directory.

 o ATTR_INDEXER
 protected static int ATTR_INDEXER
Attribute index - The indexer to use for that directory, if any.

 o ATTR_EXTENSIBLE
 protected static int ATTR_EXTENSIBLE
Attribute index - The index of wether we are extensible.

Constructors

 o DirectoryResource
 public DirectoryResource()

Methods

 o getIndexer
 protected ResourceReference getIndexer(ResourceContext c)
Get the indexer out of the given context.

Returns:
A ResourceIndexer instance, guaranteeed not to be null.
 o setValue
 public void setValue(int idx,
                      Object value)
Set some of this resource attribute.

Overrides:
setValue in class FramedResource
 o getDirectory
 public File getDirectory()
Get the physical directory exported by this resource.

Returns:
A non-null File object giving the directory of this resource.
 o getDirStamp
 public long getDirStamp()
Get the absolute time at which we examined the physicall directory.

Returns:
The date (as a long number of ms since Java epoch), or -1 if we never examined it before.
 o getExtensibleFlag
 public boolean getExtensibleFlag()
Get the extensible flag value. A DirectoryResource is extensible, if it is allowed to create new resources out of the file system knowledge on the fly.

Setting this flag might slow down the server. It unfortunatelly defaults to true until I have a decent admin program.

Returns:
A boolean true if the directory is extensible.
 o resourceRemoved
 public void resourceRemoved(StructureChangedEvent evt)
A resource is about to be removed This handles the RESOURCE_REMOVED kind of events.

Parameters:
evt - The event describing the change.
Overrides:
resourceRemoved in class ContainerResource
 o createDirectoryResource
 public ResourceReference createDirectoryResource(String name)
Create a DirectoryResource and the physical directory too.

Parameters:
name - the name of the resource.
Returns:
A ResourceReference instance.
 o createResource
 public ResourceReference createResource(String name)
Create a Resource and the physical file too.

Parameters:
name - the name of the resource.
Returns:
A ResourceReference instance.
 o createResource
 public ResourceReference createResource(String name,
                                         RequestInterface req)
Create a Resource and the physical file too.

Parameters:
name - the name of the resource.
req - the protocol request.
Returns:
A ResourceReference instance.
 o index
 protected Resource index(String name,
                          Hashtable defs,
                          RequestInterface req)
Index a Resource. Call the indexer.

Parameters:
name - The name of the resource to index.
defs - The defaults attributes.
req - The protocol request.
Returns:
A resource instance.
See Also:
SampleResourceIndexer
 o createDefaultResource
 public synchronized ResourceReference createDefaultResource(String name)
Create a default child resource in that container.

Overrides:
createDefaultResource in class ContainerResource
 o createDefaultResource
 protected synchronized ResourceReference createDefaultResource(String name,
                                                                RequestInterface req)
Try creating a default resource having the given name. This method will make its best effort to create a default resource having this name in the directory. If a file with this name exists, it will check the pre-defined admin extensions and look for a match. If a directory with this name exists, and admin allows to do so, it will create a sub-directory resource.

Parameters:
name - The name of the resource to try to create.
req - The incomming request
Returns:
A Resource instance, if possible, null otherwise.
 o updateDefaultChildAttributes
 protected ResourceContext updateDefaultChildAttributes(Hashtable attrs)
Initialize and register a new resource into this directory.

Parameters:
resource - The uninitialized resource to be added.
Overrides:
updateDefaultChildAttributes in class ContainerResource
 o reindex
 public synchronized void reindex()
Reindex recursivly all the resources from this DirectoryResource.

 o enumerateAllResourceIdentifiers
 protected synchronized Enumeration enumerateAllResourceIdentifiers()
Enumerate all available children resource identifiers. This method requires that we create all our pending resources.

Returns:
An enumeration of all our resources.
 o enumerateResourceIdentifiers
 public synchronized Enumeration enumerateResourceIdentifiers(boolean all)
Enumerate all available children resource identifiers. This method requires that we create all our pending resources if we are in the extensible mode...too bad !

Returns:
An enumeration of all our resources.
Overrides:
enumerateResourceIdentifiers in class ContainerResource
 o lookup
 public ResourceReference lookup(String name)
Lookup the resource having the given name in this directory.

Parameters:
name - The name of the resource.
Returns:
A resource instance, or null.
Overrides:
lookup in class ContainerResource
 o delete
 public synchronized void delete() throws MultipleLockException
Delete this directory resource, for ever. This method will delete the directory resource, and its associated store, along with any of the sub-resources it contains. Deleting the root directory of your server might take sometime...

Once the resource is deleted, it isx1 removed from its inital store and will not be unpickleable any more.

Throws: MultipleLockException
if someone has locked this resource.
Overrides:
delete in class ContainerResource
 o verify
 public synchronized boolean verify()
Was return false (don't khow why)

 o initialize
 public void initialize(Object values[])
Initialize this directory resource with the given set of attributes.

Parameters:
values - The attribute values.
Overrides:
initialize in class ContainerResource

All Packages  Class Hierarchy  This Package  Previous  Next  Index