クラス BeanOverrideHandler

java.lang.ObjectSE
org.springframework.test.context.bean.override.BeanOverrideHandler

public abstract class BeanOverrideHandler extends ObjectSE
指定されたメタデータセットの Bean オーバーライドインスタンスを作成し、作成されたインスタンスを追跡するロールを担う、Bean オーバーライドインジェクションポイントのハンドラー。

警告 : 実装はキャッシュキーとして使用され、オーバーライドする Bean を識別するために使用される一意のメタデータセットに基づいて適切な equals() および hashCode() メソッドを実装する必要があります。オーバーライドされた equals() および hashCode() メソッドは、すべての Bean オーバーライドで使用される基本メタデータをサポートするために、このクラスの super 実装にも委譲する必要があります。さらに、診断を強化するために、実装で toString() をオーバーライドして、関連するすべてのメタデータを含めることをお勧めします。

BeanOverrideHandler の具体的な実装では、オーバーライドインスタンスの作成中に使用する追加のメタデータを保存できます (たとえば、アノテーション、アノテーション付きフィールド、アノテーション付きクラスの追加処理に基づいて保存できます)。

注意 : オーバーライドできるのはシングルトン Bean のみです。非シングルトン Bean をオーバーライドしようとすると、例外が発生します。

導入:
6.2
作成者:
Simon Basl é , Stephane Nicoll, Sam Brannen
  • コンストラクターの詳細

  • メソッドの詳細

    • forTestClass

      public static ListSE<BeanOverrideHandler> forTestClass(ClassSE<?> testClass)
      指定された testClass を処理し、テストクラスとその型階層の @BeanOverride フィールドから派生した対応する BeanOverrideHandler リストを構築します。

      このメソッドは、囲むクラス階層を検索せず、クラスまたはインターフェース上の @BeanOverride 宣言を検索しません。

      パラメーター:
      testClass - 処理するテストクラス
      戻り値:
      Bean オーバーライドハンドラーのリスト
      関連事項:
      • findAllHandlers(Class)
    • getField

      @Nullable public final FieldSE getField()
      Get the FieldSE annotated with @BeanOverride
    • getBeanType

      public final ResolvableType getBeanType()
      オーバーライドする Beanを取得します。
    • getBeanName

      @Nullable public final StringSE getBeanName()
      上書きする Bean 名を取得するか、型 getBeanType() の一致する単一の Bean を検索するために null を取得します。
    • getContextName

      public final StringSE getContextName()
      Get the name of the context hierarchy level in which this handler should be applied.

      An empty string indicates that this handler should be applied to all application contexts.

      If a context name is configured for this handler, it must match a name configured via @ContextConfiguration(name=...).

      導入:
      6.2.6
      関連事項:
    • getStrategy

      public final BeanOverrideStrategy getStrategy()
      この BeanOverrideHandlerBeanOverrideStrategy を取得します。これは、Bean オーバーライドインスタンスを作成する方法とタイミングに影響します。
    • createOverrideInstance

      protected abstract ObjectSE createOverrideInstance(StringSE beanName, @Nullable BeanDefinition existingBeanDefinition, @Nullable ObjectSE existingBeanInstance)
      この BeanOverrideHandler のメタデータに基づいて、既存の BeanDefinition または既存のシングルトン Bean の Bean オーバーライドインスタンスを作成します。
      パラメーター:
      beanName - 上書きされる Bean の名前
      existingBeanDefinition - 指定された Bean 名に対する既存の Bean 定義、または利用できないか関連がない場合は null 
      existingBeanInstance - 折り返しの目的で提供された Bean 名の既存のインスタンス、または利用できないか関連がない場合は null 
      戻り値:
      Bean をオーバーライドするインスタンス
      関連事項:
    • trackOverrideInstance

      protected void trackOverrideInstance(ObjectSE override, SingletonBeanRegistry singletonBeanRegistry)
      この BeanOverrideHandler によって作成された、提供された Bean オーバーライドインスタンスを追跡します。

      デフォルトの実装では、提供されたインスタンスを追跡しませんが、必要に応じてサブクラスでオーバーライドできます。

      パラメーター:
      override - 追跡する Bean オーバーライドインスタンス
      singletonBeanRegistry - このハンドラーがシングルトン Bean の形式で追跡状態を保存できるレジストリ
      関連事項:
    • equals

      public boolean equals(ObjectSE other)
      オーバーライド:
      クラス ObjectSEequalsSE 
    • hashCode

      public int hashCode()
      オーバーライド:
      クラス ObjectSEhashCode 
    • toString

      public StringSE toString()
      オーバーライド:
      クラス ObjectSEtoString