|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
* Copyright 2002-2013 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
@ -81,24 +81,32 @@ public class BeanFactoryAdvisorRetrievalHelper { |
|
|
|
|
|
|
|
|
|
|
|
List<Advisor> advisors = new LinkedList<Advisor>(); |
|
|
|
List<Advisor> advisors = new LinkedList<Advisor>(); |
|
|
|
for (String name : advisorNames) { |
|
|
|
for (String name : advisorNames) { |
|
|
|
if (isEligibleBean(name) && !this.beanFactory.isCurrentlyInCreation(name)) { |
|
|
|
if (isEligibleBean(name)) { |
|
|
|
try { |
|
|
|
if (this.beanFactory.isCurrentlyInCreation(name)) { |
|
|
|
advisors.add(this.beanFactory.getBean(name, Advisor.class)); |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
|
|
|
|
logger.debug("Skipping currently created advisor '" + name + "'"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch (BeanCreationException ex) { |
|
|
|
else { |
|
|
|
Throwable rootCause = ex.getMostSpecificCause(); |
|
|
|
try { |
|
|
|
if (rootCause instanceof BeanCurrentlyInCreationException) { |
|
|
|
advisors.add(this.beanFactory.getBean(name, Advisor.class)); |
|
|
|
BeanCreationException bce = (BeanCreationException) rootCause; |
|
|
|
} |
|
|
|
if (this.beanFactory.isCurrentlyInCreation(bce.getBeanName())) { |
|
|
|
catch (BeanCreationException ex) { |
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
Throwable rootCause = ex.getMostSpecificCause(); |
|
|
|
logger.debug("Ignoring currently created advisor '" + name + "': " + ex.getMessage()); |
|
|
|
if (rootCause instanceof BeanCurrentlyInCreationException) { |
|
|
|
|
|
|
|
BeanCreationException bce = (BeanCreationException) rootCause; |
|
|
|
|
|
|
|
if (this.beanFactory.isCurrentlyInCreation(bce.getBeanName())) { |
|
|
|
|
|
|
|
if (logger.isDebugEnabled()) { |
|
|
|
|
|
|
|
logger.debug("Skipping advisor '" + name + |
|
|
|
|
|
|
|
"' with dependency on currently created bean: " + ex.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Ignore: indicates a reference back to the bean we're trying to advise.
|
|
|
|
|
|
|
|
// We want to find advisors other than the currently created bean itself.
|
|
|
|
|
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
// Ignore: indicates a reference back to the bean we're trying to advise.
|
|
|
|
|
|
|
|
// We want to find advisors other than the currently created bean itself.
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
throw ex; |
|
|
|
} |
|
|
|
} |
|
|
|
throw ex; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|