Changeset 2270 for trunk/java-client


Ignore:
Timestamp:
2001-04-03T17:08:23+12:00 (23 years ago)
Author:
say1
Message:

comments in NzdlPreferences. Moved some constants from SimpleGraphicalClient/Constants to util/NzdlConstants so everyone could play with them. Made NzdlMultiWayWrapper dynamically load-balancing, with a rebalance on every getCollectionSet

Location:
trunk/java-client
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/java-client/ChangeLog

    r2264 r2270  
     12001-04-03 15:45  say1
     2
     3    * org/nzdl/gsdl/: Makefile, Proxy.java, SimpleServer.java,
     4    service/NzdlMultiWayWrapper.java, util/NzdlServiceFactory.java:
     5    renamed SimpleServer.java Proxy.java. Fixed bug in
     6    NzdlServiceFactory.java. Fixed NzdlMultiWayWrapper.java so i only
     7    found a single instance of each collection
     8
     92001-04-03 13:08  daven
     10
     11    * org/nzdl/gsdl/SimpleGraphicalClient/ChangeLogDialog.java: tidied
     12    up ChangeLogDialog  appearance
     13
     142001-04-03 12:54  say1
     15
     16    * ChangeLog,
     17    org/nzdl/gsdl/SimpleGraphicalClient/ChangeLogDialog.java: added the
     18    ChangeLogDialog.java file
     19
    1202001-04-03 02:31  say1
    221
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Constants.java

    r2260 r2270  
    5151
    5252
    53     /* Preference Strings */
    54 
    55     String DISPLAY_FIRST_DOC = "Automatically display the first document";
    56     String RAW_TEXT = "Always display raw text (don't interpret HTML)";
    57     String MULTIPLE_SERVERS =  "Connect to multiple servers";
    58     String LOG_SERVICE = "Log at the NzdlService level";
    59     String CACHE_CORBA = "Cache corba requests";
    60     String SAVE_DOCS = "Save documents";
    6153
    6254    /* Cursors */
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/PreferencesDialog.java

    r2222 r2270  
    3737package org.nzdl.gsdl.SimpleGraphicalClient;
    3838
     39import org.nzdl.gsdl.util.NzdlConstants;
    3940import org.nzdl.gsdl.util.NzdlPreferences;
    4041import javax.swing.*;
     
    7778
    7879    showFirstDocCheckBox =
    79       new JCheckBox( Constants.DISPLAY_FIRST_DOC, NzdlPreferences.getBoolean( Constants.DISPLAY_FIRST_DOC));
     80      new JCheckBox( NzdlConstants.DISPLAY_FIRST_DOC, NzdlPreferences.getBoolean( NzdlConstants.DISPLAY_FIRST_DOC));
    8081    showFirstDocCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
    8182
    8283    showAsTextCheckBox =
    83       new JCheckBox( Constants.RAW_TEXT, NzdlPreferences.getBoolean(Constants.RAW_TEXT));
     84      new JCheckBox( NzdlConstants.RAW_TEXT, NzdlPreferences.getBoolean(NzdlConstants.RAW_TEXT));
    8485    showAsTextCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
    8586
    8687    connectToMultipleCheckBox =
    87       new JCheckBox(Constants.MULTIPLE_SERVERS, NzdlPreferences.getBoolean(Constants.MULTIPLE_SERVERS));
     88      new JCheckBox(NzdlConstants.MULTIPLE_SERVERS, NzdlPreferences.getBoolean(NzdlConstants.MULTIPLE_SERVERS));
    8889    connectToMultipleCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
    8990
    9091    logNetworkLevelCheckBox =
    91       new JCheckBox(Constants.LOG_SERVICE, NzdlPreferences.getBoolean(Constants.LOG_SERVICE));
     92      new JCheckBox(NzdlConstants.LOG_SERVICE, NzdlPreferences.getBoolean(NzdlConstants.LOG_SERVICE));
    9293    logNetworkLevelCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
    9394
    9495    useCacheCheckBox =
    95       new JCheckBox(Constants.CACHE_CORBA, NzdlPreferences.getBoolean(Constants.CACHE_CORBA));
     96      new JCheckBox(NzdlConstants.CACHE_CORBA, NzdlPreferences.getBoolean(NzdlConstants.CACHE_CORBA));
    9697    useCacheCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
    9798
    9899    saveDocsCheckBox =
    99       new JCheckBox(Constants.SAVE_DOCS, NzdlPreferences.getBoolean(Constants.SAVE_DOCS));
     100      new JCheckBox(NzdlConstants.SAVE_DOCS, NzdlPreferences.getBoolean(NzdlConstants.SAVE_DOCS));
    100101    saveDocsCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
    101102
     
    140141        //System.err.println("ok button pressed!");
    141142
    142         boolean oldRawText =  NzdlPreferences.getBoolean(Constants.RAW_TEXT);
     143        boolean oldRawText =  NzdlPreferences.getBoolean(NzdlConstants.RAW_TEXT);
    143144
    144         NzdlPreferences.setBoolean(Constants.DISPLAY_FIRST_DOC,showFirstDocCheckBox.isSelected());
    145         NzdlPreferences.setBoolean(Constants.RAW_TEXT, showAsTextCheckBox.isSelected());
    146         NzdlPreferences.setBoolean(Constants.MULTIPLE_SERVERS, connectToMultipleCheckBox.isSelected());
    147         NzdlPreferences.setBoolean(Constants.LOG_SERVICE,logNetworkLevelCheckBox.isSelected());
    148         NzdlPreferences.setBoolean(Constants.CACHE_CORBA, useCacheCheckBox.isSelected());
    149         NzdlPreferences.setBoolean(Constants.SAVE_DOCS, saveDocsCheckBox.isSelected());
     145        NzdlPreferences.setBoolean(NzdlConstants.DISPLAY_FIRST_DOC,showFirstDocCheckBox.isSelected());
     146        NzdlPreferences.setBoolean(NzdlConstants.RAW_TEXT, showAsTextCheckBox.isSelected());
     147        NzdlPreferences.setBoolean(NzdlConstants.MULTIPLE_SERVERS, connectToMultipleCheckBox.isSelected());
     148        NzdlPreferences.setBoolean(NzdlConstants.LOG_SERVICE,logNetworkLevelCheckBox.isSelected());
     149        NzdlPreferences.setBoolean(NzdlConstants.CACHE_CORBA, useCacheCheckBox.isSelected());
     150        NzdlPreferences.setBoolean(NzdlConstants.SAVE_DOCS, saveDocsCheckBox.isSelected());
    150151      NzdlPreferences.getInstance().save();
    151152
    152153      // update the current display if raw text option has changed ?
    153154
    154       boolean newRawText = NzdlPreferences.getBoolean(Constants.RAW_TEXT);
     155      boolean newRawText = NzdlPreferences.getBoolean(NzdlConstants.RAW_TEXT);
    155156     
    156157      if (oldRawText != newRawText) {
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java

    r2256 r2270  
    289289      csModel.addResult(new Result((String)titleMap.get(resultDocID), resultDocID, collectionName ));
    290290    } //end while
    291     if (NzdlPreferences.getInstance().getBoolean(Constants.DISPLAY_FIRST_DOC))
     291    if (NzdlPreferences.getInstance().getBoolean(NzdlConstants.DISPLAY_FIRST_DOC))
    292292    resultsList.setSelectedIndex(0);
    293293      } // end else
     
    337337      StringReader sr = new StringReader(nzdl.getDocument(result.getCollectionName(),  result.getDocID()));
    338338
    339       if (NzdlPreferences.getInstance().getBoolean(Constants.RAW_TEXT))
     339      if (NzdlPreferences.getInstance().getBoolean(NzdlConstants.RAW_TEXT))
    340340          // display the document as raw text
    341341          displayAsRawText(sr);
  • trunk/java-client/org/nzdl/gsdl/service/NzdlMultiWayWrapper.java

    r2269 r2270  
    3838
    3939/**
    40  *  A NzdlMultiWayWrapper multiple NzdlServices
     40 * A NzdlMultiWayWrapper is a wrapper around multiple NzdlServices.
     41 * It attempts to connect to as many servers as possible and present
     42 * them to the user a single collection.
     43 *
     44 * When two collections are found to be the same, then only the
     45 * collection with the fastest response time for a getCollectionInfo()
     46 * call is added.
    4147 *
    4248 * @author Brett Sheeran ([email protected]) (comments)
    4349 * @author Stuart Yeates  ([email protected])
     50 * @see org.nzdl.gsdl.service.NzdlCollectionInfo
    4451 * @version $Revision$
    4552 */
     
    6673    super(null);
    6774    services = new Hashtable();
    68    
     75
     76    NzdlPreferences.saving = false;
     77
    6978    Hashtable servers = NzdlServiceFactory.findIORs(_args,_props,_URL,_filename,_IOR);
    7079   
     
    135144       
    136145        NzdlService oldServer = (NzdlService) services.get( "" + j );
     146        Date startOld = new Date();
    137147        NzdlCollectionInfo oldColl = oldServer.getCollectionInfo(coll);
     148        Date endOld = new Date();
     149        Date startNew = new Date();
    138150        NzdlCollectionInfo newColl = server.getCollectionInfo(coll);
     151        Date endNew = new Date();
    139152       
    140153        if (oldColl.getBuildDate() == newColl.getBuildDate() &&
     
    143156        oldColl.getNumOfBytes() == newColl.getNumOfBytes() &&
    144157        oldColl.isPublic() == newColl.isPublic() )
    145           hit = true;
     158          {
     159        if ((endOld.getTime() - startOld.getTime()) >
     160            (endNew.getTime() - startNew.getTime()))
     161          {
     162            results.remove(oldcollname);
     163            results.add(collname);
     164          }
     165          }
     166        hit = true;
    146167      }
    147168    }
  • trunk/java-client/org/nzdl/gsdl/util/NzdlConstants.java

    r2259 r2270  
    4242  int    DEFAULT_MAX_DOCS      = 200;
    4343
     44  /* Preference Strings */
     45 
     46  String DISPLAY_FIRST_DOC = "Automatically display the first document";
     47  String RAW_TEXT = "Always display raw text (don't interpret HTML)";
     48  String MULTIPLE_SERVERS =  "Connect to multiple servers";
     49  String LOG_SERVICE = "Log at the NzdlService level";
     50  String CACHE_CORBA = "Cache corba requests";
     51  String SAVE_DOCS = "Save documents";
     52 
    4453/* these appear to have been generated by
    4554the idlj compiler but not any more - so
  • trunk/java-client/org/nzdl/gsdl/util/NzdlPreferences.java

    r2217 r2270  
    3737  /** The hashtable we write to disk ... */
    3838  protected Properties _preferences = null;
     39  /**
     40   * Should we save the preferences? Should normally be true for
     41   * GUI work and false for commandline and/or server work.
     42   */
     43  public static boolean saving = true;
     44  /** The singleton instance */
    3945  static NzdlPreferences instance = null;
    4046  static String preferencesFileName = "preferences";
     
    5056    }
    5157  }
     58
    5259  public void save() {
     60    if (!saving)
     61      return;
    5362    try {
    5463      File file = new File(preferencesFileName);
Note: See TracChangeset for help on using the changeset viewer.