接口 ApplicationContextAware
- 所有超级接口:
Aware
- 所有已知实现类:
AbstractAtomFeedView
,AbstractCachingViewResolver
,AbstractController
,AbstractDetectingUrlHandlerMapping
,AbstractFeedView
,AbstractHandlerMapping
,AbstractHandlerMapping
,AbstractHandlerMethodAdapter
,AbstractHandlerMethodMapping
,AbstractHandlerMethodMapping
,AbstractJackson2View
,AbstractJUnit4SpringContextTests
,AbstractMessageBrokerConfiguration
,AbstractMethodMessageHandler
,AbstractMethodMessageHandler
,AbstractPdfStamperView
,AbstractPdfView
,AbstractRssFeedView
,AbstractTemplateView
,AbstractTemplateViewResolver
,AbstractTestNGSpringContextTests
,AbstractTransactionalJUnit4SpringContextTests
,AbstractTransactionalTestNGSpringContextTests
,AbstractUrlBasedView
,AbstractUrlBasedView
,AbstractUrlHandlerMapping
,AbstractUrlHandlerMapping
,AbstractUrlViewController
,AbstractView
,AbstractView
,AbstractXlsView
,AbstractXlsxStreamingView
,AbstractXlsxView
,ApplicationObjectSupport
,BeanNameUrlHandlerMapping
,BeanNameViewResolver
,ContentNegotiatingViewResolver
,DelegatingWebFluxConfiguration
,DelegatingWebMvcConfiguration
,DelegatingWebSocketMessageBrokerConfiguration
,DispatcherHandler
,DispatcherServlet
,EventListenerMethodProcessor
,ExceptionHandlerExceptionResolver
,FrameworkServlet
,FreeMarkerView
,FreeMarkerView
,FreeMarkerViewResolver
,FreeMarkerViewResolver
,GroovyMarkupConfigurer
,GroovyMarkupView
,GroovyMarkupViewResolver
,HandlerMappingIntrospector
,InternalResourceView
,InternalResourceViewResolver
,Jackson2ObjectMapperFactoryBean
,JmsListenerEndpointRegistry
,JobDetailFactoryBean
,JstlView
,LiveBeansView
,LocalValidatorFactoryBean
,MappingJackson2JsonView
,MappingJackson2XmlView
,MarshallingView
,MessageMappingMessageHandler
,OptionalValidatorFactoryBean
,ParameterizableViewController
,RedirectView
,RedirectView
,RequestMappingHandlerAdapter
,RequestMappingHandlerAdapter
,RequestMappingHandlerMapping
,RequestMappingHandlerMapping
,RequestMappingInfoHandlerMapping
,RequestMappingInfoHandlerMapping
,ResourceBundleViewResolver
,ResourceHttpRequestHandler
,RouterFunctionMapping
,RouterFunctionMapping
,RSocketMessageHandler
,ScheduledAnnotationBeanPostProcessor
,SchedulerFactoryBean
,ScriptTemplateView
,ScriptTemplateView
,ScriptTemplateViewResolver
,ScriptTemplateViewResolver
,ServerEndpointExporter
,ServletContextLiveBeansView
,ServletForwardingController
,ServletWrappingController
,SimpAnnotationMethodMessageHandler
,SimpleUrlHandlerMapping
,SimpleUrlHandlerMapping
,SpringBeanJobFactory
,TilesView
,TilesViewResolver
,UrlBasedViewResolver
,UrlBasedViewResolver
,UrlFilenameViewController
,ViewResolverComposite
,WebApplicationObjectSupport
,WebContentGenerator
,WebContentInterceptor
,WebFluxConfigurationSupport
,WebMvcConfigurationSupport
,WebSocketAnnotationMethodMessageHandler
,WebSocketHandlerMapping
,WebSocketMessageBrokerConfigurationSupport
,XmlViewResolver
,XsltView
,XsltViewResolver
public interface ApplicationContextAware extends Aware
Interface to be implemented by any object that wishes to be notified of theApplicationContext
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 specificResourceLoaderAware
,ApplicationEventPublisherAware
orMessageSourceAware
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
.- 作者:
- Rod Johnson, Juergen Hoeller, Chris Beams
- 另请参阅:
ResourceLoaderAware
,ApplicationEventPublisherAware
,MessageSourceAware
,ApplicationObjectSupport
,BeanFactoryAware
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 void
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.
方法详细资料
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 afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
andMessageSourceAware
, if applicable.- 参数:
applicationContext
- the ApplicationContext object to be used by this object- 抛出:
ApplicationContextException
- in case of context initialization errorsBeansException
- if thrown by application context methods- 另请参阅:
BeanInitializationException