KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > naming > remote > proxy > JNDIHandler


1 package org.sapia.ubik.rmi.naming.remote.proxy;
2
3 import java.util.Hashtable JavaDoc;
4 import java.util.Map JavaDoc;
5
6 import javax.naming.Context JavaDoc;
7 import javax.naming.NameNotFoundException JavaDoc;
8 import javax.naming.NamingException JavaDoc;
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 /**
16  * @author Yanick Duchesne
17  * <dl>
18  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
19  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
20  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
21  * </dl>
22  */

23 public class JNDIHandler implements ServiceHandler {
24   /**
25    * @see org.sapia.ubik.rmi.naming.ServiceHandler#handleLookup(String, int, String, Map)
26    */

27   public Object JavaDoc handleLookup(String JavaDoc host, int port, String JavaDoc path, Map JavaDoc attributes)
28     throws NameNotFoundException JavaDoc, NamingException JavaDoc {
29     RemoteInitialContextFactory fac = new RemoteInitialContextFactory();
30     Hashtable JavaDoc env = new Hashtable JavaDoc(attributes);
31     env.put(Context.PROVIDER_URL,
32       ServiceLocator.UBIK_SCHEME + "://" + host + ":" + port + "/");
33
34     Context JavaDoc 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