All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.jigsaw.resources.StoreContainer

java.lang.Object
   |
   +----w3c.tools.store.AttributeHolder
           |
           +----w3c.tools.store.Resource
                   |
                   +----w3c.jigsaw.resources.HTTPResource
                           |
                           +----w3c.jigsaw.resources.FilteredResource
                                   |
                                   +----w3c.jigsaw.resources.ContainerResource
                                           |
                                           +----w3c.jigsaw.resources.StoreContainer

public abstract class StoreContainer
extends ContainerResource
implements ResourceStoreHolder
The abstract, store container resource class.

This class extends the basic ResourceContainer class to provide the management of the storage of children resources.

It provides means to add/remove children resources, and implement a basic lookup functionality. If marked extensible it will callback the createDefaultResource method to create them.


Variable Index

 o ATTR_EXTENSIBLE
Attribute index - The index of wether we are extensible.
 o ATTR_INDEX
Attribute index - our index resource name.
 o ATTR_RELOCATE
Attribute index - The index for our relocate attribute.
 o ATTR_REPOSITORY
Attribute index - The index of our store identifier.
 o children
Our children resource store.

Constructor Index

 o StoreContainer()

Method Index

 o acceptStoreUnload(ResourceStore)
ResourceStoreHolder implementation - Get rid of our store.
 o acquireChildren()
Acquire the resource store.
 o addResource(Resource)
Add an initialized resource into this store container instance.
 o delete()
Delete that resource store.
 o delete(String)
Delete a given child of this directory resource.
 o enumerateResourceIdentifiers(boolean)
Enumerate the name (ie identifiers) of our children.
 o getClone(Object[])
Clone a store container.
 o getExtensibleFlag()
Get the extensible flag value.
 o getIndex()
Get the optinal index name for this directory listing.
 o getRelocateFlag()
Should we relocate invalid requests to this directory.
 o getRepository()
Get our children resource store file.
 o getResourceStore(ResourceStoreHolder)
ContainerInterface implementation - Hold underlying resource store.
 o hasResourceStore()
ContainerInterface implementation - Do we manage a store ?
 o initialize(Object[])
Initialize ourself.
 o lookup(LookupState, LookupResult)
Lookup the next component of this lookup state in here.
 o lookup(String)
Lookup the resource having the given name in this directory.
 o lookupStore(String)
Lookup our store for a child of the given name.
 o lookupStore(String, Hashtable)
Lookup our store for a child of the given name.
 o notifyStoreShutdown(ResourceStore)
ResourceStoreHolder implementation - Shutdown our associated store.
 o notifyStoreStabilize(ResourceStore)
ResourceStoreHolder implementation - Save our store.
 o notifyUnload()
We are being unloaded.
 o registerResource(String, Resource, Hashtable)
Initialize and register the given resource under the given name.
 o save()
Save the current store to disk.
 o setValue(int, Object)
Keep our cached repository value in sync.
 o updateDefaultChildAttributes(Hashtable)
Update default child attributes.

Variables

 o ATTR_REPOSITORY
 protected static int ATTR_REPOSITORY
Attribute index - The index of our store identifier.

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

 o ATTR_RELOCATE
 protected static int ATTR_RELOCATE
Attribute index - The index for our relocate attribute.

 o ATTR_INDEX
 protected static int ATTR_INDEX
Attribute index - our index resource name.

 o children
 protected ResourceStore children
Our children resource store.

Constructors

 o StoreContainer
 public StoreContainer()

Methods

 o acquireChildren
 protected synchronized void acquireChildren()
Acquire the resource store. Should only be called from a synchronized method.

 o addResource
 protected synchronized void addResource(Resource resource)
Add an initialized resource into this store container instance.

Parameters:
resource - The resource to be added to the store.
 o save
 protected synchronized void save()
Save the current store to disk. This store container relies on its resource store for this operation.

 o hasResourceStore
 public final boolean hasResourceStore()
ContainerInterface implementation - Do we manage a store ?

Returns:
Always true.
Overrides:
hasResourceStore in class ContainerResource
 o getResourceStore
 public synchronized ResourceStore getResourceStore(ResourceStoreHolder h)
ContainerInterface implementation - Hold underlying resource store.

Parameters:
h - The resource store holder.
Returns:
A pointer to our underlying store.
Overrides:
getResourceStore in class ContainerResource
 o getClone
 public Object getClone(Object values[])
Clone a store container. Cloning a store container doesn't clone the associated resource store. The clone gets a new, empty resource store by default.

Parameters:
values - The initial attribute values for the clone.
Returns:
A StoreContainer resource, having an empty store, but otherwise similar to its master.
Overrides:
getClone in class Resource
 o setValue
 public synchronized void setValue(int idx,
                                   Object value)
Keep our cached repository value in sync.

Parameters:
idx - The index of the attribute to set.
value - The new value for the attribute.
Overrides:
setValue in class HTTPResource
 o getRepository
 public synchronized File getRepository()
Get our children resource store file. If we haven't created yet our backup file, we create it right now.

Returns:
A non-null File instance giving the location of the file used to dump our store.
 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 getRelocateFlag
 public boolean getRelocateFlag()
Should we relocate invalid requests to this directory.

Returns:
A boolean true if we should relocate.
 o getIndex
 public String getIndex()
Get the optinal index name for this directory listing.

Returns:
The name of the resource responsible to list that container.
 o acceptStoreUnload
 public synchronized boolean acceptStoreUnload(ResourceStore store)
ResourceStoreHolder implementation - 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.

We can still defer this operation by returning false in case a user is editing the store for example.

Parameters:
store - The store that to be freed.
Returns:
A boolean true if the resource store has been shutdown properly, false otherwise.
 o notifyStoreShutdown
 public synchronized void notifyStoreShutdown(ResourceStore store)
ResourceStoreHolder implementation - Shutdown our associated store.

Parameters:
store - The store to shutdown.
 o notifyStoreStabilize
 public void notifyStoreStabilize(ResourceStore store)
ResourceStoreHolder implementation - Save our store. Our store has probably been modified recently, save it.

Parameters:
store - The store to save.
Returns:
A boolean true if success.
 o updateDefaultChildAttributes
 protected void updateDefaultChildAttributes(Hashtable attrs)
Update default child attributes. A parent can often pass default attribute values to its children, such as a pointer to itself (the parent attribute).

This is the method to overide when you want your container to provide these kinds of attributes. By default this method will set the following attributes:

name
The name of the child (it's identifier) - String instance.
parent
The parent of the child (ie ourself here) - a ContainerResource instance.
resource-store
This child store - a ResourceStore instance.
server
The server context of the child - a httpd instance.
url
If a identifier attribute is defined, that attribute is set to the full URL path of the children.

 o registerResource
 public synchronized void registerResource(String identifier,
                                           Resource resource,
                                           Hashtable defs)
Initialize and register the given resource under the given name.

Overrides:
registerResource in class ContainerResource
 o lookupStore
 protected synchronized HTTPResource lookupStore(String name,
                                                 Hashtable defs) throws InvalidResourceException
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.
defs - A set of default attribute values.
Returns:
A Resource instance, or null if no match was found.
Throws: InvalidResourceException
If the resource exists, but cannot be unloaded from the store.
 o lookupStore
 protected HTTPResource lookupStore(String name) throws InvalidResourceException
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 HTTPResource instance, or null if no match was found.
 o lookup
 public Resource lookup(String name) throws InvalidResourceException
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 lookup
 public boolean lookup(LookupState ls,
                       LookupResult lr) throws HTTPException
Lookup the next component of this lookup state in here.

Parameters:
ls - The current lookup state.
lr - The lookup result under construction.
Returns:
A boolean, true if lookup has completed, false if it should be continued by the caller.
Throws: HTTPException
If an error occurs.
Overrides:
lookup in class ContainerResource
 o 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
 o delete
 public synchronized void delete()
Delete that resource store. This also removes the store we are managing.

Overrides:
delete in class HTTPResource
 o delete
 public void delete(String child)
Delete a given child of this directory resource.

Parameters:
child - The identifier of the child to delete.
Overrides:
delete in class ContainerResource
 o enumerateResourceIdentifiers
 public synchronized Enumeration enumerateResourceIdentifiers(boolean all)
Enumerate the name (ie identifiers) of our children.

Parameters:
all - Should all resources be listed.
Returns:
An enumeration, providing one element per child, which is the name of the child, as a String.
Overrides:
enumerateResourceIdentifiers in class ContainerResource
 o initialize
 public void initialize(Object values[])
Initialize ourself. As we are a container resource that really contains something, we make sure our URL ends properly with a slash.

Parameters:
values - Our default attribute values.
Overrides:
initialize in class FilteredResource

All Packages  Class Hierarchy  This Package  Previous  Next  Index