51 return getUsingURL((String)urlInfo, env); 52 } else if (urlInfo instanceof String[]) { 53 return getUsingURLs((String[])urlInfo, env); 54 } else { 55 throw (new IllegalArgumentException( 56 "iiopURLContextFactory.getObjectInstance: " + 57 "argument must be a URL String or array of URLs")); 58 } 59 } 60 61 /** 62 * Resolves 'name' into a target context with remaining name. 63 * It only resolves the hostname/port number. The remaining name 64 * contains the rest of the name found in the URL. 65 * 66 * For example, with a iiop URL "iiop://localhost:900/rest/of/name", 67 * this method resolves "iiop://localhost:900/" to the "NameService" 68 * context on for the ORB at 'localhost' on port 900, 69 * and returns as the remaining name "rest/of/name". 70 */ 71 static ResolveResult getUsingURLIgnoreRest(String url, Hashtable env) 72 throws NamingException { 73 return CNCtx.createUsingURL(url, env); 74 } 75 76 private static Object getUsingURL(String url, Hashtable env) 77 throws NamingException { 78 ResolveResult res = getUsingURLIgnoreRest(url, env); 79 80 Context ctx = (Context)res.getResolvedObj(); 81 try { 82 return ctx.lookup(res.getRemainingName()); 83 } finally { 84 ctx.close(); 85 } 86 } 87 88 private static Object getUsingURLs(String[] urls, Hashtable env) { 89 for (int i = 0; i < urls.length; i++) { 90 String url = urls[i]; 91 try { 92 Object obj = getUsingURL(url, env); 93 if (obj != null) { 94 return obj; 95 } 96 } catch (NamingException e) { 97 } 98 } 99 return null; // %%% exception?? 100 } 101 } | 51 return getUsingURL((String)urlInfo, env); 52 } else if (urlInfo instanceof String[]) { 53 return getUsingURLs((String[])urlInfo, env); 54 } else { 55 throw (new IllegalArgumentException( 56 "iiopURLContextFactory.getObjectInstance: " + 57 "argument must be a URL String or array of URLs")); 58 } 59 } 60 61 /** 62 * Resolves 'name' into a target context with remaining name. 63 * It only resolves the hostname/port number. The remaining name 64 * contains the rest of the name found in the URL. 65 * 66 * For example, with a iiop URL "iiop://localhost:900/rest/of/name", 67 * this method resolves "iiop://localhost:900/" to the "NameService" 68 * context on for the ORB at 'localhost' on port 900, 69 * and returns as the remaining name "rest/of/name". 70 */ 71 static ResolveResult getUsingURLIgnoreRest(String url, Hashtable<?,?> env) 72 throws NamingException { 73 return CNCtx.createUsingURL(url, env); 74 } 75 76 private static Object getUsingURL(String url, Hashtable<?,?> env) 77 throws NamingException { 78 ResolveResult res = getUsingURLIgnoreRest(url, env); 79 80 Context ctx = (Context)res.getResolvedObj(); 81 try { 82 return ctx.lookup(res.getRemainingName()); 83 } finally { 84 ctx.close(); 85 } 86 } 87 88 private static Object getUsingURLs(String[] urls, Hashtable<?,?> env) { 89 for (int i = 0; i < urls.length; i++) { 90 String url = urls[i]; 91 try { 92 Object obj = getUsingURL(url, env); 93 if (obj != null) { 94 return obj; 95 } 96 } catch (NamingException e) { 97 } 98 } 99 return null; // %%% exception?? 100 } 101 } |