public interface Interceptor extends Advice
汎用インターセプターは、基本プログラム内で発生するランタイムイベントをインターセプトできます。これらのイベントは、ジョインポイントによって(具体化されて)実現されます。ランタイムジョインポイントは、呼び出し、フィールドアクセス、例外などです。
このインターフェースは直接使用されません。サブインターフェースを使用して特定のイベントをインターセプトします。たとえば、次のクラスは、デバッガーを実装するために特定のインターセプターを実装しています。
class DebuggingInterceptor implements MethodInterceptor,
ConstructorInterceptor {
Object invoke(MethodInvocation i) throws Throwable {
debug(i.getMethod(), i.getThis(), i.getArgs());
return i.proceed();
}
Object construct(ConstructorInvocation i) throws Throwable {
debug(i.getConstructor(), i.getThis(), i.getArgs());
return i.proceed();
}
void debug(AccessibleObject ao, Object this, Object value) {
...
}
}
Joinpoint