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.
org.springframework.web.context.support.WebApplicationObjectSupport
| Modifier and Type | Field and Description |
|---|---|
| private ApplicationContext | applicationContext
ApplicationContext this object runs in. |
| protected final Log | logger
Logger that is available to subclasses. |
| private MessageSourceAccessor | messageSourceAccessor
MessageSourceAccessor for easy message access. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public final ApplicationContext | |
| protected final MessageSourceAccessor | getMessageSourceAccessor()
Return a MessageSourceAccessor for the application context used by this object, for easy message access. |
| protected void | initApplicationContext(ApplicationContext
the containing ApplicationContext context)Subclasses can override this for custom initialization behavior. |
| protected void | |
| protected boolean | |
| protected final ApplicationContext | Returns: the ApplicationContext (nevernull)Obtain the ApplicationContext for actual use. |
| protected Class | requiredContextClass()
Determine the context class that any context passed to
|
| public final void | setApplicationContext(ApplicationContext
the ApplicationContext object to be used by this object context)Implements org. Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object. |
| applicationContext | back to summary |
|---|---|
| private ApplicationContext applicationContext ApplicationContext this object runs in. | |
| logger | back to summary |
|---|---|
| protected final Log logger Logger that is available to subclasses. | |
| messageSourceAccessor | back to summary |
|---|---|
| private MessageSourceAccessor messageSourceAccessor MessageSourceAccessor for easy message access. | |
| ApplicationObjectSupport | back to summary |
|---|---|
| public ApplicationObjectSupport() | |
| getApplicationContext | back to summary |
|---|---|
| public final ApplicationContext getApplicationContext() throws IllegalStateException Return the ApplicationContext that this object is associated with.
| |
| getMessageSourceAccessor | back to summary |
|---|---|
| protected final MessageSourceAccessor getMessageSourceAccessor() throws IllegalStateException Return a MessageSourceAccessor for the application context used by this object, for easy message access.
| |
| initApplicationContext | back to summary |
|---|---|
| protected void initApplicationContext(ApplicationContext context) throws BeansException Subclasses can override this for custom initialization behavior.
Gets called by Note Does not get called on re-initialization of the context but rather just on first initialization of this object's context reference. The default implementation calls the overloaded
| |
| initApplicationContext | back to summary |
|---|---|
| protected void initApplicationContext() throws BeansException Subclasses can override this for custom initialization behavior. The default implementation is empty. Called by
| |
| isContextRequired | back to summary |
|---|---|
| protected boolean isContextRequired() Determine whether this application object needs to run in an ApplicationContext. Default is "false". Can be overridden to enforce running in a context (i.e. to throw IllegalStateException on accessors if outside a context). | |
| obtainApplicationContext | back to summary |
|---|---|
| protected final ApplicationContext obtainApplicationContext() Obtain the ApplicationContext for actual use.
| |
| requiredContextClass | back to summary |
|---|---|
| protected Class Determine the context class that any context passed to
| |
| setApplicationContext | back to summary |
|---|---|
| public final void setApplicationContext(ApplicationContext context) throws BeansException Implements org. Doc from org. 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
| |