パッケージ org.aopalliance.intercept

インターフェース ConstructorInterceptor

すべてのスーパーインターフェース:
AdviceInterceptor

public interface ConstructorInterceptor extends Interceptor
新しいオブジェクトの構築をインターセプトします。

ユーザーは、construct(ConstructorInvocation) メソッドを実装して、元の動作を変更する必要があります。例: 次のクラスはシングルトンインターセプターを実装します(インターセプトされたクラスに一意のインスタンスを 1 つだけ許可します)。

 class DebuggingInterceptor implements ConstructorInterceptor {
   Object instance=null;

   Object construct(ConstructorInvocation i) throws Throwable {
     if(instance==null) {
       return instance=i.proceed();
     } else {
       throw new Exception("singleton does not allow multiple instance");
     }
   }
 }
 
作成者:
Rod Johnson
  • メソッドのサマリー

    修飾子と型
    メソッド
    説明
    このメソッドを実装して、新しいオブジェクトの構築の前後に追加の処理を実行します。
  • メソッドの詳細

    • construct

      @Nonnull ObjectSE construct(ConstructorInvocation invocation) throws ThrowableSE
      このメソッドを実装して、新しいオブジェクトの構築の前後に追加の処理を実行します。ポライトインプリメンテーションは、確実に Joinpoint.proceed() を呼び出します。
      パラメーター:
      invocation - ビルドジョインポイント
      戻り値:
      新しく作成されたオブジェクト。これも Joinpoint.proceed() の呼び出しの結果です。インターセプターに置き換えられる可能性があります
      例外:
      ThrowableSE - インターセプターまたはターゲットオブジェクトが例外をスローする場合