Index: trunk/java-client/org/nzdl/gsdl/SimpleClient.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/SimpleClient.java	(revision 2136)
+++ trunk/java-client/org/nzdl/gsdl/SimpleClient.java	(revision 2140)
@@ -106,10 +106,4 @@
   int verbosity = 2;
 
-  String[] urlsCompiledIn = 
-  { 
-    "http://nikau.cs.waikato.ac.nz/~say1/gsdl/cgi-bin/getior", 
-    "http://www.nzdl.org/cgi-bin/getior"
-  };
-
   /** 
    * Basic no-args constructor. Not recommended for normal use, 
@@ -117,5 +111,8 @@
    */ 
   protected SimpleClient() {
-    init(null);
+    nzdl = NzdlIORs.findIOR(null, URLFromCommandLine,
+			    IORFileName, IORFromCommandLine);
+    if (nzdl == null)
+      throw new Error("URK! unable to find an IOR...");
   }
   
@@ -126,48 +123,10 @@
   SimpleClient(String [] args) {
     parseArgs(args);
-    init(args);
-  }
-
-  /**
-   *
-   */
-  protected void init(String [] args)  {
-    
-    // read our prevously seed IORs ...
-    String IOR = null;
-    
-    // try a URL from the command line
-    if (URLFromCommandLine != null) {
-      IOR = NzdlIORs.getIORfromURL(URLFromCommandLine);
-      attemptToInitialise(args, null, IOR);
-    }
-    
-    // try an IOR from the command line
-    if (IORFromCommandLine != null && nzdl == null) {
-      IOR = NzdlIORs. registerIOR(IORFromCommandLine);
-      attemptToInitialise(args, null, IOR);
-    }
-    
-    // try an IOR from a file (the filename may have been 
-    // given from teh commandline
-    if (nzdl == null) {
-      IOR = NzdlIORs.getIORfromFile(IORFileName);
-      attemptToInitialise(args, null, IOR);
-    }
-    
-    // try the compiled-in URLs
-    if (nzdl == null) {
-      for (int i=0;( i<urlsCompiledIn.length && nzdl == null );i++) {
-	IOR = NzdlIORs.getIORfromURL(urlsCompiledIn[i]);
-	attemptToInitialise(args, null,IOR);
-      }
-    }
-    
-    // the knownIORs is the last resort
-    if (nzdl == null) {
-      IOR = NzdlIORs.getFirstValid();
-      attemptToInitialise(args, null, IOR);
-    }
-  }
+    nzdl = NzdlIORs.findIOR(args, URLFromCommandLine, 
+			    IORFileName, IORFromCommandLine);
+    if (nzdl == null)
+      throw new Error("URK! unable to find an IOR...");
+  }
+
 
   private boolean attemptToInitialise(String [] _args, 
Index: trunk/java-client/org/nzdl/gsdl/util/NzdlIORs.java
===================================================================
--- trunk/java-client/org/nzdl/gsdl/util/NzdlIORs.java	(revision 2136)
+++ trunk/java-client/org/nzdl/gsdl/util/NzdlIORs.java	(revision 2140)
@@ -91,7 +91,17 @@
   public static String IORFileName = "/tmp/localcorba.objid";
 
-
-  /**
-   *
+  /** default places wit look for IORs ... */
+  static String[] urlsCompiledIn = 
+  { 
+    "http://nikau.cs.waikato.ac.nz/~say1/gsdl/cgi-bin/getior", 
+    "http://www.nzdl.org/cgi-bin/getior"
+  };
+
+
+
+  /**
+   * Get the first known-good IOR
+   * @see java.lang.String
+   * @return the string containing the IOR
    */
   public static String getFirstValid()  {
@@ -102,5 +112,5 @@
       while (e.hasMoreElements()) {
 	String IOR = (String) e.nextElement();
-	if (attemptToInitialise(null, null, IOR)) {
+	if (attemptToInitialise(null, null, IOR) != null) {
 	  return IOR;
 	}
@@ -111,5 +121,5 @@
 
   /**
-   *
+   * Check that the class has been correctly initialised
    */
   static protected void checkLoaded()  {
@@ -149,5 +159,6 @@
 
   /**
-   *
+   * Save the IORs back to the underlying file
+   * @see java.io.File
    */
   static protected void checkSave()  {
@@ -165,9 +176,62 @@
     }
   }
-
-  /**
-   *
-   */
-  public static void validate()  {
+  /**
+   * Find a valid IOR to initialise from.
+   * @param _args the command line arguments
+   * @param _URL a URL to look for an IOR in
+   * @param _filename a local filename to look for an IOR in
+   * @param _IOR a string to look for an IOR in
+   * @see org.omg.CORBA.ORB
+   */
+  public static NzdlServiceClient findIOR(String [] _args,
+					  String _URL,
+					  String _filename,
+					  String _IOR)  {
+    
+    // read our prevously seed IORs ...
+    String IOR = null;
+    NzdlServiceClient client = null;
+      
+    // try a URL from the command line
+    if ( _URL != null) {
+      IOR = NzdlIORs.getIORfromURL(_URL);
+      client = attemptToInitialise(_args, null, IOR);
+    }
+    
+    // try an IOR from the command line
+    if (_IOR != null && client == null) {
+      IOR = NzdlIORs.registerIOR(_IOR);
+      client = attemptToInitialise(_args, null, IOR);
+    }
+    
+    // try an IOR from a file (the filename may have been 
+    // given from teh commandline
+    if (client == null) {
+      IOR = NzdlIORs.getIORfromFile(_filename);
+      client = attemptToInitialise(_args, null, IOR);
+    }
+    
+    // try the compiled-in URLs
+    if (client == null) {
+      for (int i=0;( i<urlsCompiledIn.length && client == null );i++) {
+	IOR = NzdlIORs.getIORfromURL(urlsCompiledIn[i]);
+	client = attemptToInitialise(_args, null,IOR);
+      }
+    }
+    
+    // the knownIORs is the last resort
+    if (client == null) {
+      IOR = NzdlIORs.getFirstValid();
+      client = attemptToInitialise(_args, null, IOR);
+    }
+    return client;
+  }
+
+  /**
+   * Connect to each of the ORB's described by the IORs and throw away
+   * any that can't be connected to.
+   * @see org.omg.CORBA.ORB
+   */
+ public static void validate()  {
     checkLoaded();
     synchronized (knownIORs) {
@@ -181,5 +245,5 @@
       while (e.hasMoreElements()) {
 	String IOR = (String) e.nextElement();
-	if (attemptToInitialise(null, null, IOR)) {
+	if (attemptToInitialise(null, null, IOR) != null) {
 	  valid.put(IOR,"");
 	}
@@ -197,7 +261,10 @@
 
   /**
-   *
-   */
-  public static String registerIOR(String str)
+   * Register a given IOR 
+   * @see java.lang.String
+   * @param str the IOR
+   * @return the str
+   */
+ public static String registerIOR(String str)
   {
     checkLoaded();    
@@ -211,5 +278,8 @@
  
   /**
-   *
+   * Retrieve an IOR from a URL
+   * @see java.net.URL
+   * @param str the url to retrieve
+   * @return the IOR
    */
   public static String getIORfromURL(String str)
@@ -237,12 +307,16 @@
   }
 
-  /** 
-   * Pre:  Accept SourceOfID as either: URL or IOR string or Filename
-   * Post: extract localcorba.objid from source of ID
+  /**
+   * Retrieve an IOR from a file
+   * @see java.io.File
+   * @param str the file to open
+   * @return the IOR
    */
   public static String getIORfromFile(String file) {
     checkLoaded();
     String ior = null;
-      file = file.trim();
+    if (file == null || file.equals(""))
+      return "";
+    file = file.trim();
     try  {
       BufferedReader input
@@ -259,7 +333,11 @@
   }   // end of getIorKey
 
-  /** 
-   * Pre:  Accept SourceOfID as either: URL or IOR string or Filename
-   * Post: extract localcorba.objid from source of ID
+  /**
+   * Write all IORs to a flat file (for reading from c++ etc).
+   *
+   * Not used for the properties files.
+   *
+   * @see java.util.Properties
+   * @param file the file to write to
    */
   public static void  writeToFile(String file) {
@@ -284,19 +362,31 @@
 
 
-
-  static private boolean attemptToInitialise(String [] _args, 
+  /**
+   * Attempt to connect to the object pointed to by an IOR
+   * @see org.omg.CORBA.ORB
+   * @param _args the command line arguments
+   * @param _props the system properties
+   * @param _IOR the IOR string
+   * @return the newly created NzdlServiceClient
+   */
+  static public NzdlServiceClient attemptToInitialise(String [] _args, 
 				      Properties _props, 
 				      String _IOR) {
     checkLoaded();
+    NzdlServiceClient nzdl = null;
     try {
-      NzdlServiceClient nzdl = new NzdlServiceClient( _args, _props, _IOR);
+      nzdl = new NzdlServiceClient( _args, _props, _IOR);
     } catch (Throwable t) {
       System.err.println ("failed to initialise using:");
       System.err.println (_IOR);
-      return false;
-    }
-    return true;
+      return null;
+    }
+    return nzdl;
   }
   
+  /**
+   * Write the System properties to a file called "System.properties" in
+   * the current directory.
+   */
   public static final void main( String [] args ) {
  
