|
|
|
@ -157,7 +157,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -157,7 +157,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
|
|
|
|
|
/** Cache of pre-filtered post-processors. */ |
|
|
|
|
@Nullable |
|
|
|
|
private volatile BeanPostProcessorCache beanPostProcessorCache; |
|
|
|
|
private BeanPostProcessorCache beanPostProcessorCache; |
|
|
|
|
|
|
|
|
|
/** Map from scope identifier String to corresponding Scope. */ |
|
|
|
|
private final Map<String, Scope> scopes = new LinkedHashMap<>(8); |
|
|
|
@ -926,10 +926,12 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -926,10 +926,12 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
@Override |
|
|
|
|
public void addBeanPostProcessor(BeanPostProcessor beanPostProcessor) { |
|
|
|
|
Assert.notNull(beanPostProcessor, "BeanPostProcessor must not be null"); |
|
|
|
|
// Remove from old position, if any
|
|
|
|
|
this.beanPostProcessors.remove(beanPostProcessor); |
|
|
|
|
// Add to end of list
|
|
|
|
|
this.beanPostProcessors.add(beanPostProcessor); |
|
|
|
|
synchronized (this.beanPostProcessors) { |
|
|
|
|
// Remove from old position, if any
|
|
|
|
|
this.beanPostProcessors.remove(beanPostProcessor); |
|
|
|
|
// Add to end of list
|
|
|
|
|
this.beanPostProcessors.add(beanPostProcessor); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -939,8 +941,12 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -939,8 +941,12 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
* @see #addBeanPostProcessor |
|
|
|
|
*/ |
|
|
|
|
public void addBeanPostProcessors(Collection<? extends BeanPostProcessor> beanPostProcessors) { |
|
|
|
|
this.beanPostProcessors.removeAll(beanPostProcessors); |
|
|
|
|
this.beanPostProcessors.addAll(beanPostProcessors); |
|
|
|
|
synchronized (this.beanPostProcessors) { |
|
|
|
|
// Remove from old position, if any
|
|
|
|
|
this.beanPostProcessors.removeAll(beanPostProcessors); |
|
|
|
|
// Add to end of list
|
|
|
|
|
this.beanPostProcessors.addAll(beanPostProcessors); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -962,26 +968,34 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -962,26 +968,34 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
* @since 5.3 |
|
|
|
|
*/ |
|
|
|
|
BeanPostProcessorCache getBeanPostProcessorCache() { |
|
|
|
|
BeanPostProcessorCache bppCache = this.beanPostProcessorCache; |
|
|
|
|
if (bppCache == null) { |
|
|
|
|
bppCache = new BeanPostProcessorCache(); |
|
|
|
|
for (BeanPostProcessor bpp : this.beanPostProcessors) { |
|
|
|
|
if (bpp instanceof InstantiationAwareBeanPostProcessor instantiationAwareBpp) { |
|
|
|
|
bppCache.instantiationAware.add(instantiationAwareBpp); |
|
|
|
|
if (bpp instanceof SmartInstantiationAwareBeanPostProcessor smartInstantiationAwareBpp) { |
|
|
|
|
bppCache.smartInstantiationAware.add(smartInstantiationAwareBpp); |
|
|
|
|
synchronized (this.beanPostProcessors) { |
|
|
|
|
BeanPostProcessorCache bppCache = this.beanPostProcessorCache; |
|
|
|
|
if (bppCache == null) { |
|
|
|
|
bppCache = new BeanPostProcessorCache(); |
|
|
|
|
for (BeanPostProcessor bpp : this.beanPostProcessors) { |
|
|
|
|
if (bpp instanceof InstantiationAwareBeanPostProcessor instantiationAwareBpp) { |
|
|
|
|
bppCache.instantiationAware.add(instantiationAwareBpp); |
|
|
|
|
if (bpp instanceof SmartInstantiationAwareBeanPostProcessor smartInstantiationAwareBpp) { |
|
|
|
|
bppCache.smartInstantiationAware.add(smartInstantiationAwareBpp); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (bpp instanceof DestructionAwareBeanPostProcessor destructionAwareBpp) { |
|
|
|
|
bppCache.destructionAware.add(destructionAwareBpp); |
|
|
|
|
} |
|
|
|
|
if (bpp instanceof MergedBeanDefinitionPostProcessor mergedBeanDefBpp) { |
|
|
|
|
bppCache.mergedDefinition.add(mergedBeanDefBpp); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (bpp instanceof DestructionAwareBeanPostProcessor destructionAwareBpp) { |
|
|
|
|
bppCache.destructionAware.add(destructionAwareBpp); |
|
|
|
|
} |
|
|
|
|
if (bpp instanceof MergedBeanDefinitionPostProcessor mergedBeanDefBpp) { |
|
|
|
|
bppCache.mergedDefinition.add(mergedBeanDefBpp); |
|
|
|
|
} |
|
|
|
|
this.beanPostProcessorCache = bppCache; |
|
|
|
|
} |
|
|
|
|
this.beanPostProcessorCache = bppCache; |
|
|
|
|
return bppCache; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void resetBeanPostProcessorCache() { |
|
|
|
|
synchronized (this.beanPostProcessors) { |
|
|
|
|
this.beanPostProcessorCache = null; |
|
|
|
|
} |
|
|
|
|
return bppCache; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -1937,27 +1951,27 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -1937,27 +1951,27 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
@Override |
|
|
|
|
public BeanPostProcessor set(int index, BeanPostProcessor element) { |
|
|
|
|
BeanPostProcessor result = super.set(index, element); |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public boolean add(BeanPostProcessor o) { |
|
|
|
|
boolean success = super.add(o); |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
return success; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void add(int index, BeanPostProcessor element) { |
|
|
|
|
super.add(index, element); |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public BeanPostProcessor remove(int index) { |
|
|
|
|
BeanPostProcessor result = super.remove(index); |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1965,7 +1979,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -1965,7 +1979,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
public boolean remove(Object o) { |
|
|
|
|
boolean success = super.remove(o); |
|
|
|
|
if (success) { |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
} |
|
|
|
|
return success; |
|
|
|
|
} |
|
|
|
@ -1974,7 +1988,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -1974,7 +1988,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
public boolean removeAll(Collection<?> c) { |
|
|
|
|
boolean success = super.removeAll(c); |
|
|
|
|
if (success) { |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
} |
|
|
|
|
return success; |
|
|
|
|
} |
|
|
|
@ -1983,7 +1997,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -1983,7 +1997,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
public boolean retainAll(Collection<?> c) { |
|
|
|
|
boolean success = super.retainAll(c); |
|
|
|
|
if (success) { |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
} |
|
|
|
|
return success; |
|
|
|
|
} |
|
|
|
@ -1992,7 +2006,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -1992,7 +2006,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
public boolean addAll(Collection<? extends BeanPostProcessor> c) { |
|
|
|
|
boolean success = super.addAll(c); |
|
|
|
|
if (success) { |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
} |
|
|
|
|
return success; |
|
|
|
|
} |
|
|
|
@ -2001,7 +2015,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -2001,7 +2015,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
public boolean addAll(int index, Collection<? extends BeanPostProcessor> c) { |
|
|
|
|
boolean success = super.addAll(index, c); |
|
|
|
|
if (success) { |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
} |
|
|
|
|
return success; |
|
|
|
|
} |
|
|
|
@ -2010,7 +2024,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -2010,7 +2024,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
public boolean removeIf(Predicate<? super BeanPostProcessor> filter) { |
|
|
|
|
boolean success = super.removeIf(filter); |
|
|
|
|
if (success) { |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
} |
|
|
|
|
return success; |
|
|
|
|
} |
|
|
|
@ -2018,7 +2032,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
@@ -2018,7 +2032,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|
|
|
|
@Override |
|
|
|
|
public void replaceAll(UnaryOperator<BeanPostProcessor> operator) { |
|
|
|
|
super.replaceAll(operator); |
|
|
|
|
beanPostProcessorCache = null; |
|
|
|
|
resetBeanPostProcessorCache(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|