public class ControllerAdviceBean extends java.lang.Object implements Ordered
The findAnnotatedBeans(ApplicationContext)
method can be used to discover
such beans. However, an ControllerAdviceBean
may be created from
any object, including ones without an @ControllerAdvice
.
Modifier and Type | Field and Description |
---|---|
private java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> |
annotations |
private java.util.List<java.lang.Class<?>> |
assignableTypes |
private java.util.List<java.lang.Package> |
basePackages |
private java.lang.Object |
bean |
private BeanFactory |
beanFactory |
private static Log |
logger |
private int |
order |
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
ControllerAdviceBean(java.lang.Object bean)
Create an instance using the given bean instance.
|
ControllerAdviceBean(java.lang.String beanName,
BeanFactory beanFactory)
Create an instance using the given bean name.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
static java.util.List<ControllerAdviceBean> |
findAnnotatedBeans(ApplicationContext applicationContext)
Find the names of beans annotated with
@ControllerAdvice in the given
ApplicationContext and wrap them as
ControllerAdviceBean instances. |
java.lang.Class<?> |
getBeanType()
Returns the type of the contained bean.
|
int |
getOrder()
Returns the order value extracted from the
ControllerAdvice
annotation or Ordered.LOWEST_PRECEDENCE otherwise. |
int |
hashCode() |
private boolean |
hasSelectors() |
private static java.util.List<java.lang.Package> |
initBasePackagesFromBeanType(java.lang.Class<?> beanType,
ControllerAdvice annotation) |
private static int |
initOrderFromBean(java.lang.Object bean) |
private static int |
initOrderFromBeanType(java.lang.Class<?> beanType) |
boolean |
isApplicableToBeanType(java.lang.Class<?> beanType)
Checks whether the given bean type should be assisted by this
@ControllerAdvice instance. |
java.lang.Object |
resolveBean()
Return a bean instance if necessary resolving the bean name through the BeanFactory.
|
java.lang.String |
toString() |
private static final Log logger
private final java.lang.Object bean
private final int order
private final BeanFactory beanFactory
private final java.util.List<java.lang.Package> basePackages
private final java.util.List<java.lang.Class<? extends java.lang.annotation.Annotation>> annotations
private final java.util.List<java.lang.Class<?>> assignableTypes
public ControllerAdviceBean(java.lang.String beanName, BeanFactory beanFactory)
beanName
- the name of the beanbeanFactory
- a BeanFactory that can be used later to resolve the beanpublic ControllerAdviceBean(java.lang.Object bean)
bean
- the beanpublic int getOrder()
ControllerAdvice
annotation or Ordered.LOWEST_PRECEDENCE
otherwise.public java.lang.Class<?> getBeanType()
public java.lang.Object resolveBean()
public boolean isApplicableToBeanType(java.lang.Class<?> beanType)
@ControllerAdvice
instance.beanType
- the type of the bean to checkControllerAdvice
private boolean hasSelectors()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static java.util.List<ControllerAdviceBean> findAnnotatedBeans(ApplicationContext applicationContext)
ControllerAdviceBean
instances.private static int initOrderFromBean(java.lang.Object bean)
private static int initOrderFromBeanType(java.lang.Class<?> beanType)
private static java.util.List<java.lang.Package> initBasePackagesFromBeanType(java.lang.Class<?> beanType, ControllerAdvice annotation)