nablarch.common.handler.threadcontext
クラス ThreadContextHandler

java.lang.Object
  上位を拡張 nablarch.common.handler.threadcontext.ThreadContextHandler
すべての実装されたインタフェース:
nablarch.fw.Handler<java.lang.Object,java.lang.Object>, nablarch.fw.InboundHandleable, nablarch.fw.OutboundHandleable

public class ThreadContextHandler
extends java.lang.Object
implements nablarch.fw.Handler<java.lang.Object,java.lang.Object>, nablarch.fw.InboundHandleable, nablarch.fw.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>
 


コンストラクタの概要
ThreadContextHandler()
          デフォルトコンストラクタ
ThreadContextHandler(ThreadContextAttribute... attributes)
          引数に渡されたスレッドコンテキスト属性を管理するハンドラを生成する。
 
メソッドの概要
 java.lang.Object handle(java.lang.Object input, nablarch.fw.ExecutionContext ctx)
           このクラスの実装では以下の処理を行う。
 nablarch.fw.Result handleInbound(nablarch.fw.ExecutionContext context)
           
 nablarch.fw.Result handleOutbound(nablarch.fw.ExecutionContext context)
           
 ThreadContextHandler setAttributes(java.util.List<ThreadContextAttribute> attributes)
          このハンドラが管理する属性のリストを登録する。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

ThreadContextHandler

public ThreadContextHandler(ThreadContextAttribute... attributes)
引数に渡されたスレッドコンテキスト属性を管理するハンドラを生成する。
 このメソッドの処理は以下のソースコードと等価である。
 
     new ThreadContextHandler()
         .setAttributes(Arrays.asList(attributes))
 

パラメータ:
attributes - スレッドコンテキスト属性

ThreadContextHandler

public ThreadContextHandler()
デフォルトコンストラクタ

メソッドの詳細

handle

public java.lang.Object handle(java.lang.Object input,
                               nablarch.fw.ExecutionContext ctx)
 このクラスの実装では以下の処理を行う。
 
   1. スレッドコンテキスト上の全てのエントリを削除する。
   2. このハンドラに登録されている全ての属性について、
      キー(ThreadContextAttribute#getKey()の結果)と値(ThreadContextAttribute#getValue()の結果)を
      スレッドコンテキストに格納する。
   3. 後続のリクエストハンドラに処理を委譲する。
 

定義:
インタフェース nablarch.fw.Handler<java.lang.Object,java.lang.Object> 内の handle

setAttributes

public ThreadContextHandler setAttributes(java.util.List<ThreadContextAttribute> attributes)
このハンドラが管理する属性のリストを登録する。

パラメータ:
attributes - このハンドラが管理する属性のリスト
戻り値:
このオブジェクト自体

handleInbound

public nablarch.fw.Result handleInbound(nablarch.fw.ExecutionContext context)
定義:
インタフェース nablarch.fw.InboundHandleable 内の handleInbound

handleOutbound

public nablarch.fw.Result handleOutbound(nablarch.fw.ExecutionContext context)
定義:
インタフェース nablarch.fw.OutboundHandleable 内の handleOutbound