Class w3c.jigsaw.resources.DirectoryResource
All Packages Class Hierarchy This Package Previous Next Index
Class w3c.jigsaw.resources.DirectoryResource
java.lang.Object
|
+----w3c.jigsaw.resources.AttributeHolder
|
+----w3c.jigsaw.resources.Resource
|
+----w3c.jigsaw.resources.HTTPResource
|
+----w3c.jigsaw.resources.ContainerResource
|
+----w3c.jigsaw.resources.FilteredResource
|
+----w3c.jigsaw.resources.DirectoryResource
- public class DirectoryResource
- extends FilteredResource
- implements ResourceStoreHolder
A simple, and reasonably efficient directory resource.
This directory resource embeds its own resource store object to keep
track of its next children (wich might themselves be DirectoryResource). It
is reasonably efficient in the sense that it won't overload the memory with
unused informations. However, stay tuned for a really efficient
file based directory resource (tuned to serve only files).
-
ATTR_DIRECTORY
- Attribute index - The index for our directory attribute.
-
ATTR_DIRSTAMP
- Attribute index - The last we we physically visited the directory.
-
ATTR_EXTENSIBLE
- Attribute index - The index of wether we are extensible.
-
ATTR_ICONDIR
- Attribute index - The icon directory to use in dir listing.
-
ATTR_INDEX
- Attribute index - our index resource name.
-
ATTR_NEGOTIABLE
- Attribute index - Should this directory support content negotiation.
-
ATTR_RELOCATE
- Attribute index - The index for our relocate attribute.
-
ATTR_STOREID
- Attribute index - The index of our store identifier.
-
children
- Our children resource store.
-
listing
- Our current (cached) directory listing.
-
listing_stamp
- The time at which we generated the directory index.
-
repository
- Get the children resource store repository.
-
DirectoryResource()
-
-
acquireChildren()
- Acquire the directory resource store.
-
createDefaultResource(String)
- Try creating a default resource having the given name.
-
enumerateResourceIdentifiers()
- Enumerate all available children resource identifiers.
-
get(Request)
- GET on a directory, generate a directory listing.
-
getDirectory()
- Get the physical directory exported by this resource.
-
getDirectoryListing(Request)
- Reply with an HTML doc listing the resources of this directory.
-
getDirStamp()
- Get the absolute time at which we examined the physicall directory.
-
getExtensibleFlag()
- Get the extensible flag value.
-
getIconDirectory()
- Get the optional icon directory.
-
getIndex()
- Get the optinal index name for this directory listing.
-
getNegotiableFlag()
- Get the negotiable flag for this directory.
-
getRelocateFlag()
- Should we relocate invalid requests to this directory.
-
getRepository()
-
-
getStoreIdentifier()
- Get our children resource store identifier.
-
initialize(Object[])
- Initialize this directory resource with the given set of attributes.
-
lookup(LookupState)
- Lookup the next component of this lookup state in here.
-
lookup(String)
- Lookup the resource having the given name in this directory.
-
lookupStore(String)
- Lookup our store for a child of the given name.
-
main(String[])
- Create an empty resource store, and store a default resource directory
in it.
-
notifyStoreShutdown(ResourceStore)
- The resource store asks us to shutdown our associated store.
-
notifyStoreStabilize(ResourceStore)
- The resource store asks us to save our store.
-
notifyStoreUnload(ResourceStore)
- The resource store manager asks us to get rid of our store.
-
notifyUnload()
- We are being unloaded.
-
perform(Request)
- Perform requests on a directory.
-
registerResource(String, Resource, Hashtable)
- Register a new resource into this directory.
-
save()
- Save the current state of the children resource stroe.
-
unregisterResource(String)
- Unregister the resource.
-
updateNegotiableResource(String)
-
ATTR_DIRECTORY
protected static int ATTR_DIRECTORY
- Attribute index - The index for our directory attribute.
ATTR_STOREID
protected static int ATTR_STOREID
- Attribute index - The index of our store identifier.
ATTR_RELOCATE
protected static int ATTR_RELOCATE
- Attribute index - The index for our relocate attribute.
ATTR_EXTENSIBLE
protected static int ATTR_EXTENSIBLE
- Attribute index - The index of wether we are extensible.
ATTR_INDEX
protected static int ATTR_INDEX
- Attribute index - our index resource name.
ATTR_ICONDIR
protected static int ATTR_ICONDIR
- Attribute index - The icon directory to use in dir listing.
ATTR_DIRSTAMP
protected static int ATTR_DIRSTAMP
- Attribute index - The last we we physically visited the directory.
ATTR_NEGOTIABLE
protected static int ATTR_NEGOTIABLE
- Attribute index - Should this directory support content negotiation.
children
protected ResourceStore children
- Our children resource store.
listing
protected HtmlGenerator listing
- Our current (cached) directory listing.
repository
protected File repository
- Get the children resource store repository.
listing_stamp
protected long listing_stamp
- The time at which we generated the directory index.
DirectoryResource
public DirectoryResource()
getRepository
protected File getRepository()
acquireChildren
protected synchronized void acquireChildren()
- Acquire the directory resource store.
Should only be called from a synchronized method.
updateNegotiableResource
public synchronized void updateNegotiableResource(String name)
createDefaultResource
public synchronized HTTPResource createDefaultResource(String name)
- 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.
- Returns:
- A Resource instance, if possible, null
otherwise.
registerResource
public synchronized void registerResource(String identifier,
Resource resource,
Hashtable defs)
- Register a new resource into this directory.
- Parameters:
- resource - The uninitialized resource to be added.
unregisterResource
public synchronized void unregisterResource(String identifier)
- Unregister the resource.
If the resource identifier by the given identifier was a child
resource of this directory resource, it wil lbe removed.
- Parameters:
- identifier - The identifier of the child to remove.
save
public synchronized void save()
- Save the current state of the children resource stroe.
getDirectory
public File getDirectory()
- Get the physical directory exported by this resource.
- Returns:
- A non-null File object giving the directory of this resource.
getStoreIdentifier
public String getStoreIdentifier()
- Get our children resource store identifier.
- Returns:
- A non-null String object, used as our children resource store
identifier.
getRelocateFlag
public boolean getRelocateFlag()
- Should we relocate invalid requests to this directory.
- Returns:
- A boolean true if we should relocate.
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.
getIndex
public String getIndex()
- Get the optinal index name for this directory listing.
getIconDirectory
public String getIconDirectory()
- Get the optional icon directory.
getDirStamp
public long getDirStamp()
- Get the absolute time at which we examined the physicall directory.
getNegotiableFlag
public boolean getNegotiableFlag()
- Get the negotiable flag for this directory.
When turned to true, this flag indicates to the
directory resource that it should automatically build negotiated
resources ont op of all existing resources.
You should know, at least, that truning this flag on has some
not so small cost in terms of the size of the index files, and some
not so small costs in CPU time when detecting not found documents.
Otherwise, in all other situations its cost is probably negligible.
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 FilteredResource
notifyStoreUnload
public synchronized boolean notifyStoreUnload(ResourceStore store)
- The resource store manager asks us to get rid of our store.
The resource store manager has decided that our store hasn't been
used enough in the past to be worth keeping around. Shut it down
and get rid of any pointers we have to it, so that the garbage
collector will really get rid of it.
We can still defer this operation by returning false
in case a user is editing the store for example.
- Parameters:
- store - The store that has to be freed.
- Returns:
- A boolean true if the resource store has been
shutdown properly, false otherwise.
notifyStoreShutdown
public synchronized void notifyStoreShutdown(ResourceStore store)
- The resource store asks us to shutdown our associated store.
- Parameters:
- store - The store to shutdown.
notifyStoreStabilize
public synchronized boolean notifyStoreStabilize(ResourceStore store)
- The resource store asks us to save our store.
Our store has probably been modified recently, save it.
- Parameters:
- store - The store to save.
- Returns:
- A boolean true if success.
enumerateResourceIdentifiers
public synchronized Enumeration enumerateResourceIdentifiers()
- 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.
lookupStore
public synchronized HTTPResource lookupStore(String name)
- Lookup our store for a child of the given name.
This methods may trigger, on its first call, the creation of the
children ResourceStore wich is done is a lazy way, so that areas
not often visited don't get their store loaded.
- Parameters:
- name - The name of the child to lookup.
- Returns:
- A Resource instance, or null if no
match was found.
lookup
public HTTPResource 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.
lookup
public HTTPResource lookup(LookupState state) throws HTTPException
- Lookup the next component of this lookup state in here.
- Parameters:
- state - The current lookup state.
- Returns:
- A resource instance, or null if no match
was found.
- Overrides:
- lookup in class ContainerResource
getDirectoryListing
public Reply getDirectoryListing(Request request) throws HTTPException
- Reply with an HTML doc listing the resources of this directory.
This function takes special care not to regenerate a directory listing
when one is available. It also caches the date of the directory
listing, so that it can win big with NOT_MODIFIED.
Using a modem, I know that each place I can reply with an
NOT_MODIFIED, is a big win.
- Parameters:
- request - The request to handle.
- Throws: HTTPException
- If processsing the request failed.
get
public Reply get(Request request) throws HTTPException
- GET on a directory, generate a directory listing.
- Parameters:
- request - The request to handle.
- Overrides:
- get in class HTTPResource
notifyUnload
public synchronized void notifyUnload()
- We are being unloaded.
Cleanup-up our attribute values, and make sure our store is closed.
- Overrides:
- notifyUnload in class Resource
perform
public Reply perform(Request request) throws HTTPException
- Perform requests on a directory.
If an index has been given , this method delegates the actual handling
of the request to it.
- Parameters:
- request - The request to handle.
- Overrides:
- perform in class FilteredResource
main
public static void main(String args[]) throws Exception
- Create an empty resource store, and store a default resource directory
in it.
All Packages Class Hierarchy This Package Previous Next Index