类 JndiObjectTargetSource
- java.lang.Object
- org.springframework.jndi.JndiAccessor
- org.springframework.jndi.JndiLocatorSupport
- org.springframework.jndi.JndiObjectLocator
- org.springframework.jndi.JndiObjectTargetSource
- 所有已实现的接口:
TargetClassAware,TargetSource,InitializingBean
public class JndiObjectTargetSource extends JndiObjectLocator implements TargetSource
AOPTargetSourcethat provides configurable JNDI lookups forgetTarget()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>
AcreateQueueConnectioncall on the "queueConnectionFactory" proxy will cause a lazy JNDI lookup for "JmsQueueConnectionFactory" and a subsequent delegating call to the retrieved QueueConnectionFactory'screateQueueConnection.Alternatively, use a
JndiObjectFactoryBeanwith a "proxyInterface". "lookupOnStartup" and "cache" can then be specified on the JndiObjectFactoryBean, creating a JndiObjectTargetSource underneath (instead of defining separate ProxyFactoryBean and JndiObjectTargetSource beans).
字段概要
从类继承的字段 org.springframework.jndi.JndiLocatorSupport
CONTAINER_PREFIX
从类继承的字段 org.springframework.jndi.JndiAccessor
logger
构造器概要
构造器 构造器 说明 JndiObjectTargetSource()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.ObjectgetTarget()Return a target instance.Class<?>getTargetClass()Return the type of targets returned by thisTargetSource.booleanisStatic()Will all calls toTargetSource.getTarget()return the same object?voidreleaseTarget(Object target)Release the given target object obtained from theTargetSource.getTarget()method, if any.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.从类继承的方法 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
构造器详细资料
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.
afterPropertiesSet
public void afterPropertiesSet() throws NamingException
从接口复制的说明: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.
- 指定者:
afterPropertiesSet在接口中InitializingBean- 覆盖:
afterPropertiesSet在类中JndiObjectLocator- 抛出:
NamingException
getTargetClass
@Nullable public Class<?> getTargetClass()
从接口复制的说明:TargetSourceReturn the type of targets returned by thisTargetSource.Can return
null, although certain usages of aTargetSourcemight just work with a predetermined target class.- 指定者:
getTargetClass在接口中TargetClassAware- 指定者:
getTargetClass在接口中TargetSource- 返回:
- the type of targets returned by this
TargetSource
isStatic
public boolean isStatic()
从接口复制的说明: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().- 指定者:
isStatic在接口中TargetSource- 返回:
trueif the target is immutable- 另请参阅:
TargetSource.getTarget()
getTarget
@Nullable public Object getTarget()
从接口复制的说明:TargetSourceReturn a target instance. Invoked immediately before the AOP framework calls the "target" of an AOP method invocation.- 指定者:
getTarget在接口中TargetSource- 返回:
- the target object which contains the joinpoint, or
nullif there is no actual target instance
releaseTarget
public void releaseTarget(Object target)
从接口复制的说明:TargetSourceRelease the given target object obtained from theTargetSource.getTarget()method, if any.- 指定者:
releaseTarget在接口中TargetSource- 参数:
target- object obtained from a call toTargetSource.getTarget()