public class StaticApplicationContext extends GenericApplicationContext
ApplicationContext
implementation
which supports programmatic registration of beans and messages,
rather than reading bean definitions from external configuration sources.
Mainly useful for testing.registerSingleton(java.lang.String, java.lang.Class)
,
registerPrototype(java.lang.String, java.lang.Class)
,
GenericApplicationContext.registerBeanDefinition(java.lang.String, org.springframework.beans.factory.config.BeanDefinition)
,
AbstractApplicationContext.refresh()
APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAME
CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME
Constructor and Description |
---|
StaticApplicationContext()
Create a new StaticApplicationContext.
|
StaticApplicationContext(ApplicationContext parent)
Create a new StaticApplicationContext with the given parent.
|
Modifier and Type | Method and Description |
---|---|
void |
addMessage(String code,
Locale locale,
String defaultMessage)
Associate the given message with the given code.
|
StaticMessageSource |
getStaticMessageSource()
Return the internal StaticMessageSource used by this context.
|
void |
registerPrototype(String name,
Class clazz)
Register a prototype bean with the underlying bean factory.
|
void |
registerPrototype(String name,
Class clazz,
org.springframework.beans.MutablePropertyValues pvs)
Register a prototype bean with the underlying bean factory.
|
void |
registerSingleton(String name,
Class clazz)
Register a singleton bean with the underlying bean factory.
|
void |
registerSingleton(String name,
Class clazz,
org.springframework.beans.MutablePropertyValues pvs)
Register a singleton bean with the underlying bean factory.
|
cancelRefresh, closeBeanFactory, getBeanDefinition, getBeanFactory, getDefaultListableBeanFactory, getResource, getResources, isAlias, isBeanNameInUse, refreshBeanFactory, registerAlias, registerBeanDefinition, removeAlias, removeBeanDefinition, setAllowBeanDefinitionOverriding, setAllowCircularReferences, setId, setParent, setResourceLoader
addApplicationListener, addBeanFactoryPostProcessor, addListener, close, containsBean, containsBeanDefinition, containsLocalBean, createEnvironment, destroy, destroyBeans, doClose, findAnnotationOnBean, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getApplicationName, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getEnvironment, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResourcePatternResolver, getStartupDate, getType, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, initPropertySources, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, postProcessBeanFactory, prepareBeanFactory, prepareRefresh, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setEnvironment, start, stop, toString
getClassLoader, getResourceByPath, setClassLoader
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public StaticApplicationContext() throws org.springframework.beans.BeansException
org.springframework.beans.BeansException
registerSingleton(java.lang.String, java.lang.Class)
,
registerPrototype(java.lang.String, java.lang.Class)
,
GenericApplicationContext.registerBeanDefinition(java.lang.String, org.springframework.beans.factory.config.BeanDefinition)
,
AbstractApplicationContext.refresh()
public StaticApplicationContext(ApplicationContext parent) throws org.springframework.beans.BeansException
org.springframework.beans.BeansException
registerSingleton(java.lang.String, java.lang.Class)
,
registerPrototype(java.lang.String, java.lang.Class)
,
GenericApplicationContext.registerBeanDefinition(java.lang.String, org.springframework.beans.factory.config.BeanDefinition)
,
AbstractApplicationContext.refresh()
public final StaticMessageSource getStaticMessageSource()
public void registerSingleton(String name, Class clazz) throws org.springframework.beans.BeansException
For more advanced needs, register with the underlying BeanFactory directly.
org.springframework.beans.BeansException
GenericApplicationContext.getDefaultListableBeanFactory()
public void registerSingleton(String name, Class clazz, org.springframework.beans.MutablePropertyValues pvs) throws org.springframework.beans.BeansException
For more advanced needs, register with the underlying BeanFactory directly.
org.springframework.beans.BeansException
GenericApplicationContext.getDefaultListableBeanFactory()
public void registerPrototype(String name, Class clazz) throws org.springframework.beans.BeansException
For more advanced needs, register with the underlying BeanFactory directly.
org.springframework.beans.BeansException
GenericApplicationContext.getDefaultListableBeanFactory()
public void registerPrototype(String name, Class clazz, org.springframework.beans.MutablePropertyValues pvs) throws org.springframework.beans.BeansException
For more advanced needs, register with the underlying BeanFactory directly.
org.springframework.beans.BeansException
GenericApplicationContext.getDefaultListableBeanFactory()
public void addMessage(String code, Locale locale, String defaultMessage)
code
- lookup codelocale
- locale message should be found withindefaultMessage
- message associated with this lookup codegetStaticMessageSource()