インターフェース MethodInterceptor
- すべてのスーパーインターフェース:
Advice,Interceptor
- すべての既知のサブインターフェース:
IntroductionInterceptor
- すべての既知の実装クラス:
AbstractMonitoringInterceptor、AbstractTraceInterceptor、AfterReturningAdviceInterceptor、AnnotationAsyncExecutionInterceptor、AspectJAfterAdvice、AspectJAfterThrowingAdvice、AspectJAroundAdvice、AsyncExecutionInterceptor、CacheInterceptor、ConcurrencyThrottleInterceptor、CustomizableTraceInterceptor、DebugInterceptor、DelegatePerTargetObjectIntroductionInterceptor、DelegatingIntroductionInterceptor、EventPublicationInterceptor、ExposeInvocationInterceptor、JCacheInterceptor、MBeanClientInterceptor、MBeanProxyFactoryBean、MethodBeforeAdviceInterceptor、MethodValidationInterceptor、OpenSessionInterceptor、PerformanceMonitorInterceptor、PersistenceExceptionTranslationInterceptor、SimpleTraceInterceptor、ThrowsAdviceInterceptor、TransactionInterceptor
- 関数インターフェース:
- これは関数インターフェースであるため、ラムダ式またはメソッド参照の割り当てターゲットとして使用できます。
ターゲットに向かう途中のインターフェース上のコールをインターセプトします。これらはターゲットの「上」にネストされます。
ユーザーは、元の動作を変更するために invoke(MethodInvocation) メソッドを実装する必要があります。例: 次のクラスはトレースインターセプターを実装します (インターセプトされたメソッドのすべての呼び出しをトレースします)。
class TracingInterceptor implements MethodInterceptor {
Object invoke(MethodInvocation i) throws Throwable {
System.out.println("method "+i.getMethod()+" is called on "+
i.getThis()+" with args "+i.getArguments());
Object ret=i.proceed();
System.out.println("method "+i.getMethod()+" returns "+ret);
return ret;
}
}
- 作成者:
- Rod Johnson
メソッドのサマリー
メソッドの詳細
invoke
このメソッドを実装して、呼び出しの前後に追加の処理を実行します。正しい実装としては、必ずJoinpoint.proceed()を呼び出すようにします。- パラメーター:
invocation- メソッド呼び出しジョインポイント- 戻り値:
Joinpoint.proceed()の呼び出しの結果。インターセプターによってインターセプトされる可能性があります- 例外:
ThrowableSE- インターセプターまたはターゲットオブジェクトが例外をスローする場合