1 22 package org.jboss.test.naming.test; 23 24 import java.util.Hashtable ; 25 import javax.naming.Context ; 26 import javax.naming.NamingException ; 27 import javax.naming.InitialContext ; 28 import javax.naming.spi.InitialContextFactory ; 29 30 import org.jnp.interfaces.Naming; 31 import org.jnp.interfaces.NamingContext; 32 import org.jboss.logging.Logger; 33 34 43 public class BootstrapNamingContextFactory 44 implements InitialContextFactory 45 { 46 static Logger log = Logger.getLogger(BootstrapNamingContextFactory.class); 47 48 public Context getInitialContext(Hashtable env) 50 throws NamingException 51 { 52 Naming namingServer = null; 53 try 54 { 55 Hashtable env2 = (Hashtable ) env.clone(); 56 env2.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); 57 String location = (String ) env.get("bootstrap-binding"); 59 namingServer = (Naming) new InitialContext (env2).lookup(location); 60 log.debug("Found naming proxy:"+namingServer); 61 } 62 catch(Exception e) 63 { 64 log.debug("Lookup failed", e); 65 NamingException ex = new NamingException ("Failed to retrieve Naming interface"); 66 ex.setRootCause(e); 67 throw ex; 68 } 69 70 env = (Hashtable ) env.clone(); 72 return new NamingContext(env, null, namingServer); 73 } 74 } 75 | Popular Tags |