类 JndiObjectTargetSource

  • 所有已实现的接口:
    TargetClassAware, TargetSource, InitializingBean

    public class JndiObjectTargetSource
    extends JndiObjectLocator
    implements 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<?>)