org.springframework.context.support
Class ApplicationObjectSupport

Direct Known Subclasses:
EventPublicationInterceptor, WebApplicationObjectSupport

public abstract class ApplicationObjectSupport
implements ApplicationContextAware

Convenient superclass for application objects that want to be aware of the application context, e.g. for custom lookup of collaborating beans or for context-specific resource access. It saves the application context reference and provides an initialization callback method. Furthermore, it offers numerous convenience methods for message lookup.

There is no requirement to subclass this class: It just makes things a little easier if you need access to the context, e.g. for access to file resources or to the message source. Note that many application objects do not need to be aware of the application context at all, as they can receive collaborating beans via bean references.

Many framework classes are derived from this class, particularly within the web support.

Author:
Rod Johnson, Juergen Hoeller

Constructor Summary
ApplicationObjectSupport()
          Constructor for bean usage via subclassing.
ApplicationObjectSupport(ApplicationContext context)
          Constructor for usage as helper to delegate to.

Method Summary
 final ApplicationContextgetApplicationContext()
          Return the ApplicationContext instance used by this object.
 final voidsetApplicationContext(ApplicationContext context)
           

Constructor Detail

ApplicationObjectSupport

public ApplicationObjectSupport()
Constructor for bean usage via subclassing.

ApplicationObjectSupport

public ApplicationObjectSupport(ApplicationContext context)
Constructor for usage as helper to delegate to.
Parameters:
context - ApplicationContext object to be used by this object
Method Detail

getApplicationContext

public final ApplicationContext getApplicationContext()
Return the ApplicationContext instance used by this object.

setApplicationContext

public final void setApplicationContext(ApplicationContext context)
throws org.springframework.beans.BeansException

Association Links

to Class org.springframework.context.ApplicationContext

ApplicationContext this object runs in

to Class org.springframework.context.support.MessageSourceAccessor

MessageSourceAccessor for easy message access