| java.lang.Object org.w3c.tools.resources.store.ResourceStoreImpl
ResourceStoreImpl | public class ResourceStoreImpl implements ResourceStore(Code) | | A generic resource store that keeps resource in a file using
the Serializer interface.
|
Inner Class :class ResourceIndex | |
Method Summary | |
public synchronized boolean | acceptUnload() Can this resource store be unloaded now ?
This method gets called by the ResourceStoreManager before calling
the shutdown method, when possible. | public synchronized void | addResource(Resource resource) Add this resource to this resource store. | public Enumeration | enumerateResourceIdentifiers() Enumerate all the resources saved in this store. | public String | getIdentifier() Get the identifier for that store. | public int | getVersion() Get the version of that resource store.
Version numbers are used to distinguish between pickling format. | public boolean | hasResource(String identifier) Check for the existence of a resource in this store.
Parameters: identifier - The identifier of the resource to check. | public void | initialize(ResourceStoreManager manager, Object token, File repository, Serializer serializer) This resource store is being built, initialize it with the given arg. | protected synchronized void | internalSave(boolean unload) Internal save: save the repository back to disk. | public Resource | loadResource(String identifier, Hashtable defs) Restore the resource whose name is given.
This method doesn't assume that the resource will actually be restored,
it can be kept in a cache by the ResourceStore object, and the cached
version of the resource may be returned.
Parameters: identifier - The identifier of the resource to restore. Parameters: defs - Default attribute values. | protected synchronized void | loadResources() | public Resource | lookupResource(String identifier) Get this resource, but only if already loaded.
The resource store may (recommended) maintain a cache of the resource
it loads from its store. | protected void | markModified() | public void | markModified(Resource resource) Mark this resource as modified. | final protected void | markUsed() Mark the store as having been used recently. | public synchronized void | removeResource(String identifier) Remove this resource from the repository. | public synchronized void | renameResource(String oldid, String newid) Rename a given resource. | public void | save() Save this store. | public void | saveResource(Resource resource) Stabilize the given resource. | public synchronized void | shutdown() Shutdown this store. | protected void | warning(String msg) Emit the given string as a warning, to whoever it is appropriate. |
modified | boolean modified(Code) | | Has this repository been modified.
|
repository | File repository(Code) | | Our underlying associated file.
|
resources | Hashtable resources(Code) | | The resources we know about: maps identifier to resource objects.
|
token | Object token(Code) | | Our token within the resource store manager.
|
writerSize | final static int writerSize(Code) | | |
acceptUnload | public synchronized boolean acceptUnload()(Code) | | Can this resource store be unloaded now ?
This method gets called by the ResourceStoreManager before calling
the shutdown method, when possible. An implementation
of that method is responsible for checking the acceptUnload
method of all its loaded resource before returning
true, meaning that the resource store can be unloaded.
A boolean true if the resource store can beunloaded. |
addResource | public synchronized void addResource(Resource resource)(Code) | | Add this resource to this resource store.
Parameters: resource - The resource to be added. |
enumerateResourceIdentifiers | public Enumeration enumerateResourceIdentifiers()(Code) | | Enumerate all the resources saved in this store.
An enumeration of Strings, giving the identifier for all the resources that this store knows about. |
getIdentifier | public String getIdentifier()(Code) | | Get the identifier for that store.
A uniq store identifier, as a String. |
getVersion | public int getVersion()(Code) | | Get the version of that resource store.
Version numbers are used to distinguish between pickling format.
A resource store implementator has the duty of bumping the returned
number whenever it's archiving format changes.
Resource stores that relies on some external archiving mechanisms
(such as a database), may return a constant.
An integer version number. |
hasResource | public boolean hasResource(String identifier)(Code) | | Check for the existence of a resource in this store.
Parameters: identifier - The identifier of the resource to check. A boolean true if the resource existsin this store, false otherwise. |
initialize | public void initialize(ResourceStoreManager manager, Object token, File repository, Serializer serializer)(Code) | | This resource store is being built, initialize it with the given arg.
Parameters: manager - The ResourceStoreManager instance that asks yourselfto initialize. Parameters: token - The resource store manager key to that resource store, this token should be used when calling methods from the manager thatare to act on yourself. Parameters: repository - A file, giving the location of the associated repository. |
internalSave | protected synchronized void internalSave(boolean unload) throws IOException(Code) | | Internal save: save the repository back to disk.
Parameters: unload - Should we unload any existing resources ? |
loadResource | public Resource loadResource(String identifier, Hashtable defs) throws InvalidResourceException(Code) | | Restore the resource whose name is given.
This method doesn't assume that the resource will actually be restored,
it can be kept in a cache by the ResourceStore object, and the cached
version of the resource may be returned.
Parameters: identifier - The identifier of the resource to restore. Parameters: defs - Default attribute values. If the resource needs to berestored from its pickled version, this Hashtable providesa set of default values for some of the attributes. A Resource instance, or null. exception: InvalidResourceException - If the resource could notbe restored from the store. |
loadResources | protected synchronized void loadResources()(Code) | | |
lookupResource | public Resource lookupResource(String identifier)(Code) | | Get this resource, but only if already loaded.
The resource store may (recommended) maintain a cache of the resource
it loads from its store. If the resource having this identifier
has already been loaded, return it, otherwise, return
null.
Parameters: identifier - The resource identifier. A Resource instance, or null. |
markModified | protected void markModified()(Code) | | |
markModified | public void markModified(Resource resource)(Code) | | Mark this resource as modified.
Parameters: resource - The resource that has changed (and will have to bepickled some time latter). |
markUsed | final protected void markUsed()(Code) | | Mark the store as having been used recently.
|
removeResource | public synchronized void removeResource(String identifier)(Code) | | Remove this resource from the repository.
Parameters: identifier - The identifier of the resource to be removed. |
renameResource | public synchronized void renameResource(String oldid, String newid)(Code) | | Rename a given resource.
Parameters: oldid - The olde resource identifier. Parameters: newid - The new resource identifier. |
save | public void save()(Code) | | Save this store.
|
saveResource | public void saveResource(Resource resource)(Code) | | Stabilize the given resource.
Parameters: resource - The resource to save. |
shutdown | public synchronized void shutdown()(Code) | | Shutdown this store.
|
warning | protected void warning(String msg)(Code) | | Emit the given string as a warning, to whoever it is appropriate.
Parameters: msg - The warning message. |
|
|