    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 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.

##

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

##

StoreContainer()

##

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

##

ATTR_REPOSITORY

      protected static int ATTR_REPOSITORY

  Attribute index - The index of our store identifier.

ATTR_EXTENSIBLE

      protected static int ATTR_EXTENSIBLE

  Attribute index - The index of wether we are extensible.

ATTR_RELOCATE

      protected static int ATTR_RELOCATE

  Attribute index - The index for our relocate attribute.

ATTR_INDEX

      protected static int ATTR_INDEX

  Attribute index - our index resource name.

children

      protected ResourceStore children

  Our children resource store.

##

StoreContainer

      public StoreContainer()

##

acquireChildren

      protected synchronized void acquireChildren()

  Acquire the resource store. Should only be called from a synchronized method.

addResource

      protected synchronized void addResource(HTTPResource resource)

  Add an initialized resource into this store container instance.
  Parameters:
    resource - The resource to be added to the store.

save

      protected synchronized void save()

  Save the current store to disk. This store container relies on its resource store for this operation.

hasResourceStore

      public final boolean hasResourceStore()

  ContainerInterface implementation - Do we manage a store ?
  Returns:
    Always true.
  Overrides:
    hasResourceStore in class ContainerResource

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

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 FilteredResource

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

getRepository

      public 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.

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.

getRelocateFlag

      public boolean getRelocateFlag()

  Should we relocate invalid requests to this directory.
  Returns:
    A boolean true if we should relocate.

getIndex

      public String getIndex()

  Get the optinal index name for this directory listing.
  Returns:
    The name of the resource responsible to list that container.

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.

notifyStoreShutdown

      public synchronized void notifyStoreShutdown(ResourceStore store)

  ResourceStoreHolder implementation - Shutdown our associated store.
  Parameters:
    store - The store to shutdown.

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.

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.

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.

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.

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

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

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

delete

      public void delete(String child)

  Delete a given child of this directory resource.
  Parameters:
    child - The identifier of the child to delete.

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

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 AttributeHolder

    All Packages  Class Hierarchy  This Package  Previous  Next  Index