AbstractApplicationContext 笔记

一、这个类的属性

public abstract class AbstractApplicationContext extends DefaultResourceLoader
        implements ConfigurableApplicationContext, DisposableBean {

    /**
     * Name of the MessageSource bean in the factory.
     * If none is supplied, message resolution is delegated to the parent.
     * @see MessageSource
     */
//Bean工厂中MessageSource接口的Bean实例的名称。
public static final String MESSAGE_SOURCE_BEAN_NAME = "messageSource"; /** * Name of the LifecycleProcessor bean in the factory. * If none is supplied, a DefaultLifecycleProcessor is used. * @see org.springframework.context.LifecycleProcessor * @see org.springframework.context.support.DefaultLifecycleProcessor *///LifecycleProcessor 接口的bean实例,如果没有提供的话就使用默认的DefaultLifecycleProcessor public static final String LIFECYCLE_PROCESSOR_BEAN_NAME = "lifecycleProcessor"; /** * Name of the ApplicationEventMulticaster bean in the factory. * If none is supplied, a default SimpleApplicationEventMulticaster is used. * @see org.springframework.context.event.ApplicationEventMulticaster * @see org.springframework.context.event.SimpleApplicationEventMulticaster *///事件广播器ApplicationEventMulticaster接口的一个bean实例。如果没有提供的话就使用SimpleApplicationEventMulticaster public static final String APPLICATION_EVENT_MULTICASTER_BEAN_NAME = "applicationEventMulticaster"; static { // Eagerly load the ContextClosedEvent class to avoid weird classloader issues // on application shutdown in WebLogic 8.1. (Reported by Dustin Woods.) ContextClosedEvent.class.getName(); } /** Logger used by this class. Available to subclasses. *///logger用来打印日志的。 protected final Log logger = LogFactory.getLog(getClass()); /** Unique id for this context, if any *///这个应用上下文的id private String id = ObjectUtils.identityToString(this); /** Display name *///这个应用上下文(ApplicationContext)的名称,由这个类的 类名+ @ + 这个context对象的hash值 组成。 private String displayName = ObjectUtils.identityToString(this); /** Parent context *///父context private ApplicationContext parent; /** Environment used by this context */
    //context需要使用到的Environment对象。这个对象的作用是操作属性来源。包括添加、移除、重新排序、替换等。
    private ConfigurableEnvironment environment;

    /** BeanFactoryPostProcessors to apply on refresh *///这个List用于存放Bean工厂处理器(BeanFactoryPostProcessor)。
    private final List<BeanFactoryPostProcessor> beanFactoryPostProcessors =
            new ArrayList<BeanFactoryPostProcessor>();

    /** System time in milliseconds when this context started */
    private long startupDate;//context的启动时间。毫秒为单位。long 型变量。

    /** Flag that indicates whether this context is currently active *///active表示的当前context是否正处于的活动状态。
    private final AtomicBoolean active = new AtomicBoolean();

    /** Flag that indicates whether this context has been closed already *///closed表示当前的context是否已经关闭。
    private final AtomicBoolean closed = new AtomicBoolean();

    /** Synchronization monitor for the "refresh" and "destroy" *///这个对象用在refresh()和destroy()方法中的synchronized块。起到对象锁的作用。
    private final Object startupShutdownMonitor = new Object();

    /** Reference to the JVM shutdown hook, if registered */
    private Thread shutdownHook;//JVM关闭的钩子。

    /** ResourcePatternResolver used by this context *///这个是策略接口(涉及到策略模式),用于加载资源,比如类路径下的xml文件,或者是文件系统中的文件。
    private ResourcePatternResolver resourcePatternResolver;

    /** LifecycleProcessor for managing the lifecycle of beans within this context */
    private LifecycleProcessor lifecycleProcessor;//生命周期处理器,用来管理context中具有生命周期的bean。

    /** MessageSource we delegate our implementation of this interface to */
    private MessageSource messageSource;//这也是一个策略接口,用于国际化方面的。

    /** Helper class used in event publishing *///事件广播器,用来发布事件,将事件告诉监听器的。
    private ApplicationEventMulticaster applicationEventMulticaster;

    /** Statically specified listeners *///用来存储监听器的。
    private final Set<ApplicationListener<?>> applicationListeners = new LinkedHashSet<ApplicationListener<?>>();

    /** ApplicationEvents published early *///用来存储事件的。
    private Set<ApplicationEvent> earlyApplicationEvents;

 

posted @ 2018-01-03 01:59  钓鱼翁  阅读(2174)  评论(0编辑  收藏  举报