1 22 package org.objectweb.petals.kernel.registry.jndi; 23 24 import java.util.Hashtable ; 25 26 import javax.naming.Context ; 27 import javax.naming.NamingException ; 28 import javax.naming.spi.InitialContextFactory ; 29 30 36 public class NamingContextFactory implements InitialContextFactory { 37 38 41 @SuppressWarnings ("unchecked") 42 public Context getInitialContext(Hashtable <?, ?> environment) 43 throws NamingException { 44 String host = (String ) environment.get("java.naming.factory.host"); 46 String portStr = (String ) environment.get("java.naming.factory.port"); 47 48 if (host == null) { 49 throw new NamingException ( 50 "You must specify the property java.naming.factory.host in the environment"); 51 } 52 if (portStr == null) { 53 throw new NamingException ( 54 "You must specify the property java.naming.factory.port in the environment"); 55 } 56 int port = Integer.parseInt(portStr); 57 JNDIConnection jndiConnection = new JNDIConnection(port, host); 58 NamingContextImpl namingContextImpl = new NamingContextImpl( 59 (Hashtable <String , Object >) environment, jndiConnection, "/"); 60 61 return namingContextImpl; 62 } 63 } 64 | Popular Tags |