|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.interface21.context.support.AbstractApplicationContext
Partial implementation of ApplicationContext. Doesn't mandate the type of storage used for configuration, but implements common functionality.
This class uses the Template Method design pattern, requiring concrete subclasses to implement protected abstract methods.
The context options may be supplied as a bean in the default bean factory, with the name "contextOptions".
A message source may be supplied as a bean in the default bean factory, with the name "messageSource". Else, message resolution is delegated to the parent context.
refreshBeanFactory(),
getBeanFactory(),
OPTIONS_BEAN_NAME,
MESSAGE_SOURCE_BEAN_NAME| Field Summary | |
protected org.apache.commons.logging.Log |
logger
Log4j logger used by this class. |
static java.lang.String |
MESSAGE_SOURCE_BEAN_NAME
Name of the MessageSource bean in the factory. |
static java.lang.String |
OPTIONS_BEAN_NAME
Name of options bean in the factory. |
| Constructor Summary | |
AbstractApplicationContext()
Create a new AbstractApplicationContext with no parent. |
|
AbstractApplicationContext(ApplicationContext parent)
Create a new AbstractApplicationContext with the given parent context. |
|
| Method Summary | |
protected void |
addListener(ApplicationListener l)
Add a listener. |
protected void |
configureManagedObject(java.lang.Object o)
If the object is context-aware, give it a reference to this object. |
java.lang.String[] |
getAliases(java.lang.String name)
Return the aliases for the given bean name, if defined. |
java.lang.Object |
getBean(java.lang.String name)
Try to find the bean instance in the hierarchy. |
java.lang.Object |
getBean(java.lang.String name,
java.lang.Class requiredType)
Return an instance (possibly shared or independent) of the given bean name. |
int |
getBeanDefinitionCount()
Return the number of beans defined in the factory |
java.lang.String[] |
getBeanDefinitionNames()
Return the names of all beans defined in this factory |
java.lang.String[] |
getBeanDefinitionNames(java.lang.Class type)
Return the names of beans matching the given object type (including subclasses). |
protected abstract ListableBeanFactory |
getBeanFactory()
Unimplemented interface method. |
java.lang.String |
getDisplayName()
Return a friendly name for context |
java.lang.String |
getMessage(MessageSourceResolvable resolvable,
java.util.Locale locale)
Using all the attributes contained within the MessageSourceResolvable
arg that was passed in (except for the locale attribute),
try to resolve the message from the MessageSource contained within the Context.
NOTE: We must throw a NoSuchMessageException on this method since
at the time of calling this method we aren't able to determine if the defaultMessage
attribute is null or not. |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.util.Locale locale)
Try to resolve the message. |
java.lang.String |
getMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage,
java.util.Locale locale)
Try to resolve the message.Return default message if no message was found. |
ContextOptions |
getOptions()
Return context options. |
ApplicationContext |
getParent()
Return the parent context, or null if there is no parent, and this is the root of the context hierarchy. |
java.io.InputStream |
getResourceAsStream(java.lang.String location)
This implementation supports fully qualified URLs and appropriate (file) paths, via getResourceByPath. |
java.lang.String |
getResourceBasePath()
This implementation returns the working directory of the Java VM. |
protected java.io.InputStream |
getResourceByPath(java.lang.String path)
Return input stream to the resource at the given (file) path. |
long |
getStartupDate()
Return the timestamp when this context was first loaded |
boolean |
isSingleton(java.lang.String name)
Is this bean a singleton? |
protected void |
onRefresh()
Callback method which can be overridden to add context-specific refresh work. |
void |
publishEvent(ApplicationEvent event)
Publish the given event to all listeners. |
void |
refresh()
Load or reload configuration. |
protected abstract void |
refreshBeanFactory()
Subclasses must implement this method to perform the actual configuration load. |
java.lang.Object |
removeSharedObject(java.lang.String key)
Remove a shared object added with a call to shareObject(). |
protected void |
setDisplayName(java.lang.String displayName)
To avoid endless constructor chaining, only concrete classes take this in their constructor, and then invoke this method |
protected void |
setParent(ApplicationContext ac)
Subclasses may call this to set parent after constructor. |
java.lang.Object |
sharedObject(java.lang.String key)
Retrieve a shared object added with a call to shareObject(). |
void |
shareObject(java.lang.String key,
java.lang.Object o)
Put an object available for sharing. |
java.lang.String |
toString()
Show information about this context |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String OPTIONS_BEAN_NAME
ContextOptionspublic static final java.lang.String MESSAGE_SOURCE_BEAN_NAME
MessageSourceprotected final org.apache.commons.logging.Log logger
| Constructor Detail |
public AbstractApplicationContext()
public AbstractApplicationContext(ApplicationContext parent)
parent - parent context| Method Detail |
public ApplicationContext getParent()
getParent in interface ApplicationContextprotected void setParent(ApplicationContext ac)
ac - parent contextpublic java.lang.String getDisplayName()
getDisplayName in interface ApplicationContextprotected void setDisplayName(java.lang.String displayName)
public final long getStartupDate()
getStartupDate in interface ApplicationContextpublic final ContextOptions getOptions()
getOptions in interface ApplicationContext
public final void refresh()
throws ApplicationContextException
refresh in interface ApplicationContextApplicationContextException - if the configuration was invalid or couldn't
be found, or if configuration has already been loaded and reloading is forbidden
DYNAMIC CLASSLOADER ISSUE...subclass to get classloader!?
protected void onRefresh()
throws ApplicationContextException
ApplicationContextException - in case of errors during refresh
protected void configureManagedObject(java.lang.Object o)
throws ApplicationContextException
o - object to invoke the setApplicationContext() method on,
if it implements the ApplicationContextAware interfacepublic final void publishEvent(ApplicationEvent event)
publishEvent in interface ApplicationContextevent - event to publish. The event may be application-specific,
or a standard framework event.protected void addListener(ApplicationListener l)
public final java.io.InputStream getResourceAsStream(java.lang.String location)
throws java.io.IOException
getResourceAsStream in interface ApplicationContextgetResourceByPath(java.lang.String)
protected java.io.InputStream getResourceByPath(java.lang.String path)
throws java.io.IOException
Default implementation supports file paths, either absolute or relative to the application's working directory. This should be appropriate for standalone implementations but can be overridden, e.g. for implementations targetted at a container.
path - path to the resourcejava.io.IOException - exception when opening the specified resourcepublic java.lang.String getResourceBasePath()
getResourceBasePath in interface ApplicationContextcom.interface21.context.ApplicationContextpublic java.lang.Object sharedObject(java.lang.String key)
ApplicationContextsharedObject in interface ApplicationContextcom.interface21.context.ApplicationContext
public void shareObject(java.lang.String key,
java.lang.Object o)
ApplicationContextshareObject in interface ApplicationContextcom.interface21.context.ApplicationContextkey - object keyo - object to putpublic java.lang.Object removeSharedObject(java.lang.String key)
ApplicationContextremoveSharedObject in interface ApplicationContextcom.interface21.context.ApplicationContextkey - the object was added with
public java.lang.String getMessage(java.lang.String code,
java.lang.Object[] args,
java.lang.String defaultMessage,
java.util.Locale locale)
getMessage in interface MessageSourcecode - code to lookup up, such as 'calculator.noRateSet'locale - Locale in which to do lookupargs - Array of arguments that will be filled in for params within
the message (params look like "{0}", "{1,date}", "{2,time}" within a message).defaultMessage - String to return if the lookup fails
public java.lang.String getMessage(java.lang.String code,
java.lang.Object[] args,
java.util.Locale locale)
throws NoSuchMessageException
getMessage in interface MessageSourcecode - code to lookup up, such as 'calculator.noRateSet'locale - Locale in which to do lookupargs - Array of arguments that will be filled in for params within
the message (params look like "{0}", "{1,date}", "{2,time}" within a message).NoSuchMessageException - not found in any locale
public java.lang.String getMessage(MessageSourceResolvable resolvable,
java.util.Locale locale)
throws NoSuchMessageException
MessageSourceResolvable
arg that was passed in (except for the locale attribute),
try to resolve the message from the MessageSource contained within the Context.
NOTE: We must throw a NoSuchMessageException on this method since
at the time of calling this method we aren't able to determine if the defaultMessage
attribute is null or not.
getMessage in interface MessageSourceresolvable - Value object storing 4 attributes required to properly resolve a message.locale - Locale to be used as the "driver" to figuring out what message to return.NoSuchMessageException - not found in any locale
public java.lang.Object getBean(java.lang.String name)
throws BeansException
getBean in interface BeanFactorycom.interface21.beans.factory.BeanFactoryname - name of the bean to returnNoSuchBeanDefinitionException - if there's no such bean definition
public java.lang.Object getBean(java.lang.String name,
java.lang.Class requiredType)
throws BeansException
BeanFactorygetBean in interface BeanFactorycom.interface21.beans.factory.BeanFactoryname - name of the bean to returnrequiredType - type the bean may match. Can be an interface or superclass
of the actual class. For example, if the value is Object.class, this method will
succeed whatever the class of the returned instance.BeanNotOfRequiredTypeException - if the bean is not of the required typeNoSuchBeanDefinitionException - if there's no such bean definition
public boolean isSingleton(java.lang.String name)
throws NoSuchBeanDefinitionException
BeanFactoryisSingleton in interface BeanFactorycom.interface21.beans.factory.BeanFactoryname - name of the bean to queryNoSuchBeanDefinitionException - if there is no bean with the given namepublic java.lang.String[] getAliases(java.lang.String name)
BeanFactorygetAliases in interface BeanFactorycom.interface21.beans.factory.BeanFactoryname - the bean name to check for aliasespublic int getBeanDefinitionCount()
ListableBeanFactorygetBeanDefinitionCount in interface ListableBeanFactorycom.interface21.beans.factory.ListableBeanFactorypublic java.lang.String[] getBeanDefinitionNames()
ListableBeanFactorygetBeanDefinitionNames in interface ListableBeanFactorycom.interface21.beans.factory.ListableBeanFactorypublic java.lang.String[] getBeanDefinitionNames(java.lang.Class type)
ListableBeanFactorygetBeanDefinitionNames in interface ListableBeanFactorycom.interface21.beans.factory.ListableBeanFactorytype - class or interface to matchpublic java.lang.String toString()
toString in class java.lang.Object
protected abstract void refreshBeanFactory()
throws ApplicationContextException
protected abstract ListableBeanFactory getBeanFactory()
|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||