Interface to be implemented by any object that wishes to be notified of the {@link 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 {@link ResourceLoaderAware}, {@link ApplicationEventPublisherAware} or {@link MessageSourceAware} interfacein such a specific scenario.
Note that file resource dependencies can also be exposed as bean properties of type {@link org.springframework.core.io.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.
{@link org.springframework.context.support.ApplicationObjectSupport} is aconvenience base class for application objects, implementing this interface.
For a list of all bean lifecycle methods, see the {@link org.springframework.beans.factory.BeanFactory BeanFactory javadocs}.
@author Rod Johnson
@author Juergen Hoeller
@author Chris Beams
@see ResourceLoaderAware
@see ApplicationEventPublisherAware
@see MessageSourceAware
@see org.springframework.context.support.ApplicationObjectSupport
@see org.springframework.beans.factory.BeanFactoryAware