JNDI 在 RMI 和 JMS 中是如何使用的?

how is JNDI used in RMI and JMS?

我想知道 JMS 和 RMI 如何使用 JNDI,我也很想知道解释它的任何代码片段。

谢谢

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

示例获取初始 JNDI 上下文:

 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;
 }

有关详细信息,请参阅 WebLogic:权威指南Chapter 4. Using JNDI and RMI