Package nablarch.fw
Class Interceptor.Impl<TData,TResult,T extends Annotation>
java.lang.Object
nablarch.fw.Interceptor.Impl<TData,TResult,T>
- All Implemented Interfaces:
Handler<TData,,TResult> HandlerWrapper<TData,TResult>
- Direct Known Subclasses:
CheckRole.Impl,ErrorOnSessionWriteConflict.Impl,InjectForm.Impl,OnDoubleSubmission.Impl,OnError.Impl,OnErrors.Impl,UseToken.Impl
- Enclosing class:
- Interceptor
public abstract static class Interceptor.Impl<TData,TResult,T extends Annotation>
extends Object
implements HandlerWrapper<TData,TResult>
Interceptorの処理内容を実装するクラスの抽象基底クラスとなるリクエストハンドラ。
各インターセプションが付与されたときに行われるインターセプト処理の内容は、
このクラスを継承して作成する。
各Interceptorの値に指定されるクラスは、このクラスのサブクラスであり、
インターセプトが行われると、そのサブクラスが実装するHandler.handle(Object, ExecutionContext)に処理が委譲される。
この際、ラップされる前のリクエストハンドラをgetOriginalHandler()で取得できるので、
各インターセプタ固有の処理を以下の例のように実装することができる。
public HttpResponse handle(HttpRequest req, ExecutionContext ctx) {
try {
doBeforeAdvice(); // インターセプタによる前処理
return getOriginalHandler().handle(req, ctx); // 本処理
} catch(RuntimeException e) {
doErrorHandling(); // インターセプタによる例外ハンドリング
throw e;
} finally {
doAfterAdvice(); // インターセプタによる終端処理
}
}
- Author:
- Iwauo Tajima <iwauo@tis.co.jp>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetDelegates(TData data, ExecutionContext context) このラッパーが処理を移譲するオブジェクトのリストを返す。 対象となるオブジェクトが存在しない場合は空の配列を返す。処理対象のInterceptorを取得する。インターセプト対象のリクエストハンドラを取得する。voidsetInterceptor(Annotation annotation) 処理対象のInterceptorを設定する。voidsetOriginalHandler(Handler<TData, TResult> originalHandler) インターセプト対象のリクエストハンドラを設定する。
-
Constructor Details
-
Impl
-
-
Method Details
-
setInterceptor
処理対象のInterceptorを設定する。- Parameters:
annotation- このクラスが実装するInterceptor
-
getInterceptor
処理対象のInterceptorを取得する。- Returns:
- 処理対象の
Interceptorを取得する。
-
getOriginalHandler
インターセプト対象のリクエストハンドラを取得する。- Returns:
- インターセプト対象のリクエストハンドラ
-
setOriginalHandler
インターセプト対象のリクエストハンドラを設定する。- Parameters:
originalHandler- インターセプト対象のリクエストハンドラ
-
getDelegates
このラッパーが処理を移譲するオブジェクトのリストを返す。 対象となるオブジェクトが存在しない場合は空の配列を返す。- Specified by:
getDelegatesin interfaceHandlerWrapper<TData,TResult> - Parameters:
data- ハンドラに対する入力データcontext- 実行コンテキスト- Returns:
- 内包するオブジェクト。
-