Index: /trunk/java-client/org/nzdl/gsdl/SimpleClient.java
===================================================================
--- /trunk/java-client/org/nzdl/gsdl/SimpleClient.java	(revision 2134)
+++ /trunk/java-client/org/nzdl/gsdl/SimpleClient.java	(revision 2135)
@@ -55,4 +55,5 @@
 import org.nzdl.gsdl.service.NzdlService;
 import org.nzdl.gsdl.service.NzdlServiceClient;
+import org.nzdl.gsdl.util.NzdlIORs;
 
 /**
@@ -82,12 +83,6 @@
 public class SimpleClient implements Cloneable, Serializable {
 
-  /** The collection of CORBA IORs we know about */
-  protected Properties knownIORs = null;
   /** The underlying CORBA inferface */
   NzdlService nzdl = null;
-  /** The name of the properties file */
-  String propertiesFileName = "knownIORs.properties";
-  /** The name of the file we look for IOR's in */
-  String IORFileName = "/tmp/localcorba.objid";
   /** Look for an IOR in the file first */
   boolean useFileFirst = false;
@@ -96,4 +91,6 @@
   /** The URL that was specified on the commandline */
   String URLFromCommandLine = null;
+  /** The name of the file we look for IOR's in */
+  static String IORFileName = "/tmp/localcorba.objid";
   /** The collection to query */
   String collectionNameToQuery = "";
@@ -136,12 +133,11 @@
    */
   protected void init(String [] args)  {
-
+    
     // read our prevously seed IORs ...
-    knownIORs = new Properties();
     String IOR = null;
     
     // try a URL from the command line
     if (URLFromCommandLine != null) {
-      IOR = getIORfromURL(URLFromCommandLine);
+      IOR = NzdlIORs.getIORfromURL(URLFromCommandLine);
       attemptToInitialise(args, null, IOR);
     }
@@ -149,12 +145,12 @@
     // try an IOR from the command line
     if (IORFromCommandLine != null && nzdl == null) {
-      IOR = IORFromCommandLine;
+      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 = getIorKey(IORFileName);
+      IOR = NzdlIORs.getIORfromFile(IORFileName);
       attemptToInitialise(args, null, IOR);
     }
@@ -163,100 +159,15 @@
     if (nzdl == null) {
       for (int i=0;( i<urlsCompiledIn.length && nzdl == null );i++) {
-	IOR = getIORfromURL(urlsCompiledIn[i]);
+	IOR = NzdlIORs.getIORfromURL(urlsCompiledIn[i]);
 	attemptToInitialise(args, null,IOR);
       }
     }
-
+    
     // the knownIORs is the last resort
     if (nzdl == null) {
-      File file = new File(propertiesFileName);
-      try {
-	if (file.exists()) {
-	  knownIORs.load(new FileInputStream(file));
-	} 
-      } catch (IOException i) {
-	System.err.println("Error reading properties file:" + i);
-      }
-
-      Enumeration e = knownIORs.keys();
-      while (e.hasMoreElements() && nzdl == null) {
-	IOR = (String) e.nextElement();
-	attemptToInitialise(args, null, IOR);
-      }
-    }
-    
-    knownIORs.put(IOR,"");
-  }
-  
-  public String getIORfromURL(String str)
-  {
-
-    String ior = null;
-    
-    try { 
-      System.err.println("Looking for a URL at:" + str);
-      URL url = new URL(str);
-      InputStream his = url.openStream();
-      DataInputStream dhis = new DataInputStream(his) ;
-      ior = dhis.readLine();
-      return ior;
-    } catch (Throwable throwable) {
-      System.err.println("NzdlHosts::getIOR() unable to construct or read URL \"" +
-			 str + "\", \"" + ior + "\": " + throwable);
-      return "";
-    }
-  }
-
-  public void finalize(){
-    tidy();
-  }
-
-  void tidy() {
-    try {
-      File file = new File(propertiesFileName);
-      knownIORs.store(new FileOutputStream(file),"These are CORBA IOR's that the SimpleClient has seen and will check again...");
-    } catch (IOException i) {
-      System.err.println("Error writing properties file:" + i);
-    }
-  }
-
-  /** 
-   * Pre:  Accept SourceOfID as either: URL or IOR string or Filename
-   * Post: extract localcorba.objid from source of ID
-   */
-  private String getIorKey(String sourceOfID) {
-    String ior = null;
-    try  {
-      sourceOfID = sourceOfID.trim();
-      System.err.println("Reading IOR from: " + sourceOfID);
-
-      String firstChars = sourceOfID.substring(0, Math.min(4,sourceOfID.length())).toUpperCase();
-	// if sourceOfID is a URL ---------------------------------------
-	if (sourceOfID.length() > 4 && firstChars.equalsIgnoreCase("HTTP"))	{
-	  URL myUrl = new URL(sourceOfID);
-	  BufferedReader input =new
-	    BufferedReader(new InputStreamReader(myUrl.openStream()));
-	  ior = input.readLine();
-	}
-	    
-	// if sourceOfID is an IOR --------------------------------------
-	else if (sourceOfID.length() > 4 && firstChars.equalsIgnoreCase("IOR:"))	{
-	  ior = sourceOfID;      		  	
-	}
-
-	// else assume sourceOfID is a file name ------------------------
-	else {
-	  BufferedReader input
-	    = new BufferedReader(new FileReader(sourceOfID));
-	  ior = input.readLine();      		  	
-	}
-    }  //end of try
-    catch (java.io.IOException e) {
-      System.err.println("Error reading IOR key:\n" + e);
-    }
-    return ior;
-  }   // end of getIorKey
-
-
+      IOR = NzdlIORs.getFirstValid();
+      attemptToInitialise(args, null, IOR);
+    }
+  }
 
   private boolean attemptToInitialise(String [] _args, 
@@ -509,5 +420,4 @@
     client.runQuery();
     
-    client.tidy();
   } //main
 
Index: /trunk/java-client/org/nzdl/gsdl/SimpleServer.java
===================================================================
--- /trunk/java-client/org/nzdl/gsdl/SimpleServer.java	(revision 2134)
+++ /trunk/java-client/org/nzdl/gsdl/SimpleServer.java	(revision 2135)
@@ -22,5 +22,5 @@
 
 // java standard library classes used
-import java.io.Serializable;
+import java.io.*;
 //import java.util.*;
 
@@ -39,4 +39,5 @@
 import org.nzdl.gsdl.service.NzdlServiceClient;
 import org.nzdl.gsdl.util.NzdlCorbaFactory;
+import org.nzdl.gsdl.util.NzdlIORs;
 
 
@@ -56,4 +57,7 @@
 public class SimpleServer implements Serializable, Cloneable
 {
+  static String IORFileName = "/tmp/localcorba.proxy.objid";
+
+
   /**
    * Starts up a trivial server.
@@ -63,21 +67,34 @@
   public static void main(String args[])
   {
+    corbaComErrorHolder error = NzdlCorbaFactory.createComErrorHolder();
     try{
+      SimpleClient client = new SimpleClient();
     
       ORB orb = ORB.init(args, null);
       
       // Create the servant and register it with the ORB
-      NzdlServiceServer simpleRef = new NzdlServiceServer();
+      NzdlServiceServer simpleRef = new NzdlServiceServer(client.nzdl);
+
+      simpleRef.initialise(error);
+      if (error.value.value() != corbaComError._corbaNoError) {
+	System.err.println("CORBA error after initialisation:" + error.value.value());
+      }
+      
       orb.connect(simpleRef);
+      System.err.println(orb.object_to_string(simpleRef));     
+     
+      NzdlIORs.registerIOR(orb.object_to_string(simpleRef));
+
+      try  {
+	BufferedWriter output
+	  = new BufferedWriter(new FileWriter(IORFileName));
+	output.write(orb.object_to_string(simpleRef));
+	output.flush();
+      } catch (java.io.IOException e) {
+	System.err.println("Error reading IOR file:\n" + e);
+      }
       
-      // Get the root naming context
-      org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
-      NamingContext ncRef = NamingContextHelper.narrow(objRef);
-      
-      // Bind the object reference in naming
-      NameComponent nc = new NameComponent("Hello", "");
-      NameComponent path[] = {nc};
-      ncRef.rebind(path, simpleRef);
-      
+
+
       // Wait for invocations from clients
       java.lang.Object sync = new java.lang.Object();
@@ -87,7 +104,9 @@
       
     } catch(Exception e) {
+      System.err.println("CORBA error:" + error.value.value());     
       System.err.println("ERROR: " + e);
       e.printStackTrace(System.out);
-    }  
+    } 
+    
   }
 }
Index: /trunk/java-client/org/nzdl/gsdl/util/Makefile
===================================================================
--- /trunk/java-client/org/nzdl/gsdl/util/Makefile	(revision 2134)
+++ /trunk/java-client/org/nzdl/gsdl/util/Makefile	(revision 2135)
@@ -15,5 +15,6 @@
 CLASSFILES=NzdlConstants.class  \
      NzdlCorbaFactory.class  \
-     NzdlHosts.class  
+     NzdlHosts.class  \
+     NzdlIORs.class
 
 all: $(CLASSFILES)
