FileDocCategorySizeDatePackage
LibraryLoader.javaAPI DocExample1713Fri Feb 21 13:11:54 GMT 2003None

LibraryLoader

public class LibraryLoader extends Object

Fields Summary
static final String
CONFIG_FILE
static final String
CACHE_FILE
Constructors Summary
Methods Summary
public LibraryLoader$ConfigDataload()


       
    // Find the config file and fetch its contents as Properties
    Resource config = new Resource(CONFIG_FILE);
    Properties props = new Properties();
    props.load(config.getInputStream());

    // Determine the source dir of the config file and look for a cache file
    // next to it containing a full representation of our program state.
    // If we find a cache file and it is current, load and return that data.
    if (config.getDirectory() != null) {
      File cache = new File(config.getDirectory(), CACHE_FILE);
      if (cache.exists() &&
            cache.lastModified() >= config.lastModified()) {
        try {
          return loadCache(new FileInputStream(cache));
        }
        catch (IOException ignored) { }
      }
    }

    // We get here if there's no cache file or it's stale and we need to do a
    // full reload.  Locate the name of the raw data file from the config file
    // and return its contents using Resource.
    Resource data = new Resource(props.getProperty("data.file"));
    return loadData(data.getInputStream());
  
private LibraryLoader$ConfigDataloadCache(java.io.InputStream in)

    // Read the file, perhaps as a serialized object
    return null;
  
private LibraryLoader$ConfigDataloadData(java.io.InputStream in)

    // Read the file, perhaps as XML
    return null;