@@ -439,7 +439,8 @@ public Object applyBeanPostProcessorsAfterInitialization(Object existingBean, St
439
439
440
440
@ Override
441
441
public void destroyBean (Object existingBean ) {
442
- new DisposableBeanAdapter (existingBean , getBeanPostProcessors (), getAccessControlContext ()).destroy ();
442
+ new DisposableBeanAdapter (
443
+ existingBean , getBeanPostProcessorCache ().destructionAware , getAccessControlContext ()).destroy ();
443
444
}
444
445
445
446
@@ -651,14 +652,11 @@ protected Class<?> predictBeanType(String beanName, RootBeanDefinition mbd, Clas
651
652
// eventual type after a before-instantiation shortcut.
652
653
if (targetType != null && !mbd .isSynthetic () && hasInstantiationAwareBeanPostProcessors ()) {
653
654
boolean matchingOnlyFactoryBean = typesToMatch .length == 1 && typesToMatch [0 ] == FactoryBean .class ;
654
- for (BeanPostProcessor bp : getBeanPostProcessors ()) {
655
- if (bp instanceof SmartInstantiationAwareBeanPostProcessor ) {
656
- SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor ) bp ;
657
- Class <?> predicted = ibp .predictBeanType (targetType , beanName );
658
- if (predicted != null &&
659
- (!matchingOnlyFactoryBean || FactoryBean .class .isAssignableFrom (predicted ))) {
660
- return predicted ;
661
- }
655
+ for (SmartInstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache ().smartInstantiationAware ) {
656
+ Class <?> predicted = bp .predictBeanType (targetType , beanName );
657
+ if (predicted != null &&
658
+ (!matchingOnlyFactoryBean || FactoryBean .class .isAssignableFrom (predicted ))) {
659
+ return predicted ;
662
660
}
663
661
}
664
662
}
@@ -959,11 +957,8 @@ protected Class<?> getTypeForFactoryBean(String beanName, RootBeanDefinition mbd
959
957
protected Object getEarlyBeanReference (String beanName , RootBeanDefinition mbd , Object bean ) {
960
958
Object exposedObject = bean ;
961
959
if (!mbd .isSynthetic () && hasInstantiationAwareBeanPostProcessors ()) {
962
- for (BeanPostProcessor bp : getBeanPostProcessors ()) {
963
- if (bp instanceof SmartInstantiationAwareBeanPostProcessor ) {
964
- SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor ) bp ;
965
- exposedObject = ibp .getEarlyBeanReference (exposedObject , beanName );
966
- }
960
+ for (SmartInstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache ().smartInstantiationAware ) {
961
+ exposedObject = bp .getEarlyBeanReference (exposedObject , beanName );
967
962
}
968
963
}
969
964
return exposedObject ;
@@ -1088,11 +1083,8 @@ private FactoryBean<?> getNonSingletonFactoryBeanForTypeCheck(String beanName, R
1088
1083
* @see MergedBeanDefinitionPostProcessor#postProcessMergedBeanDefinition
1089
1084
*/
1090
1085
protected void applyMergedBeanDefinitionPostProcessors (RootBeanDefinition mbd , Class <?> beanType , String beanName ) {
1091
- for (BeanPostProcessor bp : getBeanPostProcessors ()) {
1092
- if (bp instanceof MergedBeanDefinitionPostProcessor ) {
1093
- MergedBeanDefinitionPostProcessor bdp = (MergedBeanDefinitionPostProcessor ) bp ;
1094
- bdp .postProcessMergedBeanDefinition (mbd , beanType , beanName );
1095
- }
1086
+ for (MergedBeanDefinitionPostProcessor processor : getBeanPostProcessorCache ().mergedDefinition ) {
1087
+ processor .postProcessMergedBeanDefinition (mbd , beanType , beanName );
1096
1088
}
1097
1089
}
1098
1090
@@ -1135,13 +1127,10 @@ protected Object resolveBeforeInstantiation(String beanName, RootBeanDefinition
1135
1127
*/
1136
1128
@ Nullable
1137
1129
protected Object applyBeanPostProcessorsBeforeInstantiation (Class <?> beanClass , String beanName ) {
1138
- for (BeanPostProcessor bp : getBeanPostProcessors ()) {
1139
- if (bp instanceof InstantiationAwareBeanPostProcessor ) {
1140
- InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor ) bp ;
1141
- Object result = ibp .postProcessBeforeInstantiation (beanClass , beanName );
1142
- if (result != null ) {
1143
- return result ;
1144
- }
1130
+ for (InstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache ().instantiationAware ) {
1131
+ Object result = bp .postProcessBeforeInstantiation (beanClass , beanName );
1132
+ if (result != null ) {
1133
+ return result ;
1145
1134
}
1146
1135
}
1147
1136
return null ;
@@ -1280,13 +1269,10 @@ protected Constructor<?>[] determineConstructorsFromBeanPostProcessors(@Nullable
1280
1269
throws BeansException {
1281
1270
1282
1271
if (beanClass != null && hasInstantiationAwareBeanPostProcessors ()) {
1283
- for (BeanPostProcessor bp : getBeanPostProcessors ()) {
1284
- if (bp instanceof SmartInstantiationAwareBeanPostProcessor ) {
1285
- SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor ) bp ;
1286
- Constructor <?>[] ctors = ibp .determineCandidateConstructors (beanClass , beanName );
1287
- if (ctors != null ) {
1288
- return ctors ;
1289
- }
1272
+ for (SmartInstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache ().smartInstantiationAware ) {
1273
+ Constructor <?>[] ctors = bp .determineCandidateConstructors (beanClass , beanName );
1274
+ if (ctors != null ) {
1275
+ return ctors ;
1290
1276
}
1291
1277
}
1292
1278
}
@@ -1382,12 +1368,9 @@ protected void populateBean(String beanName, RootBeanDefinition mbd, @Nullable B
1382
1368
// state of the bean before properties are set. This can be used, for example,
1383
1369
// to support styles of field injection.
1384
1370
if (!mbd .isSynthetic () && hasInstantiationAwareBeanPostProcessors ()) {
1385
- for (BeanPostProcessor bp : getBeanPostProcessors ()) {
1386
- if (bp instanceof InstantiationAwareBeanPostProcessor ) {
1387
- InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor ) bp ;
1388
- if (!ibp .postProcessAfterInstantiation (bw .getWrappedInstance (), beanName )) {
1389
- return ;
1390
- }
1371
+ for (InstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache ().instantiationAware ) {
1372
+ if (!bp .postProcessAfterInstantiation (bw .getWrappedInstance (), beanName )) {
1373
+ return ;
1391
1374
}
1392
1375
}
1393
1376
}
@@ -1416,21 +1399,18 @@ protected void populateBean(String beanName, RootBeanDefinition mbd, @Nullable B
1416
1399
if (pvs == null ) {
1417
1400
pvs = mbd .getPropertyValues ();
1418
1401
}
1419
- for (BeanPostProcessor bp : getBeanPostProcessors ()) {
1420
- if (bp instanceof InstantiationAwareBeanPostProcessor ) {
1421
- InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor ) bp ;
1422
- PropertyValues pvsToUse = ibp .postProcessProperties (pvs , bw .getWrappedInstance (), beanName );
1402
+ for (InstantiationAwareBeanPostProcessor bp : getBeanPostProcessorCache ().instantiationAware ) {
1403
+ PropertyValues pvsToUse = bp .postProcessProperties (pvs , bw .getWrappedInstance (), beanName );
1404
+ if (pvsToUse == null ) {
1405
+ if (filteredPds == null ) {
1406
+ filteredPds = filterPropertyDescriptorsForDependencyCheck (bw , mbd .allowCaching );
1407
+ }
1408
+ pvsToUse = bp .postProcessPropertyValues (pvs , filteredPds , bw .getWrappedInstance (), beanName );
1423
1409
if (pvsToUse == null ) {
1424
- if (filteredPds == null ) {
1425
- filteredPds = filterPropertyDescriptorsForDependencyCheck (bw , mbd .allowCaching );
1426
- }
1427
- pvsToUse = ibp .postProcessPropertyValues (pvs , filteredPds , bw .getWrappedInstance (), beanName );
1428
- if (pvsToUse == null ) {
1429
- return ;
1430
- }
1410
+ return ;
1431
1411
}
1432
- pvs = pvsToUse ;
1433
1412
}
1413
+ pvs = pvsToUse ;
1434
1414
}
1435
1415
}
1436
1416
if (needsDepCheck ) {
0 commit comments