【问题标题】:why use properties over hashtable when getting initial context为什么在获取初始上下文时使用哈希表上的属性
【发布时间】:2014-06-07 07:10:23
【问题描述】:

我编写了一个客户端来将 EJB 部署到 JBoss 中。我参考了互联网上的例子。几乎所有这些都使用 Properties 类来定义 URL 和初始上下文工厂。我想知道为什么属性比哈希表更受欢迎,因为我们没有将它存储到文件或从中读取? 互联网上的一个示例是 -

Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
props.put(Context.PROVIDER_URL, "file:///");

// Create the initial context from the properties we just created
Context initialContext = new InitialContext(props)

【问题讨论】:

    标签: properties hashtable jndi initial-context


    【解决方案1】:

    这不是“首选”。这几乎是一样的。属性扩展了 Hashtable。请参阅 Javadoc。

    【讨论】:

      猜你喜欢
      • 2011-10-05
      • 1970-01-01
      • 2021-03-10
      • 2012-02-22
      • 1970-01-01
      • 2012-11-15
      • 2011-12-26
      • 1970-01-01
      • 2016-07-11
      相关资源
      最近更新 更多