    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Class org.w3c.tools.resources.store.ResourceStoreManager

    java.lang.Object
       |
       +----org.w3c.tools.resources.store.ResourceStoreManager

public class ResourceStoreManager
extends Object
implements ResourceSpace

##

closed
  Is this store shutdown ?
debugMemory
eventQueue
index
  Our index file.
lru
  The store entries least recetenly used list.
root_rep
root_repository
  Our root repository.
server_name
  server name;
state
storedir
  Our store directory.
STOREFILE_IDENTIFIER
  The identifier for resource store files.
sweeper
  Our sweeper thread:

##

ResourceStoreManager(String, File, String, String, Hashtable)
  Create a new resource store manager for given store directory.

##

acquireChildren(SpaceEntry)
  Acquire the StoreEntry of the space entry.
acquireChildren(SpaceEntry, File, boolean)
  acquire children from an external file.
addResource(SpaceEntry, Resource, Hashtable)
  Add this resource to the StoreEntry of the space entry.
checkClosed()
  Check that this resource store manager isn't closed.
checkMaxLoadedStore()
checkpoint()
  Checkpoint all modified resource stores, by saving them to disk.
collect()
  Collect enough entries to go back into fixed limits.
createResourceStoreRepository()
  Create a resource store repository name.
decrLoadedStore()
deleteChildren(SpaceEntry)
  Delete all the children of resource indentified by its space entry.
deleteResource(SpaceEntry, Resource)
  delete this resource from the StoreEntry (and the repository).
displayIndex()
enumerateResourceIdentifiers(SpaceEntry)
  Enumerate the name (ie identifiers) of the space entry children.
getCurrentStoreIdentifier()
getEventQueue()
getIndexFile()
  Get the index file.
getMaxLoadedStore()
getRootKey()
  Get The root key.
getRootRepository()
  Get the root repository.
incrLoadedStore()
loadEntriesIndex()
  Load the index file.
loadResource(SpaceEntry, String, Hashtable)
  Restore the resource whose name is given.
loadRootResource(String, Hashtable)
  Restore the resource whose name is given from the root StoreEntry.
lookupResource(SpaceEntry, String)
  Lookup this resource.
markModified(SpaceEntry, Resource)
  Mark the given resource as being modified.
markUsed(Object)
  Mark the given store as having been used recently.
pickleProlog(DataOutputStream, ResourceStore)
  Dump a prolog in given stream for that resource store.
pickLRUEntry()
  Pick the least recently used entry, and remove all links to it.
renameResource(SpaceEntry, String, String)
  Rename a resource in this resource space.
salvage()
salvageState()
  Try to salvage the resource store manager state.
saveChildren(SpaceEntry)
  Save all the children of the resource indentified by its spaec entry.
saveEntriesIndex()
  Save the index file.
saveResource(SpaceEntry, Resource)
  Save this resource to the StoreEntry of the space entry.
shutdown()
  Shutdown this resource store manager.
unpickleProlog(DataInputStream, ResourceStore)
  Read in the prolog from the given input stream.
used(String)
warning(String)
  Emit the given string as a warning, to whoever it is appropriate.

##

STOREFILE_IDENTIFIER

     public static final int STOREFILE_IDENTIFIER

  The identifier for resource store files. All files that are used as resource store, and whose resource store implementation make use of `pickleProlog` will start with a dump of that integer.

  See Also:
    pickleProlog, unpickleProlog

root_rep

     public static final String root_rep

debugMemory

     public boolean debugMemory

closed

     protected boolean closed

  Is this store shutdown ?

storedir

     protected File storedir

  Our store directory.

index

     protected File index

  Our index file.

server_name

     protected String server_name

  server name;

root_repository

     protected File root_repository

  Our root repository.

lru

     protected LRUList lru

  The store entries least recetenly used list.

state

     protected ResourceStoreState state

sweeper

     protected StoreManagerSweeper sweeper

  Our sweeper thread:

eventQueue

     protected ResourceEventQueue eventQueue

##

ResourceStoreManager

     public ResourceStoreManager(String server_name,
                                 File storedir,
                                 String default_root_class,
                                 String default_root_name,
                                 Hashtable defs)

  Create a new resource store manager for given store directory. The resource store manager will manage the collection of stores contained in the directory, and keep track of the stores state.

  Parameters:
    storedir - The store directory to manage.

##

getEventQueue

     public ResourceEventQueue getEventQueue()

getMaxLoadedStore

     protected final int getMaxLoadedStore()

incrLoadedStore

     protected void incrLoadedStore()

decrLoadedStore

     protected void decrLoadedStore()

checkClosed

     protected final synchronized void checkClosed()

  Check that this resource store manager isn't closed.

  Throws: RuntimeException
    If the store manager was closed.

pickLRUEntry

     protected synchronized StoreEntry pickLRUEntry()

  Pick the least recently used entry, and remove all links to it. After this method as run, the least recently used entry for some store will be returned. The store manager will have discarded all its link to it, and the entry shutdown will have to be performed by the caller.

  Returns:
    An StoreEntry instance, to be cleaned up.

collect

     public void collect()

  Collect enough entries to go back into fixed limits.

createResourceStoreRepository

     public String createResourceStoreRepository()

  Create a resource store repository name. This method will return a new resource store repository key. When used in conjunction with the `loadResourceStore` method that takes a key as a parameter, this allows to caller to abstract itself from the physical location of the repository.

  Returns:
    A fresh resource store key, guaranteed to be uniq.

getCurrentStoreIdentifier

     public int getCurrentStoreIdentifier()

getIndexFile

     protected File getIndexFile()

  Get the index file.

  Returns:
    A File instance.

getRootRepository

     protected File getRootRepository()

  Get the root repository.

  Returns:
    A File instance.

getRootKey

     protected Integer getRootKey()

  Get The root key.

  Returns:
    A String instance

warning

     protected void warning(String msg)

  Emit the given string as a warning, to whoever it is appropriate.

  Parameters:
    msg - The warning message.

saveEntriesIndex

     protected synchronized void saveEntriesIndex()

  Save the index file.

loadEntriesIndex

     protected synchronized void loadEntriesIndex()

  Load the index file.

shutdown

     public synchronized void shutdown()

  Shutdown this resource store manager. Go through all entries, and shut them down.

checkpoint

     public void checkpoint()

  Checkpoint all modified resource stores, by saving them to disk.

markUsed

     public void markUsed(Object token)

  Mark the given store as having been used recently.

  Parameters:
    token - The token the resource store manager provided you when it initialized the store.

pickleProlog

     public static void pickleProlog(DataOutputStream out,
                                     ResourceStore store) throws IOException

  Dump a prolog in given stream for that resource store. Using the resource store manager prolog in a resource store implementation is optional. However, it is recommended that whenever possible, you use it to get the benefits of the main method of that class.

  Parameters:
    out - The output stream to dump the prolog to.
    store - The resource store which is being dumped.
  Throws: IOException
    If the prolog couldn't be pickled to the given output stream.
  See Also:
    unpickleProlog

unpickleProlog

     public static void unpickleProlog(DataInputStream in,
                                       ResourceStore store) throws IOException, NotAStoreException, InvalidStoreClassException, StoreClassVersionException

  Read in the prolog from the given input stream. This method checks the consistency between the implementation of the store that wants to read from that stream, and the implementation of the store that has been used to create it.

  Using that method, as well as using the `pickleProlog` method is optional; however, using one makes using the other mandatory.

  Parameters:
    in - The input stream to read the prolog from.
    store - The store that is to be created from the given input stream.
  Throws: IOException
    If the stream couldn't be read.
  Throws: NotAStoreException
    If the given repository wasn't flagged as containing a resource store.
  Throws: InvalidStoreClassException
    If the loading class is not the saving class.
  Throws: StoreClassVersionException
    If the saved store version number doesn't match the loader's class version number.
  See Also:
    pickleProlog

used

     protected boolean used(String rep)

salvage

     public void salvage()

displayIndex

     public void displayIndex()

salvageState

     public ResourceStoreState salvageState()

  Try to salvage the resource store manager state. That's pretty easy and robust, it should really work well if no one hacked the store directory.

  Returns:
    A ResourceStoreState instance.

loadRootResource

     public ResourceReference loadRootResource(String identifier,
                                               Hashtable defs)

  Restore the resource whose name is given from the root StoreEntry.

  Parameters:
    identifier - The identifier of the resource to restore.
    defs - Default attribute values.

lookupResource

     public ResourceReference lookupResource(SpaceEntry sentry,
                                             String identifier)

  Lookup this resource.

  Parameters:
    sentry - The resource space entry.
    identifier - The resource identifier.
  Returns:
    A Resource instance, or null if either the resource doesn't exist, or it isn't loaded yet.

loadResource

     public ResourceReference loadResource(SpaceEntry sentry,
                                           String identifier,
                                           Hashtable defs)

  Restore the resource whose name is given.

  Parameters:
    sentry - The resource space entry.
    identifier - The identifier of the resource to restore.
    defs - Default attribute values.

addResource

     public ResourceReference addResource(SpaceEntry sentry,
                                          Resource resource,
                                          Hashtable defs)

  Add this resource to the StoreEntry of the space entry.

  Parameters:
    sentry - The resource space entry.
    resource - The resource to add.
    defs - Default attribute values.

saveResource

     public void saveResource(SpaceEntry sentry,
                              Resource resource)

  Save this resource to the StoreEntry of the space entry.

  Parameters:
    sentry - The resource space entry
    resource - The resource to save.

markModified

     public void markModified(SpaceEntry sentry,
                              Resource resource)

  Mark the given resource as being modified.

  Parameters:
    sentry - The resource space entry.
    resource - The resource to mark as modified.

renameResource

     public void renameResource(SpaceEntry sentry,
                                String oldid,
                                String newid)

  Rename a resource in this resource space.

  Parameters:
    sentry - The resource space entry.
    oldid - The old resorce identifier.
    newid - The new resorce identifier.

deleteResource

     public void deleteResource(SpaceEntry sentry,
                                Resource resource)

  delete this resource from the StoreEntry (and the repository).

  Parameters:
    sentry - The resource space entry
    resource - The resource to delete.

deleteChildren

     public void deleteChildren(SpaceEntry sentry)

  Delete all the children of resource indentified by its space entry.

  Parameters:
    sentry - The resource space entry

saveChildren

     public void saveChildren(SpaceEntry sentry)

  Save all the children of the resource indentified by its spaec entry.

  Parameters:
    sentry - The resource space entry

checkMaxLoadedStore

     protected void checkMaxLoadedStore()

acquireChildren

     public void acquireChildren(SpaceEntry sentry,
                                 File repository,
                                 boolean transientFlag)

  acquire children from an external file.

  Parameters:
    sentry - The resource space entry.
    repository - The file used to store children.

acquireChildren

     public void acquireChildren(SpaceEntry sentry)

  Acquire the StoreEntry of the space entry.

  Parameters:
    sentry - The resource space entry.

enumerateResourceIdentifiers

     public Enumeration enumerateResourceIdentifiers(SpaceEntry sentry)

  Enumerate the name (ie identifiers) of the space entry children.

  Parameters:
    sentry - The space entry.
    all - Should all resources be listed.
  Returns:
    An enumeration, providing one element per child, which is the name of the child, as a String.

    All Packages  Class Hierarchy  This Package  Previous  Next  Index