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");
}
}
}
| 修飾子と型 | メソッドと説明 |
|---|---|
ObjectSE | construct(ConstructorInvocation invocation) このメソッドを実装して、新しいオブジェクトの構築の前後に追加の処理を実行します。 |
ObjectSE construct(ConstructorInvocation invocation) throws ThrowableSE
Joinpoint.proceed() を呼び出します。invocation - ビルドジョインポイント Joinpoint.proceed() の呼び出しの結果です。インターセプターに置き換えられる可能性があります ThrowableSE - インターセプターまたはターゲットオブジェクトが例外をスローする場合