if(nameCtx == null)
nameCtx = new InitialContext(environment);
final Context lookupCtx = nameCtx;
return new BrainlessContext()
{
@Override
public Object lookup(Name name) throws NamingException
{
if (name.size() > 0 && "java:comp".equals(name.get(0)))
{
if (name.size() == 2 && "ORB".equals(name.get(1)))
return ORBFactory.getORB();
else if (name.size() == 2 && "HandleDelegate".equals(name.get(1)))
return HandleDelegateFactory.getHandleDelegateSingleton();
}
throw new NameNotFoundException(name.toString());
}
@Override
public Object lookup(String name) throws NamingException
{
NameParser parser = lookupCtx.getNameParser("");
return lookup(parser.parse(name));
}
};