クラス ControllerAdviceBean

java.lang.ObjectSE
org.springframework.web.method.ControllerAdviceBean
実装されたすべてのインターフェース:
Ordered

public class ControllerAdviceBean extends ObjectSE implements Ordered
必ずしもインスタンス化する必要なく、@ControllerAdvice Spring で管理される Bean に関する情報をカプセル化します。

findAnnotatedBeans(ApplicationContext) メソッドを使用すると、このような Bean を検出できます。ただし、ControllerAdviceBean は、@ControllerAdvice アノテーションのないオブジェクトを含め、任意のオブジェクトから作成できます。

導入:
3.2
作成者:
Rossen Stoyanchev, Brian Clozel, Juergen Hoeller, Sam Brannen
  • コンストラクターの詳細

    • ControllerAdviceBean

      public ControllerAdviceBean(ObjectSE bean)
      指定された Bean インスタンスを使用して ControllerAdviceBean を作成します。
      パラメーター:
      bean - Bean インスタンス
    • ControllerAdviceBean

      public ControllerAdviceBean(StringSE beanName, BeanFactory beanFactory)
      指定された Bean 名と BeanFactory を使用して ControllerAdviceBean を作成します。
      パラメーター:
      beanName - Bean の名前
      beanFactory - 最初に Bean 型を取得し、後で実際の Bean を解決する BeanFactory 
    • ControllerAdviceBean

      public ControllerAdviceBean(StringSE beanName, BeanFactory beanFactory, @Nullable ControllerAdvice controllerAdvice)
      指定された Bean 名、BeanFactory@ControllerAdvice アノテーションを使用して ControllerAdviceBean を作成します。
      パラメーター:
      beanName - Bean の名前
      beanFactory - 最初に Bean 型を取得し、後で実際の Bean を解決する BeanFactory 
      controllerAdvice - Bean の @ControllerAdvice アノテーション、またはまだ取得されていない場合は null 
      導入:
      5.2
  • メソッドの詳細

    • getOrder

      public int getOrder()
      含まれている Bean のオーダー値を取得します。

      Spring Framework 5.3 以降、オーダー値は次のアルゴリズムを使用して遅延検索され、キャッシュされます。ただし、スコープ付き Bean として構成されている @ControllerAdvice Bean- たとえば、リクエストスコープまたはセッションスコープの Bean として - 先行して解決されることはありません。Ordered は、スコープ付き @ControllerAdvice Bean には適用されません。

      次で指定:
      インターフェース OrderedgetOrder 
      戻り値:
      オーダー額
      関連事項:
    • getBeanType

      @Nullable public ClassSE<?> getBeanType()
      含まれている Bean の型を返します。

      Bean 型が CGLIB 生成クラスである場合、元のユーザー定義クラスが返されます。

    • resolveBean

      public ObjectSE resolveBean()
      この ControllerAdviceBean の Bean インスタンスを取得します。必要に応じて、BeanFactory を介して Bean 名を解決します。

      Spring Framework 5.2 の時点で、Bean インスタンスが解決されると、それがシングルトンの場合はキャッシュされるため、BeanFactory での繰り返しのルックアップが回避されます。

    • isApplicableToBeanType

      public boolean isApplicableToBeanType(@Nullable ClassSE<?> beanType)
      指定された Bean 型がこの ControllerAdviceBean によって通知される必要があるかどうかを確認します。
      パラメーター:
      beanType - チェックする Bean の型
      導入:
      4.0
      関連事項:
    • equals

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

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

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

      public static ListSE<ControllerAdviceBean> findAnnotatedBeans(ApplicationContext context)
      指定された ApplicationContext@ControllerAdvice のアノテーションが付けられた Bean を見つけ、ControllerAdviceBean インスタンスとしてラップします。

      Spring Framework 5.2 の時点で、返されるリスト内の ControllerAdviceBean インスタンスは、OrderComparator.sort(List) を使用してソートされます。

      関連事項: