@ -54,6 +54,7 @@ public class ControllerAdviceBean implements Ordered {
@@ -54,6 +54,7 @@ public class ControllerAdviceBean implements Ordered {
* /
private final Object beanOrName ;
private final boolean isSingletonBean ;
/ * *
* Reference to the resolved bean instance , potentially lazily retrieved
* via the { @code BeanFactory } .
@ -84,6 +85,7 @@ public class ControllerAdviceBean implements Ordered {
@@ -84,6 +85,7 @@ public class ControllerAdviceBean implements Ordered {
this . beanType = ClassUtils . getUserClass ( bean . getClass ( ) ) ;
this . beanTypePredicate = createBeanTypePredicate ( this . beanType ) ;
this . beanFactory = null ;
this . isSingletonBean = true ;
}
/ * *
@ -115,6 +117,7 @@ public class ControllerAdviceBean implements Ordered {
@@ -115,6 +117,7 @@ public class ControllerAdviceBean implements Ordered {
"] does not contain specified controller advice bean '" + beanName + "'" ) ;
this . beanOrName = beanName ;
this . isSingletonBean = beanFactory . isSingleton ( beanName ) ;
this . beanType = getBeanType ( beanName , beanFactory ) ;
this . beanTypePredicate = ( controllerAdvice ! = null ? createBeanTypePredicate ( controllerAdvice ) :
createBeanTypePredicate ( this . beanType ) ) ;
@ -191,7 +194,7 @@ public class ControllerAdviceBean implements Ordered {
@@ -191,7 +194,7 @@ public class ControllerAdviceBean implements Ordered {
* will be cached , thereby avoiding repeated lookups in the { @code BeanFactory } .
* /
public Object resolveBean ( ) {
if ( this . resolvedBean = = null ) {
if ( ! this . isSingletonBean | | this . resolvedBean = = null ) {
// this.beanOrName must be a String representing the bean name if
// this.resolvedBean is null.
this . resolvedBean = obtainBeanFactory ( ) . getBean ( ( String ) this . beanOrName ) ;