Changeset 2140


Ignore:
Timestamp:
2001-03-09T11:30:02+13:00 (21 years ago)
Author:
say1
Message:

moved init stuff to NzdlIORs. comments

Location:
trunk/java-client
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/java-client/TODO

    r2124 r2140  
    11Here are a list of things left to do in the Java client:
    22
    3 1) Complete and test Java Server
    4 2) Merge in Davids interface to the Standford code
    5 3) Merge in Georges filter code
    6 4) Get IOR propogation working (getior)
    7 5) Some GUI's ...
    8 6) Work out why Collection name doesn't work.
    9 7) Get the p2p stuff going
    10 8) change make to $(MAKE) in the makefiles
    11 9) comments...
    12 10) ...
     31) Merge in Davids interface to the Standford code
     42) Some GUI's ...
     53) Work out why Collection name doesn't work.
     64) Get the p2p stuff going
     75) comments...
     86) ...
    139
    14 a) sort out the configure flags in mico so we only get what we need in the ORB
     10a) find out what causes the "specified name does not exist" error
     11     message and how to fix it.
    1512b) ...
  • trunk/java-client/org/nzdl/gsdl/SimpleClient.java

    r2135 r2140  
    106106  int verbosity = 2;
    107107
    108   String[] urlsCompiledIn =
    109   {
    110     "http://nikau.cs.waikato.ac.nz/~say1/gsdl/cgi-bin/getior",
    111     "http://www.nzdl.org/cgi-bin/getior"
    112   };
    113 
    114108  /**
    115109   * Basic no-args constructor. Not recommended for normal use,
     
    117111   */
    118112  protected SimpleClient() {
    119     init(null);
     113    nzdl = NzdlIORs.findIOR(null, URLFromCommandLine,
     114                IORFileName, IORFromCommandLine);
     115    if (nzdl == null)
     116      throw new Error("URK! unable to find an IOR...");
    120117  }
    121118 
     
    126123  SimpleClient(String [] args) {
    127124    parseArgs(args);
    128     init(args);
    129   }
    130 
    131   /**
    132    *
    133    */
    134   protected void init(String [] args)  {
    135    
    136     // read our prevously seed IORs ...
    137     String IOR = null;
    138    
    139     // try a URL from the command line
    140     if (URLFromCommandLine != null) {
    141       IOR = NzdlIORs.getIORfromURL(URLFromCommandLine);
    142       attemptToInitialise(args, null, IOR);
    143     }
    144    
    145     // try an IOR from the command line
    146     if (IORFromCommandLine != null && nzdl == null) {
    147       IOR = NzdlIORs. registerIOR(IORFromCommandLine);
    148       attemptToInitialise(args, null, IOR);
    149     }
    150    
    151     // try an IOR from a file (the filename may have been
    152     // given from teh commandline
    153     if (nzdl == null) {
    154       IOR = NzdlIORs.getIORfromFile(IORFileName);
    155       attemptToInitialise(args, null, IOR);
    156     }
    157    
    158     // try the compiled-in URLs
    159     if (nzdl == null) {
    160       for (int i=0;( i<urlsCompiledIn.length && nzdl == null );i++) {
    161     IOR = NzdlIORs.getIORfromURL(urlsCompiledIn[i]);
    162     attemptToInitialise(args, null,IOR);
    163       }
    164     }
    165    
    166     // the knownIORs is the last resort
    167     if (nzdl == null) {
    168       IOR = NzdlIORs.getFirstValid();
    169       attemptToInitialise(args, null, IOR);
    170     }
    171   }
     125    nzdl = NzdlIORs.findIOR(args, URLFromCommandLine,
     126                IORFileName, IORFromCommandLine);
     127    if (nzdl == null)
     128      throw new Error("URK! unable to find an IOR...");
     129  }
     130
    172131
    173132  private boolean attemptToInitialise(String [] _args,
  • trunk/java-client/org/nzdl/gsdl/util/NzdlIORs.java

    r2136 r2140  
    9191  public static String IORFileName = "/tmp/localcorba.objid";
    9292
    93 
    94   /**
    95    *
     93  /** default places wit look for IORs ... */
     94  static String[] urlsCompiledIn =
     95  {
     96    "http://nikau.cs.waikato.ac.nz/~say1/gsdl/cgi-bin/getior",
     97    "http://www.nzdl.org/cgi-bin/getior"
     98  };
     99
     100
     101
     102  /**
     103   * Get the first known-good IOR
     104   * @see java.lang.String
     105   * @return the string containing the IOR
    96106   */
    97107  public static String getFirstValid()  {
     
    102112      while (e.hasMoreElements()) {
    103113    String IOR = (String) e.nextElement();
    104     if (attemptToInitialise(null, null, IOR)) {
     114    if (attemptToInitialise(null, null, IOR) != null) {
    105115      return IOR;
    106116    }
     
    111121
    112122  /**
    113    *
     123   * Check that the class has been correctly initialised
    114124   */
    115125  static protected void checkLoaded()  {
     
    149159
    150160  /**
    151    *
     161   * Save the IORs back to the underlying file
     162   * @see java.io.File
    152163   */
    153164  static protected void checkSave()  {
     
    165176    }
    166177  }
    167 
    168   /**
    169    *
    170    */
    171   public static void validate()  {
     178  /**
     179   * Find a valid IOR to initialise from.
     180   * @param _args the command line arguments
     181   * @param _URL a URL to look for an IOR in
     182   * @param _filename a local filename to look for an IOR in
     183   * @param _IOR a string to look for an IOR in
     184   * @see org.omg.CORBA.ORB
     185   */
     186  public static NzdlServiceClient findIOR(String [] _args,
     187                      String _URL,
     188                      String _filename,
     189                      String _IOR)  {
     190   
     191    // read our prevously seed IORs ...
     192    String IOR = null;
     193    NzdlServiceClient client = null;
     194     
     195    // try a URL from the command line
     196    if ( _URL != null) {
     197      IOR = NzdlIORs.getIORfromURL(_URL);
     198      client = attemptToInitialise(_args, null, IOR);
     199    }
     200   
     201    // try an IOR from the command line
     202    if (_IOR != null && client == null) {
     203      IOR = NzdlIORs.registerIOR(_IOR);
     204      client = attemptToInitialise(_args, null, IOR);
     205    }
     206   
     207    // try an IOR from a file (the filename may have been
     208    // given from teh commandline
     209    if (client == null) {
     210      IOR = NzdlIORs.getIORfromFile(_filename);
     211      client = attemptToInitialise(_args, null, IOR);
     212    }
     213   
     214    // try the compiled-in URLs
     215    if (client == null) {
     216      for (int i=0;( i<urlsCompiledIn.length && client == null );i++) {
     217    IOR = NzdlIORs.getIORfromURL(urlsCompiledIn[i]);
     218    client = attemptToInitialise(_args, null,IOR);
     219      }
     220    }
     221   
     222    // the knownIORs is the last resort
     223    if (client == null) {
     224      IOR = NzdlIORs.getFirstValid();
     225      client = attemptToInitialise(_args, null, IOR);
     226    }
     227    return client;
     228  }
     229
     230  /**
     231   * Connect to each of the ORB's described by the IORs and throw away
     232   * any that can't be connected to.
     233   * @see org.omg.CORBA.ORB
     234   */
     235 public static void validate()  {
    172236    checkLoaded();
    173237    synchronized (knownIORs) {
     
    181245      while (e.hasMoreElements()) {
    182246    String IOR = (String) e.nextElement();
    183     if (attemptToInitialise(null, null, IOR)) {
     247    if (attemptToInitialise(null, null, IOR) != null) {
    184248      valid.put(IOR,"");
    185249    }
     
    197261
    198262  /**
    199    *
    200    */
    201   public static String registerIOR(String str)
     263   * Register a given IOR
     264   * @see java.lang.String
     265   * @param str the IOR
     266   * @return the str
     267   */
     268 public static String registerIOR(String str)
    202269  {
    203270    checkLoaded();   
     
    211278 
    212279  /**
    213    *
     280   * Retrieve an IOR from a URL
     281   * @see java.net.URL
     282   * @param str the url to retrieve
     283   * @return the IOR
    214284   */
    215285  public static String getIORfromURL(String str)
     
    237307  }
    238308
    239   /**
    240    * Pre:  Accept SourceOfID as either: URL or IOR string or Filename
    241    * Post: extract localcorba.objid from source of ID
     309  /**
     310   * Retrieve an IOR from a file
     311   * @see java.io.File
     312   * @param str the file to open
     313   * @return the IOR
    242314   */
    243315  public static String getIORfromFile(String file) {
    244316    checkLoaded();
    245317    String ior = null;
    246       file = file.trim();
     318    if (file == null || file.equals(""))
     319      return "";
     320    file = file.trim();
    247321    try  {
    248322      BufferedReader input
     
    259333  }   // end of getIorKey
    260334
    261   /**
    262    * Pre:  Accept SourceOfID as either: URL or IOR string or Filename
    263    * Post: extract localcorba.objid from source of ID
     335  /**
     336   * Write all IORs to a flat file (for reading from c++ etc).
     337   *
     338   * Not used for the properties files.
     339   *
     340   * @see java.util.Properties
     341   * @param file the file to write to
    264342   */
    265343  public static void  writeToFile(String file) {
     
    284362
    285363
    286 
    287   static private boolean attemptToInitialise(String [] _args,
     364  /**
     365   * Attempt to connect to the object pointed to by an IOR
     366   * @see org.omg.CORBA.ORB
     367   * @param _args the command line arguments
     368   * @param _props the system properties
     369   * @param _IOR the IOR string
     370   * @return the newly created NzdlServiceClient
     371   */
     372  static public NzdlServiceClient attemptToInitialise(String [] _args,
    288373                      Properties _props,
    289374                      String _IOR) {
    290375    checkLoaded();
     376    NzdlServiceClient nzdl = null;
    291377    try {
    292       NzdlServiceClient nzdl = new NzdlServiceClient( _args, _props, _IOR);
     378      nzdl = new NzdlServiceClient( _args, _props, _IOR);
    293379    } catch (Throwable t) {
    294380      System.err.println ("failed to initialise using:");
    295381      System.err.println (_IOR);
    296       return false;
    297     }
    298     return true;
     382      return null;
     383    }
     384    return nzdl;
    299385  }
    300386 
     387  /**
     388   * Write the System properties to a file called "System.properties" in
     389   * the current directory.
     390   */
    301391  public static final void main( String [] args ) {
    302392 
Note: See TracChangeset for help on using the changeset viewer.