Changeset 2152 for trunk/java-client


Ignore:
Timestamp:
2001-03-09T23:26:57+13:00 (23 years ago)
Author:
say1
Message:

caching NzdlService now works ...

Location:
trunk/java-client/org/nzdl/gsdl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java

    r2150 r2152  
    246246      Result result =  (Result) resultsList.getSelectedValue();
    247247      if (result.toString() == Result.FAKE_RESULT) {
    248     dataTextArea.setText(null);
     248    dataTextArea.setText("");
    249249    //System.err.println("no results");
    250250      }
  • trunk/java-client/org/nzdl/gsdl/service/NzdlResponse.java

    r2108 r2152  
    5151  public NzdlResponse( ) {
    5252    m_responseHolder = NzdlCorbaFactory.createFilterResponseHolder();
     53    m_response = m_responseHolder.value;
     54  }
     55
     56  /**
     57   * Create an empty instance of a NzdlResponse object.
     58   */
     59  public void copyData(NzdlResponse old) {
     60    m_responseHolder = old.m_responseHolder ;
     61    m_response = old.m_response;
     62    m_resultSet =  old.m_resultSet;
     63    m_frequencies = old.m_frequencies;
     64    m_queryTerms = old.m_queryTerms;
     65  }
     66
     67  /**
     68   * Get the corbaFilterReponse.
     69   */
     70  public corbaFilterResponse getResponse() {
     71    return m_response;
     72  }
     73
     74  /**
     75   * Set the corbaFilterReponse.
     76   */
     77  public void setResponse(corbaFilterResponse response) {
     78    m_response = response;
     79    m_responseHolder.value = response;
     80    parseResponse();
    5381  }
    5482
     
    128156    m_resultSet = new NzdlResultSet();
    129157    m_resultSet.setNumOfDocs( m_response.numDocs );
     158    if (m_response.isApprox == null)
     159      throw new Error ("null m_response.isApprox in parseResponse");
    130160    m_resultSet.setResultType( m_response.isApprox.value() );
    131161    /** HAS SIDE EFFECT ! */
  • trunk/java-client/org/nzdl/gsdl/service/NzdlServiceCachingClient.java

    r2151 r2152  
    2525 
    2626  public NzdlCollectionInfo getCollectionInfo( String _name ) {
     27    //System.err.println("in NzdlServiceCachingClient::getCollectionInfo()");
    2728    NzdlCollectionInfo info = null;
    2829    info = (NzdlCollectionInfo)_collectionInfo.get(_name);
     
    3132    info = super.getCollectionInfo(_name);
    3233    _collectionInfo.put(_name,info);
    33    
     34
     35    System.err.println("Cache miss (getCollectionInfo)");
    3436    return info;
    3537  }
     
    3739  public String getDocument( String _name, String _docID ) {
    3840    String doc = null;
    39     doc = (String)_collectionInfo.get(_name + _docID);
     41    String key = "" + _name + _docID;
     42    doc = (String)_docs.get(key);
    4043    if (doc != null)
    4144      return doc;
    4245    doc = super.getDocument(_name,_docID);
    43     _docs.put(_name + _docID,doc);
     46    _docs.put(key, doc);
     47   
     48    System.err.println("Cache miss (getDocument) " + _name
     49                + " " +_docID);
    4450   
    4551    return doc;
     
    4753
    4854  public void service( String _name, NzdlRequest _request, NzdlResponse _response ) {   
    49     if (_name == null || _name.equals("")){
    50       throw new Error ("null or empty _name");
     55   
     56    String key = _name + corbaFilterRequestToString(_request);
     57
     58    if (_services.get(key) != null) {
     59      _response.copyData((NzdlResponse) _services.get(key));
     60      return;
    5161    }
    52     if (_request == null || _request.equals("")){
    53       throw new Error ("null or empty _request");
    54     }
    55     if (_response == null || _response.equals("")){
    56       throw new Error ("null or empty _response");
    57     }
    58    
    59     NzdlResponse info = null;
    60     _response.getHolder().value = (corbaFilterResponse)
    61       _services.get(_name + corbaFilterRequestToString(_request));
    62 
    63     if (info != null)     
    64       return;
    6562
    6663    super.service(_name, _request,_response);
    67     _collectionInfo.put(_name +corbaFilterRequestToString(_request),
    68             _response.getHolder().value);
     64
     65    _services.put(key, _response);
     66   
     67    System.err.println("Cache miss (service)" + key);
    6968    return;
    7069  }
     
    108107    return buf.toString();
    109108  }
    110 
    111 
    112109}
    113110
  • trunk/java-client/org/nzdl/gsdl/util/NzdlIORs.java

    r2141 r2152  
    5757import org.nzdl.gsdl.service.NzdlService;
    5858import org.nzdl.gsdl.service.NzdlServiceClient;
     59import org.nzdl.gsdl.service.NzdlServiceCachingClient;
    5960
    6061/**
     
    9899  };
    99100
    100 
     101  /** Are we using a caching NzdlService ? */
     102  static public boolean nzdlServiceCachingClass = true;
    101103
    102104  /**
     
    128130    if (knownIORs != null)
    129131      return;
    130    
     132
    131133    Properties blarg = new Properties();
    132134   
     
    380382    NzdlServiceClient nzdl = null;
    381383    try {
    382       nzdl = new NzdlServiceClient( _args, _props, _IOR);
     384      if (nzdlServiceCachingClass)
     385    nzdl = new NzdlServiceCachingClient( _args, _props, _IOR);
     386      else
     387    nzdl = new NzdlServiceClient( _args, _props, _IOR);
    383388    } catch (Throwable t) {
    384389      System.err.println ("failed to initialise using:");
Note: See TracChangeset for help on using the changeset viewer.