//==============================================================================
// StorageManager.java
//==============================================================================
package sample.resource;
/**
* Responsibilities:
* - loads and registers the configured resources,
* - stores the registered resources prior to shutdown.
*
*
* @author Copyright 2003 Nikolas S. Boyd.
*/
public class StorageManager {
/**
* Loads and registers the configured resources using the (registrar).
* @param registrar maintains the resource registry.
*/
protected void
loadResources(Registry.Registrar registrar) {
// resources must actually be loaded from backing store, e.g., XML
Resource[] resources = {};
int count = resources.length;
for (int i = 0; i < count; i++) {
registrar.register(resources[i]);
}
}
/**
* Saves the registered resources from the (registry).
* @param registry contains the registered resources.
*/
protected void
storeResources(Registry registry) {
String[] resourceNames = registry.getResourceNames();
int count = resourceNames.length;
for (int i = 0; i < count; i++) {
String resourceName = resourceNames[i];
Resource resource = registry.getResourceNamed(resourceName);
// ... save the resource in the backing store ...
}
}
} // StorageManager