Search code examples
javajmsjndirmi

how is JNDI used in RMI and JMS?


I would like to know how JMS and RMI uses JNDI ,i would also appreciate any snippets of code explaining it .

Thanks


Solution

  • The Java Naming and Directory Interface (JNDI) provides a standard way of accessing naming and directory services

    Example Obtaining the initial JNDI context:

     import javax.naming.*;
     private static InitialContext ctx = null;
      ...
      public static InitialContext getInitialContext( ) throws NamingException {
       if (ctx == null) {
        Hashtable env = new Hashtable( );
        env.put(Context.INITIAL_CONTEXT_FACTORY, 
            "weblogic.jndi.WLInitialContextFactory");
        env.put(Context.PROVIDER_URL, 
            "t3://myserver:8001");
        ctx = new InitialContext(env);
       }
     return ctx;
     }
    

    See Chapter 4. Using JNDI and RMI of WebLogic: The Definitive Guide for more details.