public class ThreadContextHandler extends Object implements nablarch.fw.Handler<Object,Object>, nablarch.fw.InboundHandleable, nablarch.fw.OutboundHandleable
<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 and Description |
|---|
ThreadContextHandler()
デフォルトコンストラクタ
|
ThreadContextHandler(ThreadContextAttribute... attributes)
引数に渡されたスレッドコンテキスト属性を管理するハンドラを生成する。
|
| Modifier and Type | Method and Description |
|---|---|
Object |
handle(Object input,
nablarch.fw.ExecutionContext ctx) |
nablarch.fw.Result |
handleInbound(nablarch.fw.ExecutionContext context) |
nablarch.fw.Result |
handleOutbound(nablarch.fw.ExecutionContext context) |
ThreadContextHandler |
setAttributes(List<ThreadContextAttribute> attributes)
このハンドラが管理する属性のリストを登録する。
|
public ThreadContextHandler(ThreadContextAttribute... attributes)
このメソッドの処理は以下のソースコードと等価である。
new ThreadContextHandler()
.setAttributes(Arrays.asList(attributes))
attributes - スレッドコンテキスト属性public ThreadContextHandler()
public Object handle(Object input, nablarch.fw.ExecutionContext ctx)
このクラスの実装では以下の処理を行う。
1. スレッドコンテキスト上の全てのエントリを削除する。
2. このハンドラに登録されている全ての属性について、
キー(ThreadContextAttribute#getKey()の結果)と値(ThreadContextAttribute#getValue()の結果)を
スレッドコンテキストに格納する。
3. 後続のリクエストハンドラに処理を委譲する。
public ThreadContextHandler setAttributes(List<ThreadContextAttribute> attributes)
attributes - このハンドラが管理する属性のリストpublic nablarch.fw.Result handleInbound(nablarch.fw.ExecutionContext context)
handleInbound in interface nablarch.fw.InboundHandleablepublic nablarch.fw.Result handleOutbound(nablarch.fw.ExecutionContext context)
handleOutbound in interface nablarch.fw.OutboundHandleableCopyright © 2020. All rights reserved.