182 * URL-formatted (without the scheme component) strings. The array contains
183 * a snapshot of the names present in the registry at the time of the
184 * call.
185 *
186 * @param name a registry name in URL format (without the scheme
187 * component)
188 * @return an array of names (in the appropriate format) bound
189 * in the registry
190 * @exception MalformedURLException if the name is not an appropriately
191 * formatted URL
192 * @exception RemoteException if registry could not be contacted.
193 * @since 1.1
194 */
195 public static String[] list(String name)
196 throws RemoteException, java.net.MalformedURLException
197 {
198 ParsedNamingURL parsed = parseURL(name);
199 Registry registry = getRegistry(parsed);
200
201 String prefix = "";
202 if (parsed.port > 0 || !parsed.host.equals(""))
203 prefix += "//" + parsed.host;
204 if (parsed.port > 0)
205 prefix += ":" + parsed.port;
206 prefix += "/";
207
208 String[] names = registry.list();
209 for (int i = 0; i < names.length; i++) {
210 names[i] = prefix + names[i];
211 }
212 return names;
213 }
214
215 /**
216 * Returns a registry reference obtained from information in the URL.
217 */
218 private static Registry getRegistry(ParsedNamingURL parsed)
219 throws RemoteException
220 {
221 return LocateRegistry.getRegistry(parsed.host, parsed.port);
222 }
|
182 * URL-formatted (without the scheme component) strings. The array contains
183 * a snapshot of the names present in the registry at the time of the
184 * call.
185 *
186 * @param name a registry name in URL format (without the scheme
187 * component)
188 * @return an array of names (in the appropriate format) bound
189 * in the registry
190 * @exception MalformedURLException if the name is not an appropriately
191 * formatted URL
192 * @exception RemoteException if registry could not be contacted.
193 * @since 1.1
194 */
195 public static String[] list(String name)
196 throws RemoteException, java.net.MalformedURLException
197 {
198 ParsedNamingURL parsed = parseURL(name);
199 Registry registry = getRegistry(parsed);
200
201 String prefix = "";
202 if (parsed.port > 0 || !parsed.host.isEmpty())
203 prefix += "//" + parsed.host;
204 if (parsed.port > 0)
205 prefix += ":" + parsed.port;
206 prefix += "/";
207
208 String[] names = registry.list();
209 for (int i = 0; i < names.length; i++) {
210 names[i] = prefix + names[i];
211 }
212 return names;
213 }
214
215 /**
216 * Returns a registry reference obtained from information in the URL.
217 */
218 private static Registry getRegistry(ParsedNamingURL parsed)
219 throws RemoteException
220 {
221 return LocateRegistry.getRegistry(parsed.host, parsed.port);
222 }
|