public void refresh() throws BeansException, IllegalStateException {
synchronized (this.startupShutdownMonitor) {
// Prepare this context for refreshing.
prepareRefresh();
// Tell the subclass to refresh the internal bean factory.
ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();
// Prepare the bean factory for use in this context.
prepareBeanFactory(beanFactory);
try {
// Allows post-processing of the bean factory in context subclasses.
//后置处理bean工厂,可以在某些上下文实现中加特点的后置处理器,比如AbstractRefreshableWebApplicationContext中加入ServletContextAwareProcessor处理器和依赖忽略接口ServletContextAware。
postProcessBeanFactory(beanFactory);
// Invoke factory processors registered as beans in the context.