Spring 源码之核心加载方法(14) 完成后清理

14 AbstractApplicationContext#destroyBeans

定位: org.springframework.context.support.AbstractApplicationContext#destroyBeans

1
2
3
4
5
6
7
8
9
protected void destroyBeans() {
getBeanFactory().destroySingletons();
}

public void destroySingletons() {
super.destroySingletons();
updateManualSingletonNames(Set::clear, set -> !set.isEmpty());
clearByTypeCache();
}

15 AbstractApplicationContext#cancelRefresh

定位: org.springframework.context.support.AbstractApplicationContext#cancelRefresh

1
2
3
protected void cancelRefresh(BeansException ex) {
this.active.set(false);
}

16 AbstractApplicationContext#resetCommonCaches

定位: org.springframework.context.support.AbstractApplicationContext#resetCommonCaches

1
2
3
4
5
6
protected void resetCommonCaches() {
ReflectionUtils.clearCache();
AnnotationUtils.clearCache();
ResolvableType.clearCache();
CachedIntrospectionResults.clearClassLoader(getClassLoader());
}