Package nablarch.common.handler
Class DbConnectionManagementHandler
java.lang.Object
nablarch.common.handler.DbConnectionManagementHandler
- All Implemented Interfaces:
Handler<Object,,Object> InboundHandleable,OutboundHandleable
public class DbConnectionManagementHandler
extends Object
implements Handler<Object,Object>, InboundHandleable, OutboundHandleable
後続ハンドラの処理で必要となる、データベース接続オブジェクトを
スレッドローカル変数上で管理するハンドラ。
デフォルトの設定では、トランザクションが暗黙的に使用する接続名 (TransactionContext.DEFAULT_TRANSACTION_CONTEXT_KEY) に対して接続オブジェクトを登録する。 接続名を明示的に指定する場合は、属性dbConnectionNameにその値を設定する。
<!-- 設定例 --> <component class="nablarch.common.handler.DbConnectionManagementHandler"> <!-- DbConnectionFactory --> <property name="dbConnectionFactory" ref="dbConnectionFactory"/> <!-- 追加するデータベース接続オブジェクトの名称 --> <property name="dbConnectionName" value="db"/> </component>
- Author:
- Iwauo Tajima
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafter()復路処理を行う。voidbefore()往路処理を行う。handle(Object inputData, ExecutionContext ctx) 入力データに対する処理を実行する。handleInbound(ExecutionContext context) 前処理を実装する。handleOutbound(ExecutionContext context) 後処理を実装する。setConnectionFactory(ConnectionFactory connectionFactory) データベース接続オブジェクトを生成するためのファクトリを設定する。voidsetConnectionName(String connectionName) データベース接続のスレッドコンテキスト上の登録名を設定する。
-
Constructor Details
-
DbConnectionManagementHandler
public DbConnectionManagementHandler()
-
-
Method Details
-
setConnectionFactory
データベース接続オブジェクトを生成するためのファクトリを設定する。- Parameters:
connectionFactory- データベース接続オブジェクトを生成するためのファクトリ- Returns:
- このハンドラ自体
-
setConnectionName
データベース接続のスレッドコンテキスト上の登録名を設定する。デフォルトでは既定のトランザクション名 (
TransactionContext.DEFAULT_TRANSACTION_CONTEXT_KEY)を使用する。- Parameters:
connectionName- データベース接続のスレッドコンテキスト上の登録名
-
handle
入力データに対する処理を実行する。このクラスの実装では後続ハンドラに対する処理委譲の前後に、 データベース接続オブジェクトの初期化と終了の処理をそれぞれ行う。
-
before
public void before() -
after
public void after()復路処理を行う。DbConnectionContextからデータベース接続を削除し、リソースの開放処理を行う。 -
handleInbound
Description copied from interface:InboundHandleable前処理を実装する。- Specified by:
handleInboundin interfaceInboundHandleable- Parameters:
context- ExecutionContext- Returns:
- 処理結果オブジェクト
-
handleOutbound
Description copied from interface:OutboundHandleable後処理を実装する。- Specified by:
handleOutboundin interfaceOutboundHandleable- Parameters:
context- ExecutionContext- Returns:
- 処理結果オブジェクト
-