org.springframework.context
Interface ApplicationContextAware

All Known Implementing Classes:
ApplicationObjectSupport, ReloadableResourceBundleMessageSource, VelocityConfigurer

public interface ApplicationContextAware

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

Implementing this interface makes sense when an object requires access to file resources, i.e. wants to call ApplicationContext.getResource, or access to the MessageSource. Configuration via bean references is preferable to implementing this interface just for bean lookup purposes.

Note that Resource dependencies can also be exposed as bean properties of type Resource, populated via Strings with automatic type conversion by the bean factory or via ResourceFactoryBean. This removes the need for implementing this interface just for resource access purposes.

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
See Also: ApplicationContext.getResource(java.lang.String), Resource, ResourceFactoryBean, MessageSource, ApplicationObjectSupport, BeanFactoryAware, InitializingBean, BeanFactory

Method Summary
 voidsetApplicationContext(ApplicationContext context)
          Set the application context used by this object.

Method Detail

setApplicationContext

public void setApplicationContext(ApplicationContext context)
throws org.springframework.beans.BeansException
Set the application context used by this object. Normally this call will be used to initialize the object.

Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method.

Parameters:
context - 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