Spring源码-ApplicationContext-源码解读

/**
 * Central interface to provide configuration for an application.	主要的接口提供配置给一个 application
 * This is read-only while the application is running, but may be	当 application 运行时,它是仅读的,但是
 * reloaded if the implementation supports this.					实现支持,可能实现重新加载
 *
 * <p>An ApplicationContext provides:								ApplicationContext 提供的
 * <ul>
 * <li>Bean factory methods for accessing application components.					1。用于访问 application 的组件的 Bean factory 方法
 * Inherited from {@link org.springframework.beans.factory.ListableBeanFactory}.	  继承自 ListableBeanFactory
 * <li>The ability to load file resources in a generic fashion.						2。以通用的方式加载资源文件的方式
 * Inherited from the {@link org.springframework.core.io.ResourceLoader} interface.   继承自 ResourceLoader
 * <li>The ability to publish events to registered listeners.						3。将事件发布到已经注册的监听器的能力
 * Inherited from the {@link ApplicationEventPublisher} interface.					  继承自 ApplicationEventPublisher
 * <li>The ability to resolve messages, supporting internationalization.			4。解析信息的能力,支持国际化
 * Inherited from the {@link MessageSource} interface.								  继承自 MessageSource 接口
 * <li>Inheritance from a parent context. Definitions in a descendant context		5。继承自父 context。 后代 context 中的定义将总是优先
 * will always take priority. This means, for example, that a single parent			  这意味着,例如,整个 web application 都可以使用单例 context
 * context can be used by an entire web application, while each servlet has			  被使用,每一个 servlet
 * its own child context that is independent of that of any other servlet.			  都有它自己的子上下文,独立于其他的任何 servlet
 * </ul>
 *
 * <p>In addition to standard {@link org.springframework.beans.factory.BeanFactory}	除了标准的 BeanFactory 生命周期能力
 * lifecycle capabilities, ApplicationContext implementations detect and invoke		ApplicationContext 实现能够检测并执行 ApplicationContextAware bean
 * {@link ApplicationContextAware} beans as well as {@link ResourceLoaderAware},	和 ResourceLoaderAware,ApplicationEventPublisherAware,MessageSourceAware bean
 * {@link ApplicationEventPublisherAware} and {@link MessageSourceAware} beans.
 *
 * @author Rod Johnson
 * @author Juergen Hoeller
 * @see ConfigurableApplicationContext
 * @see org.springframework.beans.factory.BeanFactory
 * @see org.springframework.core.io.ResourceLoader
 */
public interface ApplicationContext extends EnvironmentCapable, ListableBeanFactory, HierarchicalBeanFactory,
		MessageSource, ApplicationEventPublisher, ResourcePatternResolver {

	/**
	 * Return the unique id of this application context.
	 * @return the unique id of the context, or {@code null} if none
	 * 返回这个 application context. 的唯一 id
	 */
	@Nullable
	String getId();

	/**
	 * Return a name for the deployed application that this context belongs to.
	 * @return a name for the deployed application, or the empty String by default
	 * 为已经部署的 context 返回一个专属的 application 名字,
	 */
	String getApplicationName();

	/**
	 * Return a friendly name for this context.
	 * @return a display name for this context (never {@code null})
	 * 为 context 返回一个友好的名字
	 */
	String getDisplayName();

	/**
	 * Return the timestamp when this context was first loaded.
	 * @return the timestamp (ms) when this context was first loaded
	 * 返回这个 context 第一次登陆的时间戳
	 */
	long getStartupDate();

	/**
	 * Return the parent context, or {@code null} if there is no parent
	 * and this is the root of the context hierarchy.
	 * @return the parent context, or {@code null} if there is no parent
	 * 返回父 context,如果没有父上下文,并且他是层次结构的根返回 null
	 */
	@Nullable
	ApplicationContext getParent();

	/**
	 * Expose AutowireCapableBeanFactory functionality for this context.				为这个 context 暴露 AutowireCapableBeanFactory 功能
	 * <p>This is not typically used by application code, except for the purpose of		这 通常不被 application 代码所使用,
	 * initializing bean instances that live outside of the application context,		除非用于初始化位于应用程序上下文之外的bean实例
	 * applying the Spring bean lifecycle (fully or partly) to them.					将 Spring bean 的生命周期(全部/部分)应用到他们身上
	 * <p>Alternatively, the internal BeanFactory exposed by the						或者,凭借 ConfigurableApplicationContext 接口内部的 BeanFactory
	 * {@link ConfigurableApplicationContext} interface offers access to the			去提供 AutowireCapableBeanFactory 接口的访问。
	 * {@link AutowireCapableBeanFactory} interface too. The present method mainly		目前这个方法主要为了
	 * serves as a convenient, specific facility on the ApplicationContext interface.	ApplicationContext 之上方便特定的工具
	 * <p><b>NOTE: As of 4.2, this method will consistently throw IllegalStateException	批注:4.2 版本,在 application context 被关闭以后这个方法将一贯的抛出 IllegalStateException
	 * after the application context has been closed.</b> In current Spring Framework	在当前的 Spring Framework 版本中
	 * versions, only refreshable application contexts behave that way; as of 4.2,		仅可刷新的 application contexts 才能以这种形式运行,
	 * all application context implementations will be required to comply.				4.2 所有的 application context 将必须遵守
	 * @return the AutowireCapableBeanFactory for this context							这个 context 的 AutowireCapableBeanFactory
	 * @throws IllegalStateException if the context does not support the
	 * {@link AutowireCapableBeanFactory} interface, or does not hold an
	 * autowire-capable bean factory yet (e.g. if {@code refresh()} has
	 * never been called), or if the context has been closed already
	 * @see ConfigurableApplicationContext#refresh()
	 * @see ConfigurableApplicationContext#getBeanFactory()
	 */
	AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException;

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值