1 package org.sapia.ubik.rmi.naming.remote.proxy; 2 3 import java.util.Hashtable ; 4 import java.util.Map ; 5 6 import javax.naming.Context ; 7 import javax.naming.NameNotFoundException ; 8 import javax.naming.NamingException ; 9 10 import org.sapia.ubik.rmi.naming.ServiceHandler; 11 import org.sapia.ubik.rmi.naming.ServiceLocator; 12 import org.sapia.ubik.rmi.naming.remote.RemoteInitialContextFactory; 13 14 15 23 public class JNDIHandler implements ServiceHandler { 24 27 public Object handleLookup(String host, int port, String path, Map attributes) 28 throws NameNotFoundException , NamingException { 29 RemoteInitialContextFactory fac = new RemoteInitialContextFactory(); 30 Hashtable env = new Hashtable (attributes); 31 env.put(Context.PROVIDER_URL, 32 ServiceLocator.UBIK_SCHEME + "://" + host + ":" + port + "/"); 33 34 Context context = null; 35 36 try { 37 context = fac.getInitialContext(env); 38 39 return context.lookup(path); 40 } finally { 41 if (context != null) { 42 context.close(); 43 } 44 } 45 } 46 } 47 | Popular Tags |