ApplicationContext解析

ApplicationContext解析_第1张图片

ApplicationContext 这个接口作为作为spring框架下最重要的一个接口他提供了能力结构图如上。

他自己提供了以下方法

public interface ApplicationContext extends EnvironmentCapable, ListableBeanFactory, HierarchicalBeanFactory,
		MessageSource, ApplicationEventPublisher, ResourcePatternResolver {

	/**
	 * 返回这个context的唯一id
	 */
	@Nullable
	String getId();

	/**
	 * 返回这个context所属的应用名称
	 */
	String getApplicationName();

	/**
	 * 返回一个context名称
	 */
	String getDisplayName();

	/**
	 * 返回context加载的时间
	 */
	long getStartupDate();

	/**
	 * 返回级的上下文
	 */
	@Nullable
	ApplicationContext getParent();

	/**
	 * 公开AutowireCapableBeanFactory接口的能力给到context
	 * 

This is not typically used by application code, except for the purpose of * initializing bean instances that live outside of the application context, * applying the Spring bean lifecycle (fully or partly) to them. *

Alternatively, the internal BeanFactory exposed by the * {@link ConfigurableApplicationContext} interface offers access to the * {@link AutowireCapableBeanFactory} interface too. The present method mainly * serves as a convenient, specific facility on the ApplicationContext interface. *

NOTE: As of 4.2, this method will consistently throw IllegalStateException * after the application context has been closed. In current Spring Framework * versions, only refreshable application contexts behave that way; as of 4.2, * all application context implementations will be required to comply. * @return the AutowireCapableBeanFactory for this context * @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;

 

 

你可能感兴趣的:(spring)