站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

ApplicationContextAware (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.context
Interface ApplicationContextAware

All Known Implementing Classes:
AbstractCachingViewResolver, AbstractCommandController, AbstractCommandController, AbstractController, AbstractController, AbstractExcelView, AbstractFormController, AbstractFormController, AbstractHandlerMapping, AbstractHandlerMapping, AbstractJasperReportsSingleFormatView, AbstractJasperReportsView, AbstractJExcelView, AbstractMapBasedHandlerMapping, AbstractPathMapHandlerMapping, AbstractPdfView, AbstractTemplateView, AbstractTemplateViewResolver, AbstractUrlBasedView, AbstractUrlHandlerMapping, AbstractUrlViewController, AbstractView, AbstractWizardFormController, AbstractWizardFormController, AbstractXsltView, ApplicationObjectSupport, BaseCommandController, BaseCommandController, BeanNameUrlHandlerMapping, BeanNameViewResolver, CancellableFormController, CommonsPathMapHandlerMapping, ConfigurableJasperReportsView, ControllerClassNameHandlerMapping, FreeMarkerView, FreeMarkerViewResolver, InternalResourceView, InternalResourceViewResolver, JasperReportsCsvView, JasperReportsHtmlView, JasperReportsMultiFormatView, JasperReportsPdfView, JasperReportsViewResolver, JasperReportsXlsView, JobDetailBean, JstlView, MultiActionController, ParameterHandlerMapping, ParameterizableViewController, ParameterizableViewController, PortletApplicationObjectSupport, PortletContentGenerator, PortletModeHandlerMapping, PortletModeParameterHandlerMapping, PortletWrappingController, RedirectView, ResourceBundleViewResolver, SchedulerFactoryBean, ServletForwardingController, ServletWrappingController, SimpleFormController, SimpleFormController, SimpleUrlHandlerMapping, TilesConfigurer, TilesJstlView, TilesView, UrlBasedViewResolver, UrlFilenameViewController, VelocityLayoutView, VelocityLayoutViewResolver, VelocityToolboxView, VelocityView, VelocityViewResolver, WebApplicationObjectSupport, WebContentGenerator, WebContentInterceptor, XmlViewResolver, XsltView, XsltViewResolver

public interface ApplicationContextAware

Interface to be implemented by any object that wishes to be notified of the ApplicationContext that it runs in.

Implementing this interface makes sense for example when an object requires access to a set of collaborating beans. Note that configuration via bean references is preferable to implementing this interface just for bean lookup purposes.

This interface can also be implemented if an object needs access to file resources, i.e. wants to call getResource, wants to publish an application event, or requires access to the MessageSource. However, it is preferable to implement the more specific ResourceLoaderAware, ApplicationEventPublisherAware or MessageSourceAware interface in such a specific scenario.

Note that file resource dependencies can also be exposed as bean properties of type Resource, populated via Strings with automatic type conversion by the bean factory. This removes the need for implementing any callback interface just for the purpose of accessing a specific file resource.

ApplicationObjectSupport is a convenience base class for application objects, implementing this interface.

For a list of all bean lifecycle methods, see the BeanFactory javadocs.

Author:
Rod Johnson, Juergen Hoeller
See Also:
ResourceLoaderAware, ApplicationEventPublisherAware, MessageSourceAware, ApplicationObjectSupport, BeanFactoryAware

Method Summary
 void setApplicationContext(ApplicationContext applicationContext)
          Set the ApplicationContext that this object runs in.
 

Method Detail

setApplicationContext

void setApplicationContext(ApplicationContext applicationContext)
                           throws BeansException
Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.

Invoked after population of normal bean properties but before an init callback such as InitializingBean.afterPropertiesSet() or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader), ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) and MessageSourceAware, if applicable.

Parameters:
applicationContext - the ApplicationContext object to be used by this object
Throws:
ApplicationContextException - in case of context initialization errors
BeansException - if thrown by application context methods
See Also:
BeanInitializationException

The Spring Framework

Copyright © 2002-2007 The Spring Framework.