Class ThreadContextHandler
java.lang.Object
nablarch.common.handler.threadcontext.ThreadContextHandler
- All Implemented Interfaces:
Handler<Object,,Object> InboundHandleable,OutboundHandleable
public class ThreadContextHandler
extends Object
implements Handler<Object,Object>, InboundHandleable, OutboundHandleable
スレッドコンテキストに保持される共通属性を管理するハンドラ。
フレームワークには、スレッドコンテキストにユーザID・リクエストID・言語設定を保持する実装が含まれている。
これらを有効化するには以下のリポジトリ設定を追加する。
(同様にプロジェクト固有の属性を追加することも可能である。)
<component class="nablarch.common.handler.threadcontext.ThreadContextHandler">
<property name="attributes">
<list>
<!-- ユーザID -->
<component class="nablarch.common.handler.threadcontext.UserIdAttribute">
<property name="sessionKey" value="user.id" />
<property name="anonymousId" value="guest" />
</component>
<!-- リクエストID -->
<component class="nablarch.common.handler.threadcontext.RequestIdAttribute" />
<!-- 言語 -->
<component class="nablarch.common.handler.threadcontext.LanguageAttribute">
<property name="defaultLanguage" value="ja" />
</component>
</list>
</property>
</component>
-
Constructor Summary
ConstructorsConstructorDescriptionデフォルトコンストラクタThreadContextHandler(ThreadContextAttribute... attributes) 引数に渡されたスレッドコンテキスト属性を管理するハンドラを生成する。 -
Method Summary
Modifier and TypeMethodDescriptionhandle(Object input, ExecutionContext ctx) 入力データに対する処理を実行する。handleInbound(ExecutionContext context) 前処理を実装する。handleOutbound(ExecutionContext context) 後処理を実装する。setAttributes(List<ThreadContextAttribute> attributes) このハンドラが管理する属性のリストを登録する。
-
Constructor Details
-
ThreadContextHandler
引数に渡されたスレッドコンテキスト属性を管理するハンドラを生成する。このメソッドの処理は以下のソースコードと等価である。 new ThreadContextHandler() .setAttributes(Arrays.asList(attributes))- Parameters:
attributes- スレッドコンテキスト属性
-
ThreadContextHandler
public ThreadContextHandler()デフォルトコンストラクタ
-
-
Method Details
-
handle
入力データに対する処理を実行する。このクラスの実装では以下の処理を行う。 1. スレッドコンテキスト上の全てのエントリを削除する。 2. このハンドラに登録されている全ての属性について、 キー(ThreadContextAttribute#getKey()の結果)と値(ThreadContextAttribute#getValue()の結果)を スレッドコンテキストに格納する。 3. 後続のリクエストハンドラに処理を委譲する。 -
setAttributes
このハンドラが管理する属性のリストを登録する。- Parameters:
attributes- このハンドラが管理する属性のリスト- Returns:
- このオブジェクト自体
-
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:
- 処理結果オブジェクト
-