if (url == null)
url = (String) env.get(Context.PROVIDER_URL);
if (url != null && !url.equals("")) {
StringTokenizer tokenizer = new StringTokenizer(url, "/:,");
if (! tokenizer.hasMoreElements())
throw new NamingException("URL not valid:" + url);
String protocol = tokenizer.nextToken();
if (protocol.equals("scn")) {
host = tokenizer.nextToken();
String portStr = tokenizer.nextToken();
port = Integer.parseInt(portStr);
} else {
throw new NamingException("Unknown protocol:" + protocol);
}
} else {
host = (String) env.get(SCN_HOST_PROPERTY);
if (host == null)
host = System.getProperty(SCN_HOST_PROPERTY);
if (host == null)
host = (String) env.get(JAVA_HOST_PROPERTY);
if (host == null)
host = System.getProperty(JAVA_HOST_PROPERTY);
if (host == null)
host = "localhost";
String portStr = (String) env.get(SCN_PORT_PROPERTY);
if (portStr == null)
portStr = System.getProperty(SCN_PORT_PROPERTY);
if (portStr == null)
portStr = (String) env.get(JAVA_PORT_PROPERTY);
if (portStr == null)
portStr = System.getProperty(JAVA_PORT_PROPERTY);
if (portStr == null)
portStr = "16400";
port = Integer.parseInt(portStr);
}
SimpleNamingConnection namingConnection = new SimpleNamingConnection(host, port, env);
namingConnection.init(host, port, env);
return namingConnection;
} catch (NumberFormatException e) {
NamingException nx = new NamingException();
nx.setRootCause(e);
throw nx;
} catch (Exception e) {
NamingException nx = new NamingException();
nx.setRootCause(e);
throw nx;
}
}