org.springframework.jndi

## 类 JndiPropertySource

- java.lang.Object
- - org.springframework.core.env.PropertySource<JndiLocatorDelegate>
  - - org.springframework.jndi.JndiPropertySource

-     public class JndiPropertySource
      extends org.springframework.core.env.PropertySource<JndiLocatorDelegate>

  `PropertySource` implementation that reads properties from an underlying Spring `JndiLocatorDelegate`.

  By default, the underlying `JndiLocatorDelegate` will be configured with its `"resourceRef"` property set to `true`, meaning that names looked up will automatically be prefixed with "java:comp/env/" in alignment with published JNDI naming conventions. To override this setting or to change the prefix, manually configure a `JndiLocatorDelegate` and provide it to one of the constructors here that accepts it. The same applies when providing custom JNDI properties. These should be specified using `JndiAccessor.setJndiEnvironment(java.util.Properties)` prior to construction of the `JndiPropertySource`.

  Note that `StandardServletEnvironment` includes a `JndiPropertySource` by default, and any customization of the underlying `JndiLocatorDelegate` may be performed within an `ApplicationContextInitializer` or `WebApplicationInitializer`.

  从以下版本开始:
    3.1
  作者:
    Chris Beams, Juergen Hoeller
  另请参阅:
    `JndiLocatorDelegate`, `ApplicationContextInitializer`, `org.springframework.web.WebApplicationInitializer`, `org.springframework.web.context.support.StandardServletEnvironment`

- - ### 嵌套类概要

    - ### 从类继承的嵌套类/接口 org.springframework.core.env.PropertySource

      `org.springframework.core.env.PropertySource.StubPropertySource`

  - ### 字段概要

    - ### 从类继承的字段 org.springframework.core.env.PropertySource

      `logger, name, source`

  - ### 构造器概要

    构造器
    构造器和说明
    `JndiPropertySource(String name)` Create a new `JndiPropertySource` with the given name and a `JndiLocatorDelegate` configured to prefix any names with "java:comp/env/".
    `JndiPropertySource(String name, JndiLocatorDelegate jndiLocator)` Create a new `JndiPropertySource` with the given name and the given `JndiLocatorDelegate`.

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `Object` | `getProperty(String name)` This implementation looks up and returns the value associated with the given name from the underlying `JndiLocatorDelegate`.

    - ### 从类继承的方法 org.springframework.core.env.PropertySource

      `containsProperty, equals, getName, getSource, hashCode, named, toString`

    - ### 从类继承的方法 java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### 构造器详细资料

    - #### JndiPropertySource

          public JndiPropertySource(String name)

      Create a new `JndiPropertySource` with the given name and a `JndiLocatorDelegate` configured to prefix any names with "java:comp/env/".

    - #### JndiPropertySource

          public JndiPropertySource(String name,
                                    JndiLocatorDelegate jndiLocator)

      Create a new `JndiPropertySource` with the given name and the given `JndiLocatorDelegate`.

  - ### 方法详细资料

    - #### getProperty

          @Nullable
          public Object getProperty(String name)

      This implementation looks up and returns the value associated with the given name from the underlying `JndiLocatorDelegate`. If a `NamingException` is thrown during the call to `JndiLocatorDelegate.lookup(String)`, returns `null` and issues a DEBUG-level log statement with the exception message.
      指定者:
        `getProperty` 在类中 `org.springframework.core.env.PropertySource<JndiLocatorDelegate>`