パッケージ org.aopalliance.intercept

インターフェース MethodInterceptor

すべてのスーパーインターフェース:
AdviceInterceptor
すべての既知のサブインターフェース:
IntroductionInterceptor
すべての既知の実装クラス:
AbstractMonitoringInterceptorAbstractTraceInterceptorAfterReturningAdviceInterceptorAnnotationAsyncExecutionInterceptorAspectJAfterAdviceAspectJAfterThrowingAdviceAspectJAroundAdviceAsyncExecutionInterceptorCacheInterceptorConcurrencyThrottleInterceptorCustomizableTraceInterceptorDebugInterceptorDelegatePerTargetObjectIntroductionInterceptorDelegatingIntroductionInterceptorEventPublicationInterceptorExposeInvocationInterceptorJCacheInterceptorMBeanClientInterceptorMBeanProxyFactoryBeanMethodBeforeAdviceInterceptorMethodValidationInterceptorOpenSessionInterceptorPerformanceMonitorInterceptorPersistenceExceptionTranslationInterceptorSimpleTraceInterceptorThrowsAdviceInterceptorTransactionInterceptor
関数インターフェース:
これは関数インターフェースであるため、ラムダ式またはメソッド参照の割り当てターゲットとして使用できます。

@FunctionalInterfaceSE public interface MethodInterceptor extends Interceptor
ターゲットに向かう途中のインターフェース上のコールをインターセプトします。これらはターゲットの「上」にネストされます。

ユーザーは、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

      @Nullable ObjectSE invoke(@Nonnull MethodInvocation invocation) throws ThrowableSE
      このメソッドを実装して、呼び出しの前後に追加の処理を実行します。正しい実装としては、必ず Joinpoint.proceed() を呼び出すようにします。
      パラメーター:
      invocation - メソッド呼び出しジョインポイント
      戻り値:
      Joinpoint.proceed() の呼び出しの結果。インターセプターによってインターセプトされる可能性があります
      例外:
      ThrowableSE - インターセプターまたはターゲットオブジェクトが例外をスローする場合