Changeset 2178


Ignore:
Timestamp:
2001-03-14T15:15:38+13:00 (23 years ago)
Author:
say1
Message:

implemented multiway wrapper to allow a client to connect to multiple servers seamlessly

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

Legend:

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

    r2148 r2178  
    111111   */
    112112  protected SimpleClient() {
    113     nzdl = NzdlIORs.findIOR(null, URLFromCommandLine,
    114                 IORFileName, IORFromCommandLine);
     113    nzdl = NzdlIORs.createNzdlService(null,
     114                      System.getProperties(),
     115                      URLFromCommandLine,
     116                      IORFileName,
     117                      IORFromCommandLine);
    115118    if (nzdl == null)
    116119      throw new Error("URK! unable to find an IOR...");
     
    123126  SimpleClient(String [] args) {
    124127    parseArgs(args);
    125     nzdl = NzdlIORs.findIOR(args, URLFromCommandLine,
    126                 IORFileName, IORFromCommandLine);
     128    nzdl = NzdlIORs.createNzdlService(args,
     129                      System.getProperties(),
     130                      URLFromCommandLine,
     131                      IORFileName,
     132                      IORFromCommandLine);
    127133    if (nzdl == null)
    128134      throw new Error("URK! unable to find an IOR...");
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SimpleGraphicalClient.java

    r2159 r2178  
    9595   */
    9696    void init(String [] args)  {
    97     nzdl = NzdlIORs.findIOR(null, null,
    98                 IORFileName, IORFromCommandLine);
     97    nzdl = NzdlIORs.createNzdlService(args,
     98                      System.getProperties(),
     99                      null,
     100                      IORFileName,
     101                      IORFromCommandLine);
    99102    if (nzdl == null)
    100103        throw new Error("URK! unable to find an IOR...");
  • trunk/java-client/org/nzdl/gsdl/service/Makefile

    r2157 r2178  
    2525          NzdlLogWrapper.class \
    2626          NzdlDocSaveWrapper.class \
     27          NzdlMultiWayWrapper.class \
    2728          NzdlCacheWrapper.class
    2829
  • trunk/java-client/org/nzdl/gsdl/service/NzdlCollectionInfo.java

    r2163 r2178  
    6969   */
    7070  public String getHTTPPrefix() {
    71     return NzdlCorbaFactory.toString( m_Info.httpprefix) ;
     71    //return m_Info.httpprefix.text.toString();
     72     return NzdlCorbaFactory.toString( m_Info.httpprefix ) ;
    7273  }
    7374
     
    7677   */
    7778  public String getHTTPDomain() {
    78     return NzdlCorbaFactory.toString( m_Info.httpdomain) ;
     79    return NzdlCorbaFactory.toString( m_Info.httpdomain ) ;
     80  }
     81
     82  /**
     83   * Returns reseptionist
     84   */
     85  public String getReceptionist() {
     86    return NzdlCorbaFactory.toString( m_Info.receptionist ) ;
    7987  }
    8088
  • trunk/java-client/org/nzdl/gsdl/service/NzdlWrapper.java

    r2157 r2178  
    5151   */
    5252  public NzdlWrapper(NzdlService service) {
    53     if (service == null)
    54       throw new Error("null service");
    5553    this.service = service;
    5654  }
  • trunk/java-client/org/nzdl/gsdl/util/NzdlCorbaFactory.java

    r2163 r2178  
    5959    return text.toString();
    6060  }
     61
    6162
    6263  public static corbaComErrorHolder createComErrorHolder() {
  • trunk/java-client/org/nzdl/gsdl/util/NzdlIORs.java

    r2163 r2178  
    4444import java.util.Set;
    4545import java.util.Vector;
     46import java.util.Hashtable;
    4647
    4748// local libraries
     
    5657import org.nzdl.gsdl.service.NzdlLogWrapper;
    5758import org.nzdl.gsdl.service.NzdlDocSaveWrapper;
     59import org.nzdl.gsdl.service.NzdlMultiWayWrapper;
    5860
    5961/**
     
    108110  /** Are we saving documents ? */
    109111  static public boolean saveDocs = true;
     112  /** Are we trying for multiple servers ? */
     113  static public boolean doMultiple = true;
    110114
    111115  /**
     
    194198   */
    195199  public static NzdlService findIOR(String [] _args,
     200                    Properties _props,
    196201                    String _URL,
    197202                    String _filename,
     
    235240    }
    236241    return client;
     242  }
     243
     244  /**
     245   * Connect for as many servers as possible
     246   * @param _args the command line arguments
     247   * @param _URL a URL to look for an IOR in
     248   * @param _filename a local filename to look for an IOR in
     249   * @param _IOR a string to look for an IOR in
     250   * @see org.omg.CORBA.ORB
     251   */
     252  public static Hashtable findIORs(String [] _args,
     253                   Properties _props,
     254                   String _URL,
     255                   String _filename,
     256                   String _IOR)  {
     257    // the object we're filling ...
     258    Hashtable result = new Hashtable();
     259
     260    // read our prevously seed IORs ...
     261    String IOR = null;
     262    NzdlService client = null;
     263     
     264    // try a URL from the command line
     265    if ( _URL != null) {
     266      IOR = NzdlIORs.getIORfromURL(_URL);
     267      client = attemptToInitialise(_args, null, IOR);
     268      if (client != null)
     269    result.put(IOR,client);
     270    }
     271   
     272    // try an IOR from the command line
     273    if (_IOR != null) {
     274      IOR = NzdlIORs.registerIOR(_IOR);
     275      client = attemptToInitialise(_args, null, IOR);
     276      if (client != null)
     277    result.put(IOR,client);
     278    }
     279   
     280    // try an IOR from a file (the filename may have been
     281    // given from the commandline
     282   
     283    IOR = NzdlIORs.getIORfromFile(_filename);
     284    client = attemptToInitialise(_args, null, IOR);
     285    if (client != null)
     286      result.put(IOR,client);
     287
     288   
     289    // try the compiled-in URLs
     290    for (int i=0;( i<urlsCompiledIn.length && client == null );i++) {
     291      IOR = NzdlIORs.getIORfromURL(urlsCompiledIn[i]);
     292      client = attemptToInitialise(_args, null,IOR);
     293      if (client != null)
     294    result.put(IOR,client);
     295    }
     296   
     297    // the knownIORs is the last resort
     298    IOR = NzdlIORs.getFirstValid();
     299    client = attemptToInitialise(_args, null, IOR);
     300    if (client != null)
     301      result.put(IOR,client);
     302   
     303    return result;   
    237304  }
    238305
     
    328395    String ior = null;
    329396    if (file == null || file.equals(""))
    330       return "";
     397      file = IORFileName;
    331398    file = file.trim();
    332399    try  {
     
    395462      return null;
    396463    }
     464    return nzdl;
     465  }
     466 
     467  static public NzdlService createNzdlService(String [] _args,
     468                          Properties _props,
     469                          String _URL,
     470                          String _filename,
     471                          String _IOR) {
     472    if (_props == null)
     473      _props = System.getProperties();
     474
     475    NzdlService nzdl = null;
     476   
     477    if (doMultiple)
     478      nzdl = new NzdlMultiWayWrapper(_args,_props,_URL,_filename,_IOR);
     479    else
     480      nzdl = findIOR(_args,_props,_URL,_filename,_IOR);
     481   
    397482    if (saveDocs)
    398483      nzdl = new NzdlDocSaveWrapper(nzdl);
    399 
     484   
    400485    if (logAfter)
    401486      nzdl = new NzdlLogWrapper(nzdl, "log.file.after.cache", "AFTER: ");
    402 
     487   
    403488    if (caching)
    404489      nzdl = new NzdlCacheWrapper(nzdl);
     
    406491    if (logBefore)
    407492      nzdl = new NzdlLogWrapper(nzdl, "log.file.before.cache", "BEFORE: ");
     493   
    408494    return nzdl;
    409495  }
    410  
     496   
    411497  /**
    412498   * Write the System properties to a file called "System.properties" in
Note: See TracChangeset for help on using the changeset viewer.