public Context getInitialContext(Hashtable env) throws NamingException {
// InitialContextFactory implementation --------------------------
// Parse the Context.PROVIDER_URL
String provider = (String) env.get(Context.PROVIDER_URL);
if( provider.startsWith("jnp:") == true )
provider = "http:" + provider.substring(4);
else if( provider.startsWith("jnps:") == true )
provider = "https:" + provider.substring(5);
else if( provider.startsWith("jnp-http:") == true )
provider = "http:" + provider.substring(9);
else if( provider.startsWith("jnp-https:") == true )
provider = "https:" + provider.substring(10);
URL providerURL = null;
Naming namingServer = null;
try
{
providerURL = new URL(provider);
// Retrieve the Naming interface
namingServer = getNamingServer(providerURL);
}
catch(Exception e)
{
NamingException ex = new NamingException("Failed to retrieve Naming interface for provider " + provider);
ex.setRootCause(e);
throw ex;
}
// Copy the context env
env = (Hashtable) env.clone();
return new NamingContext(env, null, namingServer);
}
|