Changeset 2215
- Timestamp:
- 2001-03-21T10:36:32+12:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-client/org/nzdl/gsdl/SearchAllCollections.java
r2203 r2215 54 54 import org.nzdl.gsdl.service.NzdlService; 55 55 import org.nzdl.gsdl.service.NzdlServiceClient; 56 import org.nzdl.gsdl.util.NzdlServiceFactory; 56 57 57 58 /** … … 71 72 * @see org.nzdl.gsdl.service.NzdlService 72 73 * @see org.nzdl.gsdl.service.NzdlServiceClient 74 * @see org.nzdl.gsdl.util.NzdlServiceFactory 73 75 * @see gnu.getopt.Getopt 74 76 * @see gnu.getopt.LongOpt … … 77 79 public class SearchAllCollections implements Cloneable, Serializable { 78 80 79 /** The collection of CORBA IORs we know about */80 protected Properties knownIORs = null;81 81 /** The underlying CORBA inferface */ 82 82 NzdlService nzdl = null; 83 83 84 /** The name of the properties file */85 String propertiesFileName = "knownIORs.properties";86 /** The name of the file we look for IOR's in */87 String IORFileName = "/tmp/localcorba.objid";88 84 /** Look for an IOR in the file first */ 89 85 boolean useFileFirst = false; 90 86 /** The IOR that was specified on the commandline */ 91 87 String IORFromCommandLine = null; 88 /** The URL that was specified on the commandline */ 89 String URLFromCommandLine = null; 90 /** The name of the file we look for IOR's in */ 91 static String IORFileName = "/tmp/localcorba.objid"; 92 92 93 93 /** The query to use */ … … 98 98 99 99 SearchAllCollections() { 100 init(null); 101 } 102 100 nzdl = NzdlServiceFactory.createNzdlService(null, 101 System.getProperties(), 102 URLFromCommandLine, 103 IORFileName, 104 IORFromCommandLine); 105 if (nzdl == null) 106 throw new Error("URK! unable to find an IOR..."); 107 } 108 109 110 /** 111 * Normal constructor. the args are passed into the orb 112 * initialisation code so they can extract obscure args ... 113 */ 103 114 SearchAllCollections(String [] args) { 104 parseArgs(args); 105 init(args); 106 } 107 108 void init(String [] args) { 109 110 // Load prevously seen IORs from property file 111 knownIORs = new Properties(); 112 113 File file = new File(propertiesFileName); 114 try { 115 if (file.exists()) { 116 knownIORs.load(new FileInputStream(file)); 117 } 118 } catch (IOException i) { 119 System.err.println("Error reading properties file:" + i); 120 } 121 122 // Attempt to initialise client with ORs from property file 123 Enumeration e = knownIORs.keys(); 124 while (e.hasMoreElements() && nzdl == null) { 125 String IOR = (String) e.nextElement(); 126 attemptToInitialise(args, null, IOR); 127 128 } 129 130 // Attempt to initialise client with IOR from file 131 if (nzdl == null) { 132 String IOR = getIorKey(IORFileName); 133 attemptToInitialise(args, null, IOR); 134 knownIORs.put(IOR,""); 135 } 136 137 } 138 115 // parseArgs(args); 116 nzdl = NzdlServiceFactory.createNzdlService(args, 117 System.getProperties(), 118 URLFromCommandLine, 119 IORFileName, 120 IORFromCommandLine); 121 if (nzdl == null) 122 throw new Error("Unable to find an IOR."); 123 } 124 139 125 public void finalize(){ 140 tidy(); 141 } 142 143 void tidy() { 144 try { 145 File file = new File(propertiesFileName); 146 knownIORs.store(new FileOutputStream(file),"These are CORBA IOR's that the SearchAllCollections client has seen and will check again..."); 147 } catch (IOException i) { 148 System.err.println("Error writing properties file:" + i); 149 } 126 150 127 } 151 128 … … 190 167 191 168 192 private boolean attemptToInitialise(String [] _args,193 Properties _props,194 String _IOR) {195 try {196 nzdl = new NzdlServiceClient( _args, _props, _IOR);197 } catch (Throwable t) {198 System.err.println ("Failed to initialise using:");199 System.err.println (_IOR);200 nzdl = null;201 return false;202 }203 return true;204 }205 206 207 169 static String getHelpText() { 208 170 String s = ""; … … 345 307 346 308 SearchAllCollections client = new SearchAllCollections(args); 347 348 309 client.queryAllCollections(); 349 client.tidy(); 350 310 351 311 } //main 352 312
Note:
See TracChangeset
for help on using the changeset viewer.