Changeset 6036


Ignore:
Timestamp:
2003-11-28T17:45:01+13:00 (20 years ago)
Author:
jmt12
Message:

Removed the dummy code, and the GDMLoader, as legacy stuff is now handled in its own class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/msm/GDMManager.java

    r5997 r6036  
    5050import org.greenstone.gatherer.msm.MSMListener;
    5151import org.greenstone.gatherer.util.HashMap3D;
     52import org.greenstone.gatherer.util.StaticStrings;
    5253import org.greenstone.gatherer.util.Utility;
    5354import org.w3c.dom.*;
     
    6465    private TreeNode root = null;
    6566    /** The threaded object responsible for loading all of the existing metadata.xml files prior to any save action. This is necessary so that hierarchy indexes within the metadata.xml files stay fresh. */
    66     private GDMLoader gdm_loader = null;
     67    //private GDMLoader gdm_loader = null;
    6768    /** The maximum number of GDMDocuments to load at any one time */
    6869    static final private int MAX_DOCUMENTS = 25;
    69     static final private String METADATA_XML = "metadata.xml";
    7070    /** Constructor. */
    7171    public GDMManager() {
    72     this(false);
    73     }
    74 
    75     public GDMManager(boolean dummy_load) {
    7672    super();
    7773    this.metadata_cache = new HashMap3D(Gatherer.c_man.getCollection().msm.getSize());
    7874    // Connect
    7975    Gatherer.c_man.getCollection().msm.addMSMListener(this);
    80     // Now create and start the synchronous GDM loader.
    81     gdm_loader = new GDMLoader(dummy_load);
    82     gdm_loader.start();
    83     ///atherer.println("New GDMManager created.");
    8476    }
    8577
     
    136128    File metadata_file = null;
    137129    if(file.isFile()) {
    138         metadata_file = new File(file.getParentFile(), METADATA_XML);
     130        metadata_file = new File(file.getParentFile(), StaticStrings.METADATA_XML);
    139131    }
    140132    else {
    141         metadata_file = new File(file, METADATA_XML);
     133        metadata_file = new File(file, StaticStrings.METADATA_XML);
    142134    }
    143135    // Then try to retrieve it from cache. First we consider the case of a cache hit.
     
    163155    }
    164156
     157    /*
    165158    // returns metadata file from cache or creates a new one
    166159    public GDMDocument getDummyDocument(File file) {
     
    170163    File metadata_file = null;
    171164    if(file.isFile()) {
    172         metadata_file = new File(file.getParentFile(), METADATA_XML);
     165        metadata_file = new File(file.getParentFile(), StaticStrings.METADATA_XML);
    173166    }
    174167    else {
    175         metadata_file = new File(file, METADATA_XML);
     168        metadata_file = new File(file, StaticStrings.METADATA_XML);
    176169    }
    177170    // Then try to retrieve it from cache. First we consider the case of a cache hit.
     
    185178    return metadata_xml;
    186179    }
    187 
     180    */
     181
     182    /*
    188183    public synchronized void dummyGetMetadata(File file) {
    189184    String filename = null;
     
    193188    }
    194189    GDMDocument document = getDummyDocument(file);
    195 
    196 
    197     }
     190    }
     191    */
     192
    198193    /** Recover the metadata associated with a particular file. Note that this call is synchronized, so that all of the data holders don't need to be. */
    199194    public synchronized ArrayList getMetadata(File file) {
     
    430425
    431426    public void waitUntilComplete() {
    432         if(gdm_loader != null) {
    433         gdm_loader.waitUntilComplete();
    434         }
     427    //if(gdm_loader != null) {
     428    //  gdm_loader.waitUntilComplete();
     429    //}
    435430    }
    436431
     
    446441
    447442    /** A separately threaded class to load all of the current metadata.xml files. Note that files can still be loaded on demand if they're not already in the cache. Also provides the functionality to block any other thread until the loading is complete, such as is necessary when moving values about in the value tree hierarchy. */
     443    /*
    448444    private class GDMLoader
    449445    extends Thread {
     
    504500    }
    505501    }
    506 
    507     protected boolean removeEldestEntry(Map.Entry eldest) {
     502    */
     503
     504    protected boolean removeEldestEntry(Map.Entry eldest) {
    508505        if(size() > MAX_DOCUMENTS) {
    509             // Save the oldest document before its dumped
    510             File file = (File) eldest.getKey();
    511             ///ystem.err.println("Dumping oldest Document: " + file.getAbsolutePath());
    512             GDMDocument document = (GDMDocument) eldest.getValue();
    513             save(file, document);
    514             // And then dump it
    515             return true;
    516         }
    517         else {
    518             return false;
    519         }
    520      }
     506        // Save the oldest document before its dumped
     507        File file = (File) eldest.getKey();
     508        ///ystem.err.println("Dumping oldest Document: " + file.getAbsolutePath());
     509        GDMDocument document = (GDMDocument) eldest.getValue();
     510        save(file, document);
     511        // And then dump it
     512        return true;
     513    }
     514    else {
     515        return false;
     516    }
     517    }
    521518}
Note: See TracChangeset for help on using the changeset viewer.