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" と "cache" を JndiObjectFactoryBean に指定して、そに JndiObjectTargetSource を作成できます (ProxyFactoryBean と JndiObjectTargetSource の Bean を個別に定義する代わりに)。
CONTAINER_PREFIXlogger| コンストラクターと説明 |
|---|
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, setJndiNameconvertJndiName, isResourceRef, lookup, lookup, setResourceRefgetJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplatecloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEpublic void setLookupOnStartup(boolean lookupOnStartup)
JNDI オブジェクトの遅い可用性を可能にするためにオフにすることができます。この場合、JNDI オブジェクトは最初のアクセスでフェッチされます。
setCache(boolean)public void setCache(boolean cache)
JNDI オブジェクトのホット再デプロイメントを可能にするためにオフにすることができます。この場合、JNDI オブジェクトは呼び出しごとにフェッチされます。
public void afterPropertiesSet()
throws NamingExceptionSEInitializingBeanBeanFactoryAware、ApplicationContextAware などを満たした後、包含 BeanFactory によって呼び出されます。このメソッドにより、Bean インスタンスは、すべての Bean プロパティが設定されたときに、その全体的な構成の検証と最終的な初期化を実行できます。
InitializingBean の afterPropertiesSet JndiObjectLocator の afterPropertiesSet NamingExceptionSE@Nullable public ClassSE<?> getTargetClass()
TargetSourceTargetSource によって返されるターゲットの型を返します。null を返すことができますが、TargetSource の特定の使用箇所は、事前定義されたターゲットクラスでのみ機能する場合があります。
TargetClassAware の getTargetClass TargetSource の getTargetClass TargetSource によって返されるターゲットの型 public boolean isStatic()
TargetSourceTargetSource.getTarget() へのすべての呼び出しは同じオブジェクトを返しますか? その場合、TargetSource.releaseTarget(Object) を呼び出す必要はなく、AOP フレームワークは TargetSource.getTarget() の戻り値をキャッシュできます。
TargetSource の isStatic true (ターゲットが不変の場合)TargetSource.getTarget()@Nullable public ObjectSE getTarget()
TargetSourceTargetSource の getTarget null public void releaseTarget(ObjectSE target)
TargetSourceTargetSource.getTarget() メソッドから取得した特定のターゲットオブジェクトがあれば解放します。TargetSource の releaseTarget target - TargetSource.getTarget() の呼び出しから取得したオブジェクト