Top Description Fields Methods
org.springframework.context

public Interface ApplicationContext

extends EnvironmentCapable, ListableBeanFactory, HierarchicalBeanFactory, MessageSource, ApplicationEventPublisher, ResourcePatternResolver
Known Direct Subinterfaces
org.springframework.context.ConfigurableApplicationContext
Imports
org.springframework.beans.factory.HierarchicalBeanFactory, .ListableBeanFactory, org.springframework.beans.factory.config.AutowireCapableBeanFactory, org.springframework.core.env.EnvironmentCapable, org.springframework.core.io.support.ResourcePatternResolver, org.springframework.lang.Nullable

Central interface to provide configuration for an application. This is read-only while the application is running, but may be reloaded if the implementation supports this.

An ApplicationContext provides:

In addition to standard org.springframework.beans.factory.BeanFactory lifecycle capabilities, ApplicationContext implementations detect and invoke ApplicationContextAware beans as well as ResourceLoaderAware, ApplicationEventPublisherAware and MessageSourceAware beans.

Authors
Rod Johnson, Juergen Hoeller
See Also
ConfigurableApplicationContext, org.springframework.beans.factory.BeanFactory, org.springframework.core.io.ResourceLoader

Field Summary

Inherited from org.springframework.core.io.support.ResourcePatternResolver:
CLASSPATH_ALL_URL_PREFIX

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

a name for the deployed application, or the empty String by default
getApplicationName
()

Return a name for the deployed application that this context belongs to.

public AutowireCapableBeanFactory

Returns:

the AutowireCapableBeanFactory for this context
getAutowireCapableBeanFactory
()

Expose AutowireCapableBeanFactory functionality for this context.

public String

Returns:

a display name for this context (never null)
getDisplayName
()

Return a friendly name for this context.

public String

Returns:

the unique id of the context, or null if none
getId
()

Return the unique id of this application context.

public ApplicationContext

Returns:

the parent context, or null if there is no parent
getParent
()

Return the parent context, or null if there is no parent and this is the root of the context hierarchy.

public long

Returns:

the timestamp (ms) when this context was first loaded
getStartupDate
()

Return the timestamp when this context was first loaded.

Inherited from org.springframework.beans.factory.HierarchicalBeanFactory:
containsLocalBeangetParentBeanFactory
Inherited from org.springframework.beans.factory.ListableBeanFactory:
containsBeanDefinitionfindAllAnnotationsOnBeanfindAnnotationOnBeanfindAnnotationOnBeangetBeanDefinitionCountgetBeanDefinitionNamesgetBeanNamesForAnnotationgetBeanNamesForTypegetBeanNamesForTypegetBeanNamesForTypegetBeanNamesForTypegetBeanProvidergetBeanProvidergetBeansOfTypegetBeansOfTypegetBeansWithAnnotation
Inherited from org.springframework.context.ApplicationEventPublisher:
publishEventpublishEvent
Inherited from org.springframework.context.MessageSource:
getMessagegetMessagegetMessage
Inherited from org.springframework.core.env.EnvironmentCapable:
getEnvironment
Inherited from org.springframework.core.io.support.ResourcePatternResolver:
getResources

Method Detail

getApplicationNameback to summary
public String getApplicationName()

Return a name for the deployed application that this context belongs to.

Returns:String

a name for the deployed application, or the empty String by default

getAutowireCapableBeanFactoryback to summary
public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException

Expose 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 ConfigurableApplicationContext interface offers access to the 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.

Returns:AutowireCapableBeanFactory

the AutowireCapableBeanFactory for this context

Exceptions
IllegalStateException:
if the context does not support the AutowireCapableBeanFactory interface, or does not hold an autowire-capable bean factory yet (e.g. if refresh() has never been called), or if the context has been closed already
See Also
ConfigurableApplicationContext#refresh(), ConfigurableApplicationContext#getBeanFactory()
getDisplayNameback to summary
public String getDisplayName()

Return a friendly name for this context.

Returns:String

a display name for this context (never null)

getIdback to summary
public String getId()

Return the unique id of this application context.

Returns:String

the unique id of the context, or null if none

Annotations
@Nullable
getParentback to summary
public ApplicationContext getParent()

Return the parent context, or null if there is no parent and this is the root of the context hierarchy.

Returns:ApplicationContext

the parent context, or null if there is no parent

Annotations
@Nullable
getStartupDateback to summary
public long getStartupDate()

Return the timestamp when this context was first loaded.

Returns:long

the timestamp (ms) when this context was first loaded