Interface ApplicationContext
- All Superinterfaces:
- ApplicationEventPublisher, BeanFactory, EnvironmentCapable, HierarchicalBeanFactory, ListableBeanFactory, MessageSource, ResourceLoader, ResourcePatternResolver
- All Known Subinterfaces:
- ConfigurableApplicationContext, ConfigurableWebApplicationContext, WebApplicationContext
- All Known Implementing Classes:
- AbstractApplicationContext, AbstractRefreshableApplicationContext, AbstractRefreshableConfigApplicationContext, AbstractRefreshableWebApplicationContext, AbstractXmlApplicationContext, AnnotationConfigApplicationContext, AnnotationConfigWebApplicationContext, ClassPathXmlApplicationContext, FileSystemXmlApplicationContext, GenericApplicationContext, GenericGroovyApplicationContext, GenericWebApplicationContext, GenericXmlApplicationContext, GroovyWebApplicationContext, StaticApplicationContext, StaticWebApplicationContext, XmlWebApplicationContext
An ApplicationContext provides:
- Bean factory methods for accessing application components.
Inherited from ListableBeanFactory.
- The ability to load file resources in a generic fashion.
Inherited from the ResourceLoaderinterface.
- The ability to publish events to registered listeners.
Inherited from the ApplicationEventPublisherinterface.
- The ability to resolve messages, supporting internationalization.
Inherited from the MessageSourceinterface.
- Inheritance from a parent context. Definitions in a descendant context will always take priority. This means, for example, that a single parent context can be used by an entire web application, while each servlet has its own child context that is independent of that of any other servlet.
In addition to standard BeanFactory
lifecycle capabilities, ApplicationContext implementations detect and invoke
ApplicationContextAware beans as well as ResourceLoaderAware,
ApplicationEventPublisherAware and MessageSourceAware beans.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
- 
Field SummaryFields inherited from interface BeanFactoryFACTORY_BEAN_PREFIX, FACTORY_BEAN_PREFIX_CHARFields inherited from interface ResourceLoaderCLASSPATH_URL_PREFIXFields inherited from interface ResourcePatternResolverCLASSPATH_ALL_URL_PREFIX
- 
Method SummaryModifier and TypeMethodDescriptionReturn a name for the deployed application that this context belongs to.Expose AutowireCapableBeanFactory functionality for this context.Return a friendly name for this context.getId()Return the unique id of this application context.Return the parent context, ornullif there is no parent and this is the root of the context hierarchy.longReturn the timestamp when this context was first loaded.Methods inherited from interface ApplicationEventPublisherpublishEvent, publishEventMethods inherited from interface BeanFactorycontainsBean, getAliases, getBean, getBean, getBean, getBean, getBean, getBeanProvider, getBeanProvider, getBeanProvider, getType, getType, isPrototype, isSingleton, isTypeMatch, isTypeMatchMethods inherited from interface EnvironmentCapablegetEnvironmentMethods inherited from interface HierarchicalBeanFactorycontainsLocalBean, getParentBeanFactoryMethods inherited from interface ListableBeanFactorycontainsBeanDefinition, findAllAnnotationsOnBean, findAnnotationOnBean, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotationMethods inherited from interface MessageSourcegetMessage, getMessage, getMessageMethods inherited from interface ResourceLoadergetClassLoader, getResourceMethods inherited from interface ResourcePatternResolvergetResources
- 
Method Details- 
getId
- 
getApplicationNameString getApplicationName()Return a name for the deployed application that this context belongs to.- Returns:
- a name for the deployed application, or the empty String by default
 
- 
getDisplayNameString getDisplayName()Return a friendly name for this context.- Returns:
- a display name for this context (never null)
 
- 
getStartupDatelong getStartupDate()Return the timestamp when this context was first loaded.- Returns:
- the timestamp (ms) when this context was first loaded
 
- 
getParent@Nullable ApplicationContext getParent()Return the parent context, ornullif there is no parent and this is the root of the context hierarchy.- Returns:
- the parent context, or nullif there is no parent
 
- 
getAutowireCapableBeanFactoryExpose AutowireCapableBeanFactory functionality for this context.This is not typically used by application code, except for the purpose of initializing bean instances that live outside the application context, applying the Spring bean lifecycle (fully or partly) to them. Alternatively, the internal BeanFactory exposed by the ConfigurableApplicationContextinterface offers access to theAutowireCapableBeanFactoryinterface 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. - Returns:
- the AutowireCapableBeanFactory for this context
- Throws:
- IllegalStateException- if the context does not support the- AutowireCapableBeanFactoryinterface, or does not hold an autowire-capable bean factory yet (for example, if- refresh()has never been called), or if the context has been closed already
- See Also:
 
 
-