public class GenericMessageEndpointManager extends ObjectSE implements SmartLifecycle, InitializingBean, DisposableBean
このクラスは、ResourceAdapter、MessageEndpointFactory、および ActivationSpec で機能するという点で完全に汎用的です。次のように、Spring の XML Bean 定義形式などを使用して、標準の Bean スタイルで構成できます。
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointManager">
<property name="resourceAdapter" ref="resourceAdapter"/>
<property name="messageEndpointFactory">
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointFactory">
<property name="messageListener" ref="messageListener"/>
</bean>
</property>
<property name="activationSpec">
<bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
<property name="destination" value="myQueue"/>
<property name="destinationType" value="javax.jms.Queue"/>
</bean>
</property>
</bean> この例では、Spring 自身の GenericMessageEndpointFactory を使用して、指定されたターゲット ResourceAdapter によってサポートされている標準のメッセージリスナオブジェクト (この場合は、ActiveMQ メッセージブローカーによってサポートされ、Spring Bean として定義されている JMS MessageListenerEE オブジェクト) を示します。<bean id="messageListener" class="com.myorg.messaging.myMessageListener"> ... </bean>ターゲット ResourceAdapter は、ローカル Spring Bean としても構成できます (一般的なケース)。または、JNDI から取得することもできます (例: WebLogic)。上記の例では、ローカル ResourceAdapter Bean は次のように定義できます (上記の "resourceAdapter" Bean 参照に一致)。
<bean id="resourceAdapter" class="org.springframework.jca.support.ResourceAdapterFactoryBean">
<property name="resourceAdapter">
<bean class="org.apache.activemq.ra.ActiveMQResourceAdapter">
<property name="serverUrl" value="tcp://localhost:61616"/>
</bean>
</property>
<property name="workManager">
<bean class="org.springframework.jca.work.SimpleTaskWorkManager"/>
</property>
</bean> 別のターゲットリソースの場合、構成は、別の ResourceAdapter および別の ActivationSpec オブジェクト(どちらもリソースプロバイダーに固有)を指し、場合によっては別のメッセージリスナー(たとえば、以下に基づくリソースアダプターの CCI MessageListenerEE)を指すだけです。JCA Common Client Interface)。 非同期実行戦略は、ResourceAdapterFactoryBean の "workManager" プロパティを通じてカスタマイズできます (上記参照)。構成オプションについては、SimpleTaskWorkManager の javadoc を参照してください。または、他の JCA 準拠の WorkManager (Geronimo など) を使用することもできます。
トランザクションの実行は、指定された MessageEndpointFactory によって構築された具体的なメッセージエンドポイントの責任です。GenericMessageEndpointFactory は、通常、そこに指定された Spring JtaTransactionManager または単純な TransactionManagerSE 実装を使用して、その "transactionManager" プロパティを通じて XA トランザクション参加をサポートします。
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointManager">
<property name="resourceAdapter" ref="resourceAdapter"/>
<property name="messageEndpointFactory">
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointFactory">
<property name="messageListener" ref="messageListener"/>
<property name="transactionManager" ref="transactionManager"/>
</bean>
</property>
<property name="activationSpec">
<bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
<property name="destination" value="myQueue"/>
<property name="destinationType" value="javax.jms.Queue"/>
</bean>
</property>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/> または、リソースプロバイダーの ActivationSpec オブジェクトを確認してください。これは、プロバイダー固有の構成フラグ(例: ActiveMQActivationSpec の "useRAManagedTransaction" Bean プロパティ。
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointManager">
<property name="resourceAdapter" ref="resourceAdapter"/>
<property name="messageEndpointFactory">
<bean class="org.springframework.jca.endpoint.GenericMessageEndpointFactory">
<property name="messageListener" ref="messageListener"/>
</bean>
</property>
<property name="activationSpec">
<bean class="org.apache.activemq.ra.ActiveMQActivationSpec">
<property name="destination" value="myQueue"/>
<property name="destinationType" value="javax.jms.Queue"/>
<property name="useRAManagedTransaction" value="true"/>
</bean>
</property>
</bean>ResourceAdapter.endpointActivation(javax.resource.spi.endpoint.MessageEndpointFactory, javax.resource.spi.ActivationSpec)EE, ResourceAdapter.endpointDeactivation(javax.resource.spi.endpoint.MessageEndpointFactory, javax.resource.spi.ActivationSpec)EE, MessageEndpointFactoryEE, ActivationSpecEE| コンストラクターと説明 |
|---|
GenericMessageEndpointManager() |
| 修飾子と型 | メソッドと説明 |
|---|---|
void | afterPropertiesSet() メッセージエンドポイントを準備し、"autoStartup" フラグが "true" に設定されている場合は自動的にアクティブ化します。 |
void | destroy() メッセージエンドポイントを非アクティブ化し、シャットダウンの準備をします。 |
ActivationSpecEE | getActivationSpec() エンドポイントのアクティブ化に使用する JCA ActivationSpec を返します。 |
MessageEndpointFactoryEE | getMessageEndpointFactory()JCA MessageEndpointFactory を返却してアクティブにします。 |
int | getPhase() このエンドポイントマネージャーが開始および停止されるフェーズを返します。 |
ResourceAdapterEE | getResourceAdapter() エンドポイントを管理する JCA ResourceAdapter を返します。 |
boolean | isAutoStartup()'autoStartup' プロパティの値を返します。 |
boolean | isRunning() 設定されたメッセージエンドポイントが現在アクティブかどうかを返します。 |
void | setActivationSpec(ActivationSpecEE activationSpec) エンドポイントのアクティブ化に使用する JCA ActivationSpec を設定します。 |
void | setAutoStartup(boolean autoStartup) このエンドポイントマネージャーが初期化され、コンテキストがリフレッシュされた後に、エンドポイントのアクティブ化を自動で開始するかどうかを設定します。 |
void | setMessageEndpointFactory(MessageEndpointFactoryEE messageEndpointFactory) エンドポイントが委譲する MessageListener オブジェクトを指すように、JCA MessageEndpointFactory をアクティブに設定します。 |
void | setPhase(int phase) この Endpoint Manager を開始および停止するフェーズを指定します。 |
void | setResourceAdapter(ResourceAdapterEE resourceAdapter) エンドポイントを管理する JCA ResourceAdapter を設定します。 |
void | start() 設定されたメッセージエンドポイントをアクティブ化します。 |
void | stop() 設定されたメッセージエンドポイントを非アクティブ化します。 |
void | stop(RunnableSE callback)Lifecycle コンポーネントが現在実行中の場合、停止する必要があることを示します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEpublic void setResourceAdapter(ResourceAdapterEE resourceAdapter)
public ResourceAdapterEE getResourceAdapter()
public void setMessageEndpointFactory(MessageEndpointFactoryEE messageEndpointFactory)
MessageEndpointFactory インスタンスは、異なる ActivationSpec オブジェクトを適用して、複数のエンドポイント(つまり、複数の GenericMessageEndpointManager インスタンス)で共有できます。
public MessageEndpointFactoryEE getMessageEndpointFactory()
public void setActivationSpec(ActivationSpecEE activationSpec)
この ActivationSpec インスタンスを複数の ResourceAdapter インスタンス間で共有しないでください。
public ActivationSpecEE getActivationSpec()
public void setAutoStartup(boolean autoStartup)
デフォルトは "true" です。このフラグをオフにして、明示的な start() 呼び出しまでエンドポイントのアクティブ化を延期します。
public boolean isAutoStartup()
public void setPhase(int phase)
public void afterPropertiesSet()
throws ResourceExceptionEEInitializingBean の afterPropertiesSet ResourceExceptionEEpublic void start()
Lifecycle の start SmartLifecycle.isAutoStartup()public void stop()
Lifecycle の stop SmartLifecycle.stop(Runnable), DisposableBean.destroy()public void stop(RunnableSE callback)
SmartLifecycle 提供されたコールバックは、LifecycleProcessor によって使用され、共通のシャットダウン順序値を持つすべてのコンポーネントの順序付けられた、潜在的に同時のシャットダウンをサポートします。コールバック は、SmartLifecycle コンポーネントが実際に停止した後に実行する必要があります。
LifecycleProcessor は、stop メソッドのこのバリアントのみを呼び出します。つまり、SmartLifecycle 実装では、このメソッドの実装内に明示的に委譲されない限り、Lifecycle.stop() は呼び出されません。
SmartLifecycle の stop Lifecycle.stop(), Phased.getPhase()public boolean isRunning()
public void destroy()
DisposableBean の destroy