|
|
|
@ -46,7 +46,7 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu |
|
|
|
|
|
|
|
|
|
|
|
private BeanFactory beanFactory; |
|
|
|
private BeanFactory beanFactory; |
|
|
|
|
|
|
|
|
|
|
|
private transient Advice advice; |
|
|
|
private transient volatile Advice advice; |
|
|
|
|
|
|
|
|
|
|
|
private transient volatile Object adviceMonitor = new Object(); |
|
|
|
private transient volatile Object adviceMonitor = new Object(); |
|
|
|
|
|
|
|
|
|
|
|
@ -98,14 +98,30 @@ public abstract class AbstractBeanFactoryPointcutAdvisor extends AbstractPointcu |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Advice getAdvice() { |
|
|
|
public Advice getAdvice() { |
|
|
|
synchronized (this.adviceMonitor) { |
|
|
|
Advice advice = this.advice; |
|
|
|
if (this.advice == null && this.adviceBeanName != null) { |
|
|
|
if (advice != null || this.adviceBeanName == null) { |
|
|
|
|
|
|
|
return advice; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Assert.state(this.beanFactory != null, "BeanFactory must be set to resolve 'adviceBeanName'"); |
|
|
|
Assert.state(this.beanFactory != null, "BeanFactory must be set to resolve 'adviceBeanName'"); |
|
|
|
|
|
|
|
if (this.beanFactory.isSingleton(this.adviceBeanName)) { |
|
|
|
|
|
|
|
// Rely on singleton semantics provided by the factory.
|
|
|
|
|
|
|
|
advice = this.beanFactory.getBean(this.adviceBeanName, Advice.class); |
|
|
|
|
|
|
|
this.advice = advice; |
|
|
|
|
|
|
|
return advice; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
// No singleton guarantees from the factory -> let's lock locally but
|
|
|
|
|
|
|
|
// reuse the factory's singleton lock, just in case a lazy dependency
|
|
|
|
|
|
|
|
// of our advice bean happens to trigger the singleton lock implicitly...
|
|
|
|
|
|
|
|
synchronized (this.adviceMonitor) { |
|
|
|
|
|
|
|
if (this.advice == null) { |
|
|
|
this.advice = this.beanFactory.getBean(this.adviceBeanName, Advice.class); |
|
|
|
this.advice = this.beanFactory.getBean(this.adviceBeanName, Advice.class); |
|
|
|
} |
|
|
|
} |
|
|
|
return this.advice; |
|
|
|
return this.advice; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String toString() { |
|
|
|
public String toString() { |
|
|
|
|