public class JndiObjectTargetSource extends JndiObjectLocator implements TargetSource
getTarget()
呼び出しの構成可能な JNDI ルックアップを提供する AOP TargetSource
。JndiObjectFactoryBean
の代わりに使用して、JNDI オブジェクトを遅延または各操作で再配置できます(「lookupOnStartup」および「cache」プロパティを参照)。これは、JNDI サーバー(リモート JMS サーバーなど)のホットリスタートを可能にするため、開発中に特に役立ちます。
例:
<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>"queueConnectionFactory" プロキシで
createQueueConnection
呼び出しを行うと、"JmsQueueConnectionFactory" の遅延 JNDI ルックアップと、取得した QueueConnectionFactory の createQueueConnection
への後続の委譲呼び出しが発生します。 または、「proxyInterface」を指定して JndiObjectFactoryBean
を使用します。次に、「lookupOnStartup」と「キャッシュ」を JndiObjectFactoryBean で指定して、(別個の ProxyFactoryBean と JndiObjectTargetSource Bean を定義する代わりに)下に JndiObjectTargetSource を作成します。
CONTAINER_PREFIX
logger
コンストラクターと説明 |
---|
JndiObjectTargetSource() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterPropertiesSet() |
ObjectSE | getTarget() ターゲットインスタンスを返します。 |
ClassSE<?> | getTargetClass() この TargetSource によって返されるターゲットのタイプを返します。 |
boolean | isStatic() TargetSource.getTarget() へのすべての呼び出しは同じオブジェクトを返しますか? |
void | releaseTarget(ObjectSE target) TargetSource.getTarget() メソッドから取得した特定のターゲットオブジェクトがあれば解放します。 |
void | setCache(boolean cache) 見つかった JNDI オブジェクトをキャッシュするかどうかを設定します。 |
void | setLookupOnStartup(boolean lookupOnStartup) 起動時に JNDI オブジェクトを検索するかどうかを設定します。 |
getExpectedType, getJndiName, lookup, setExpectedType, setJndiName
convertJndiName, isResourceRef, lookup, lookup, setResourceRef
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public void setLookupOnStartup(boolean lookupOnStartup)
JNDI オブジェクトの遅い可用性を可能にするためにオフにすることができます。この場合、JNDI オブジェクトは最初のアクセスでフェッチされます。
setCache(boolean)
public void setCache(boolean cache)
JNDI オブジェクトのホット再デプロイメントを可能にするためにオフにすることができます。この場合、JNDI オブジェクトは呼び出しごとにフェッチされます。
public void afterPropertiesSet() throws NamingExceptionSE
InitializingBean
BeanFactoryAware
、ApplicationContextAware
などを満たした後、包含 BeanFactory
によって呼び出されます。このメソッドにより、Bean インスタンスは、すべての Bean プロパティが設定されたときに、その全体的な構成の検証と最終的な初期化を実行できます。
InitializingBean
の afterPropertiesSet
JndiObjectLocator
の afterPropertiesSet
NamingExceptionSE
@Nullable public ClassSE<?> getTargetClass()
TargetSource
TargetSource
によって返されるターゲットのタイプを返します。null
を返すことができますが、TargetSource
の特定の使用箇所は、事前定義されたターゲットクラスでのみ機能する場合があります。
TargetClassAware
の getTargetClass
TargetSource
の getTargetClass
TargetSource
によって返されるターゲットのタイプ public boolean isStatic()
TargetSource
TargetSource.getTarget()
へのすべての呼び出しは同じオブジェクトを返しますか? その場合、TargetSource.releaseTarget(Object)
を呼び出す必要はなく、AOP フレームワークは TargetSource.getTarget()
の戻り値をキャッシュできます。
TargetSource
の isStatic
true
(ターゲットが不変の場合)TargetSource.getTarget()
@Nullable public ObjectSE getTarget()
TargetSource
TargetSource
の getTarget
null
public void releaseTarget(ObjectSE target)
TargetSource
TargetSource.getTarget()
メソッドから取得した特定のターゲットオブジェクトがあれば解放します。TargetSource
の releaseTarget
target
- TargetSource.getTarget()
の呼び出しから取得したオブジェクト