@Documented @Target(value=ANNOTATION_TYPE) @Retention(value=RUNTIME) @Published(tag="architect") public @interface Interceptor
Handler.handle(Object, ExecutionContext)メソッドに対するインターセプタに付与する
メタアノテーション。
インターセプタを作成するには、このメタアノテーションを付与したアノテーションを作成し、
Interceptorの属性には、インターセプト処理を実装するクラスを指定する。
この実装クラスは、Interceptor.Impl を継承して作成する。
以下は、インターセプタ"@AroundAdvice"の実装例である。
@Target(ElementType.METHOD)@Retention(RetentionPolicy.RUNTIME)@Interceptor(AroundAdvice.Impl.class) public@interfaceAroundAdvice { public static class Impl extends Interceptor.Impl{ public HttpResponse handle(HttpRequest req, ExecutionContext ctx) { doBeforeAdvice(req, ctx); HttpResponse res = getOriginalHandler().handle(req, ctx); doAfterAdvice(req, ctx); return res; } void doBeforeAdvice(HttpRequest req, ExecutionContext ctx) { //...... } void doAfterAdvice(HttpRequest req, ExecutionContext ctx) { //...... } } }
| 修飾子とタイプ | 必須要素と説明 |
|---|---|
java.lang.Class<? extends Interceptor.Impl> |
value
このインターセプタが付与されたメソッドに対して実行される
インターセプト処理を実装するクラス。
|
public abstract java.lang.Class<? extends Interceptor.Impl> value
Interceptor.Impl