package org.huihoo.jfox.jndi;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.Name;
import javax.naming.Reference;
import java.util.Hashtable;
import java.net.URL;
public class InitialContextFactoryImpl implements javax.naming.spi.InitialContextFactory,javax.naming.spi.ObjectFactory{
public Context getInitialContext(Hashtable env) throws NamingException {
if(env == null) {
env = JNDIProperties.getDefaultEnvironment();
}
else {
env = JNDIProperties.mergeEnvironment(env);
}
return new ContextImpl("/",env);
}
public Object getObjectInstance(Object obj, Name name, Context ctx, Hashtable environment) throws Exception {
Reference ref = (Reference)obj;
String url_string = (String)ref.get("URL").getContent();
URL url = new URL(url_string);
return url.getContent();
}
public static void main(String[] args) {
}
}