public abstract static class Interceptor.Impl<TData,TResult,T>
extends java.lang.Object
implements nablarch.fw.HandlerWrapper<TData,TResult>
Interceptorの処理内容を実装するクラスの抽象基底クラスとなるリクエストハンドラ。
各インターセプションが付与されたときに行われるインターセプト処理の内容は、
このクラスを継承して作成する。
各Interceptorの値に指定されるクラスは、このクラスのサブクラスであり、
インターセプトが行われると、そのサブクラスが実装するHandler.handle(Object, ExecutionContext)に処理が委譲される。
この際、ラップされる前のリクエストハンドラをInterceptor.Impl.getOriginalHandler()で取得できるので、
各インターセプタ固有の処理を以下の例のように実装することができる。
public HttpResponse handle(HttpRequest req, ExecutionContext ctx) {
try {
doBeforeAdvice(); // インターセプタによる前処理
return getOriginalHandler().handle(req, ctx); // 本処理
} catch(RuntimeException e) {
doErrorHandling(); // インターセプタによる例外ハンドリング
throw e;
} finally {
doAfterAdvice(); // インターセプタによる終端処理
}
}
| Constructor and Description |
|---|
Impl() |
| Modifier and Type | Method and Description |
|---|---|
T |
getInterceptor()
処理対象の
Interceptorを取得する。 |
Handler<TData,TResult> |
getOriginalHandler()
インターセプト対象のリクエストハンドラを取得する。
|
@Published(tag="architect") public T getInterceptor()
Interceptorを取得する。Interceptorを取得する。