org.springframework.jndi

## 类 JndiObjectTargetSource

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

- 所有已实现的接口:
    org.springframework.aop.TargetClassAware, org.springframework.aop.TargetSource, org.springframework.beans.factory.InitializingBean

      public class JndiObjectTargetSource
      extends JndiObjectLocator
      implements org.springframework.aop.TargetSource

  AOP `TargetSource` that provides configurable JNDI lookups for `getTarget()` calls.

  Can be used as alternative to `JndiObjectFactoryBean`, to allow for relocating a JNDI object lazily or for each operation (see "lookupOnStartup" and "cache" properties). This is particularly useful during development, as it allows for hot restarting of the JNDI server (for example, a remote JMS server).

  Example:

       <bean id="queueConnectionFactoryTarget" class="org.springframework.jndi.JndiObjectTargetSource">
         <property name="jndiName" value="JmsQueueConnectionFactory"/>
         <property name="lookupOnStartup" value="false"/>
       </bean>

       <bean id="queueConnectionFactory" class="org.springframework.aop.framework.ProxyFactoryBean">
         <property name="proxyInterfaces" value="javax.jms.QueueConnectionFactory"/>
         <property name="targetSource" ref="queueConnectionFactoryTarget"/>
       </bean>

  A `createQueueConnection` call on the "queueConnectionFactory" proxy will cause a lazy JNDI lookup for "JmsQueueConnectionFactory" and a subsequent delegating call to the retrieved QueueConnectionFactory's `createQueueConnection`.

  Alternatively, use a `JndiObjectFactoryBean` with a "proxyInterface". "lookupOnStartup" and "cache" can then be specified on the JndiObjectFactoryBean, creating a JndiObjectTargetSource underneath (instead of defining separate ProxyFactoryBean and JndiObjectTargetSource beans).

  从以下版本开始:
    1.1
  作者:
    Juergen Hoeller
  另请参阅:
    `setLookupOnStartup(boolean)`, `setCache(boolean)`, `AdvisedSupport.setTargetSource(org.springframework.aop.TargetSource)`, `JndiObjectFactoryBean.setProxyInterface(java.lang.Class<?>)`

- - ### 字段概要

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

      `CONTAINER_PREFIX`

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

      `logger`

  - ### 构造器概要

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

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `void` | `afterPropertiesSet()`
    `Object` | `getTarget()`
    `Class<?>` | `getTargetClass()`
    `boolean` | `isStatic()`
    `void` | `releaseTarget(Object target)`
    `void` | `setCache(boolean cache)` Set whether to cache the JNDI object once it has been located.
    `void` | `setLookupOnStartup(boolean lookupOnStartup)` Set whether to look up the JNDI object on startup.

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

      `getExpectedType, getJndiName, lookup, setExpectedType, setJndiName`

    - ### 从类继承的方法 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`

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

    - #### JndiObjectTargetSource

          public JndiObjectTargetSource()

  - ### 方法详细资料

    - #### setLookupOnStartup

          public void setLookupOnStartup(boolean lookupOnStartup)

      Set whether to look up the JNDI object on startup. Default is "true".

      Can be turned off to allow for late availability of the JNDI object. In this case, the JNDI object will be fetched on first access.

      另请参阅:
        `setCache(boolean)`

    - #### setCache

          public void setCache(boolean cache)

      Set whether to cache the JNDI object once it has been located. Default is "true".

      Can be turned off to allow for hot redeployment of JNDI objects. In this case, the JNDI object will be fetched for each invocation.

      另请参阅:
        `setLookupOnStartup(boolean)`

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws NamingException

      指定者:
        `afterPropertiesSet` 在接口中 `org.springframework.beans.factory.InitializingBean`
      覆盖:
        `afterPropertiesSet` 在类中 `JndiObjectLocator`
      抛出:
        `NamingException`

    - #### getTargetClass

          @Nullable
          public Class<?> getTargetClass()

      指定者:
        `getTargetClass` 在接口中 `org.springframework.aop.TargetClassAware`
      指定者:
        `getTargetClass` 在接口中 `org.springframework.aop.TargetSource`

    - #### isStatic

          public boolean isStatic()

      指定者:
        `isStatic` 在接口中 `org.springframework.aop.TargetSource`

    - #### getTarget

          @Nullable
          public Object getTarget()

      指定者:
        `getTarget` 在接口中 `org.springframework.aop.TargetSource`

    - #### releaseTarget

          public void releaseTarget(Object target)

      指定者:
        `releaseTarget` 在接口中 `org.springframework.aop.TargetSource`