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