org.springframework.jndi

## 类 JndiObjectLocator

- java.lang.Object
- - org.springframework.jndi.JndiAccessor
  - - org.springframework.jndi.JndiLocatorSupport
    - - org.springframework.jndi.JndiObjectLocator

- 所有已实现的接口:
    org.springframework.beans.factory.InitializingBean
  直接已知子类:
    AbstractSlsbInvokerInterceptor, JndiObjectFactoryBean, JndiObjectTargetSource, JndiRmiClientInterceptor

      public abstract class JndiObjectLocator
      extends JndiLocatorSupport
      implements org.springframework.beans.factory.InitializingBean

  Convenient superclass for JNDI-based service locators, providing configurable lookup of a specific JNDI resource.

  Exposes a `"jndiName"` property. This may or may not include the "java:comp/env/" prefix expected by Java EE applications when accessing a locally mapped (Environmental Naming Context) resource. If it doesn't, the "java:comp/env/" prefix will be prepended if the "resourceRef" property is true (the default is false) and no other scheme (e.g. "java:") is given.

  Subclasses may invoke the `lookup()` method whenever it is appropriate. Some classes might do this on initialization, while others might do it on demand. The latter strategy is more flexible in that it allows for initialization of the locator before the JNDI object is available.

  从以下版本开始:
    1.1
  作者:
    Juergen Hoeller
  另请参阅:
    `setJndiName(java.lang.String)`, `JndiAccessor.setJndiTemplate(org.springframework.jndi.JndiTemplate)`, `JndiAccessor.setJndiEnvironment(java.util.Properties)`, `JndiLocatorSupport.setResourceRef(boolean)`, `lookup()`

- - ### 字段概要

    - ### 从类继承的字段 org.springframework.jndi.JndiLocatorSupport

      `CONTAINER_PREFIX`

    - ### 从类继承的字段 org.springframework.jndi.JndiAccessor

      `logger`

  - ### 构造器概要

    构造器
    构造器和说明
    `JndiObjectLocator()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `afterPropertiesSet()`
    `Class<?>` | `getExpectedType()` Return the type that the located JNDI object is supposed to be assignable to, if any.
    `String` | `getJndiName()` Return the JNDI name to look up.
    `protected Object` | `lookup()` Perform the actual JNDI lookup for this locator's target resource.
    `void` | `setExpectedType(Class<?> expectedType)` Specify the type that the located JNDI object is supposed to be assignable to, if any.
    `void` | `setJndiName(String jndiName)` Specify the JNDI name to look up.

    - ### 从类继承的方法 org.springframework.jndi.JndiLocatorSupport

      `convertJndiName, isResourceRef, lookup, lookup, setResourceRef`

    - ### 从类继承的方法 org.springframework.jndi.JndiAccessor

      `getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

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

    - #### JndiObjectLocator

          public JndiObjectLocator()

  - ### 方法详细资料

    - #### setJndiName

          public void setJndiName(@Nullable
                                  String jndiName)

      Specify the JNDI name to look up. If it doesn't begin with "java:comp/env/" this prefix is added automatically if "resourceRef" is set to "true".
      参数:
        `jndiName` - the JNDI name to look up
      另请参阅:
        `JndiLocatorSupport.setResourceRef(boolean)`

    - #### getJndiName

          @Nullable
          public String getJndiName()

      Return the JNDI name to look up.

    - #### setExpectedType

          public void setExpectedType(@Nullable
                                      Class<?> expectedType)

      Specify the type that the located JNDI object is supposed to be assignable to, if any.

    - #### getExpectedType

          @Nullable
          public Class<?> getExpectedType()

      Return the type that the located JNDI object is supposed to be assignable to, if any.

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws IllegalArgumentException,
                                         NamingException

      指定者:
        `afterPropertiesSet` 在接口中 `org.springframework.beans.factory.InitializingBean`
      抛出:
        `IllegalArgumentException`
        `NamingException`

    - #### lookup

          protected Object lookup()
                           throws NamingException

      Perform the actual JNDI lookup for this locator's target resource.
      返回:
        the located target object
      抛出:
        `NamingException` - if the JNDI lookup failed or if the located JNDI object is not assigable to the expected type
      另请参阅:
        `setJndiName(java.lang.String)`, `setExpectedType(java.lang.Class<?>)`, `JndiLocatorSupport.lookup(String, Class)`