@ -228,14 +228,26 @@ public class ControllerAdviceBean implements Ordered {
* instances .
* instances .
* < p > Note that the { @code ControllerAdviceBean } instances in the returned list
* < p > Note that the { @code ControllerAdviceBean } instances in the returned list
* are sorted using { @link OrderComparator # sort ( List ) } .
* are sorted using { @link OrderComparator # sort ( List ) } .
* @see # findAnnotatedBeans ( ListableBeanFactory )
* /
public static List < ControllerAdviceBean > findAnnotatedBeans ( ApplicationContext context ) {
return findAnnotatedBeans ( ( ListableBeanFactory ) context ) ;
}
/ * *
* Find beans annotated with { @link ControllerAdvice @ControllerAdvice } in the
* given { @link ListableBeanFactory } and wrap them as { @code ControllerAdviceBean }
* instances .
* < p > Note that the { @code ControllerAdviceBean } instances in the returned list
* are sorted using { @link OrderComparator # sort ( List ) } .
* @since 7 . 0
* @see # getOrder ( )
* @see # getOrder ( )
* @see OrderComparator
* @see OrderComparator
* @see Ordered
* @see Ordered
* /
* /
public static List < ControllerAdviceBean > findAnnotatedBeans ( ApplicationContext context ) {
public static List < ControllerAdviceBean > findAnnotatedBeans ( ListableBeanFactory beanFactory ) {
ListableBeanFactory beanFactory = context ;
if ( beanFactory instanceof ConfigurableApplicationContext cac ) {
if ( context instanceof ConfigurableApplicationContext cac ) {
// Use internal BeanFactory for potential downcast to ConfigurableBeanFactory in getOrder().
// Use internal BeanFactory for potential downcast to ConfigurableBeanFactory above
beanFactory = cac . getBeanFactory ( ) ;
beanFactory = cac . getBeanFactory ( ) ;
}
}
List < ControllerAdviceBean > adviceBeans = new ArrayList < > ( ) ;
List < ControllerAdviceBean > adviceBeans = new ArrayList < > ( ) ;