Class JndiObjectTargetSource
- All Implemented Interfaces:
- TargetClassAware, TargetSource, InitializingBean
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="jakarta.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).
- Since:
- 1.1
- Author:
- Juergen Hoeller
- See Also:
- 
Field SummaryFields inherited from class JndiLocatorSupportCONTAINER_PREFIXFields inherited from class JndiAccessorlogger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.Return a target instance.Return the type of targets returned by thisTargetSource.booleanisStatic()Will all calls toTargetSource.getTarget()return the same object?voidsetCache(boolean cache) Set whether to cache the JNDI object once it has been located.voidsetLookupOnStartup(boolean lookupOnStartup) Set whether to look up the JNDI object on startup.Methods inherited from class JndiObjectLocatorgetExpectedType, getJndiName, lookup, setExpectedType, setJndiNameMethods inherited from class JndiLocatorSupportconvertJndiName, isResourceRef, lookup, lookup, setResourceRefMethods inherited from class JndiAccessorgetJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplateMethods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TargetSourcereleaseTarget
- 
Constructor Details- 
JndiObjectTargetSourcepublic JndiObjectTargetSource()
 
- 
- 
Method Details- 
setLookupOnStartuppublic 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. - See Also:
 
- 
setCachepublic 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. - See Also:
 
- 
afterPropertiesSetDescription copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. - Specified by:
- afterPropertiesSetin interface- InitializingBean
- Overrides:
- afterPropertiesSetin class- JndiObjectLocator
- Throws:
- NamingException
 
- 
getTargetClassDescription copied from interface:TargetSourceReturn the type of targets returned by thisTargetSource.Can return null, although certain usages of aTargetSourcemight just work with a predetermined target class.- Specified by:
- getTargetClassin interface- TargetClassAware
- Specified by:
- getTargetClassin interface- TargetSource
- Returns:
- the type of targets returned by this TargetSource
 
- 
isStaticpublic boolean isStatic()Description copied from interface:TargetSourceWill all calls toTargetSource.getTarget()return the same object?In that case, there will be no need to invoke TargetSource.releaseTarget(Object), and the AOP framework can cache the return value ofTargetSource.getTarget().The default implementation returns false.- Specified by:
- isStaticin interface- TargetSource
- Returns:
- trueif the target is immutable
- See Also:
 
- 
getTargetDescription copied from interface:TargetSourceReturn a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.- Specified by:
- getTargetin interface- TargetSource
- Returns:
- the target object which contains the joinpoint,
or nullif there is no actual target instance
 
 
-