org.springframework.web.method

Class ControllerAdviceBean

  • java.lang.Object
    • org.springframework.web.method.ControllerAdviceBean
  • All Implemented Interfaces:
    Ordered


    public class ControllerAdviceBean
    extends java.lang.Object
    implements Ordered
    Encapsulates information about an @ControllerAdvice Spring-managed bean without necessarily requiring it to be instantiated.

    The findAnnotatedBeans(ApplicationContext) method can be used to discover such beans. However, a ControllerAdviceBean may be created from any object, including ones without an @ControllerAdvice.

    Since:
    3.2
    Author:
    Rossen Stoyanchev, Brian Clozel, Juergen Hoeller
    • Constructor Detail

      • ControllerAdviceBean

        public ControllerAdviceBean(java.lang.Object bean)
        Create a ControllerAdviceBean using the given bean instance.
        Parameters:
        bean - the bean instance
      • ControllerAdviceBean

        public ControllerAdviceBean(java.lang.String beanName,
                                    @Nullable
                                    BeanFactory beanFactory)
        Create a ControllerAdviceBean using the given bean name.
        Parameters:
        beanName - the name of the bean
        beanFactory - a BeanFactory that can be used later to resolve the bean
    • Method Detail

      • getBeanType

        @Nullable
        public java.lang.Class<?> getBeanType()
        Return the type of the contained bean.

        If the bean type is a CGLIB-generated class, the original user-defined class is returned.

      • resolveBean

        public java.lang.Object resolveBean()
        Return a bean instance if necessary resolving the bean name through the BeanFactory.
      • isApplicableToBeanType

        public boolean isApplicableToBeanType(@Nullable
                                              java.lang.Class<?> beanType)
        Check whether the given bean type should be assisted by this @ControllerAdvice instance.
        Parameters:
        beanType - the type of the bean to check
        Since:
        4.0
        See Also:
        ControllerAdvice
      • equals

        public boolean equals(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object