package org.jboss.iiop.naming;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NamingException;
import org.jnp.interfaces.NamingContextFactory;
import org.omg.CORBA.ORB;
public class ORBInitialContextFactory extends NamingContextFactory
{
public static final String ORB_INSTANCE = "java.naming.corba.orb";
private static ORB orb;
public static void setORB(ORB orb)
{
ORBInitialContextFactory.orb = orb;
}
public Context getInitialContext(Hashtable env) throws NamingException
{
insertORB(env);
return super.getInitialContext(env);
}
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception
{
insertORB(environment);
return super.getObjectInstance(obj, name, nameCtx, environment);
}
protected void insertORB(Hashtable environment)
{
if (orb != null && environment.containsKey(ORB_INSTANCE) == false)
environment.put(ORB_INSTANCE, orb);
}
}