org.springframework.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="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).
setLookupOnStartup, setCache, org.springframework.aop.framework.ProxyFactoryBean#setTargetSource , JndiObjectFactoryBean#setProxyInterface
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private Object | |
| private boolean | |
| private Class |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Overrides org. Implements org. Invoked by the containing This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. |
| public Object | |
| public Class | getTargetClass()
Implements org. Return the type of targets returned by this |
| public boolean | isStatic()
Overrides default org. Will all calls to |
| public void | |
| public void |
| cache | back to summary |
|---|---|
| private boolean cache | |
| cachedObject | back to summary |
|---|---|
| private Object cachedObject
| |
| lookupOnStartup | back to summary |
|---|---|
| private boolean lookupOnStartup | |
| targetClass | back to summary |
|---|---|
| private Class<?> targetClass
| |
| JndiObjectTargetSource | back to summary |
|---|---|
| public JndiObjectTargetSource() | |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() throws NamingException Overrides org. Implements org. Doc from org. Invoked by the containing This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
| |
| getTarget | back to summary |
|---|---|
| public Object getTarget() Implements org. Doc from org. Return a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation. | |
| getTargetClass | back to summary |
|---|---|
| public Class Implements org. Doc from org. Return the type of targets returned by this Can return
| |
| isStatic | back to summary |
|---|---|
| public boolean isStatic() Overrides default org. Doc from org. Will all calls to In that case, there will be no need to invoke The default implementation returns
| |
| setCache | back to summary |
|---|---|
| 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 | back to summary |
|---|---|
| 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.
| |