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

Variable Index

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

Constructor Index

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

Method Index

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

Variables

 o 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
 o root_rep
 public static final String root_rep
 o debugMemory
 public boolean debugMemory
 o closed
 protected boolean closed
Is this store shutdown ?

 o storedir
 protected File storedir
Our store directory.

 o index
 protected File index
Our index file.

 o server_name
 protected String server_name
server name;

 o root_repository
 protected File root_repository
Our root repository.

 o lru
 protected LRUList lru
The store entries least recetenly used list.

 o state
 protected ResourceStoreState state
 o sweeper
 protected StoreManagerSweeper sweeper
Our sweeper thread:

 o eventQueue
 protected ResourceEventQueue eventQueue

Constructors

 o ResourceStoreManager
 public ResourceStoreManager(String server_name,
                             File storedir,
                             String default_root_class,
                             String default_root_name,
                             int max_loaded_store,
                             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.

Methods

 o getEventQueue
 public ResourceEventQueue getEventQueue()
 o getMaxLoadedStore
 protected final int getMaxLoadedStore()
 o incrLoadedStore
 protected void incrLoadedStore()
 o decrLoadedStore
 protected void decrLoadedStore()
 o checkClosed
 protected final synchronized void checkClosed()
Check that this resource store manager isn't closed.

Throws: RuntimeException
If the store manager was closed.
 o 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.
 o collect
 public void collect()
Collect enough entries to go back into fixed limits.

 o 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.
 o getCurrentStoreIdentifier
 public int getCurrentStoreIdentifier()
 o getIndexFile
 protected File getIndexFile()
Get the index file.

Returns:
A File instance.
 o getRootRepository
 protected File getRootRepository()
Get the root repository.

Returns:
A File instance.
 o getRootKey
 protected Integer getRootKey()
Get The root key.

Returns:
A String instance
 o warning
 protected void warning(String msg)
Emit the given string as a warning, to whoever it is appropriate.

Parameters:
msg - The warning message.
 o saveEntriesIndex
 protected synchronized void saveEntriesIndex()
Save the index file.

 o loadEntriesIndex
 protected synchronized void loadEntriesIndex()
Load the index file.

 o shutdown
 public synchronized void shutdown()
Shutdown this resource store manager. Go through all entries, and shut them down.

 o checkpoint
 public void checkpoint()
Checkpoint all modified resource stores, by saving them to disk.

 o 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.
 o 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
 o 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
 o used
 protected boolean used(String rep)
 o salvage
 public void salvage()
 o displayIndex
 public void displayIndex()
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o deleteChildren
 public void deleteChildren(SpaceEntry sentry)
Delete all the children of resource indentified by its space entry.

Parameters:
sentry - The resource space entry
 o saveChildren
 public void saveChildren(SpaceEntry sentry)
Save all the children of the resource indentified by its spaec entry.

Parameters:
sentry - The resource space entry
 o checkMaxLoadedStore
 protected void checkMaxLoadedStore()
 o 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.
 o acquireChildren
 public void acquireChildren(SpaceEntry sentry)
Acquire the StoreEntry of the space entry.

Parameters:
sentry - The resource space entry.
 o 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