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_NAMECONFIG_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(java.lang.String code,
java.util.Locale locale,
java.lang.String defaultMessage)
Associate the given message with the given code.
|
protected void |
assertBeanFactoryActive()
Overridden to turn it into a no-op, to be more lenient towards test cases.
|
StaticMessageSource |
getStaticMessageSource()
Return the internal StaticMessageSource used by this context.
|
void |
registerPrototype(java.lang.String name,
java.lang.Class<?> clazz)
Register a prototype bean with the underlying bean factory.
|
void |
registerPrototype(java.lang.String name,
java.lang.Class<?> clazz,
org.springframework.beans.MutablePropertyValues pvs)
Register a prototype bean with the underlying bean factory.
|
void |
registerSingleton(java.lang.String name,
java.lang.Class<?> clazz)
Register a singleton bean with the underlying bean factory.
|
void |
registerSingleton(java.lang.String name,
java.lang.Class<?> clazz,
org.springframework.beans.MutablePropertyValues pvs)
Register a singleton bean with the underlying bean factory.
|
cancelRefresh, closeBeanFactory, getAutowireCapableBeanFactory, getBeanDefinition, getBeanFactory, getClassLoader, getDefaultListableBeanFactory, getResource, getResources, isAlias, isBeanNameInUse, refreshBeanFactory, registerAlias, registerBeanDefinition, removeAlias, removeBeanDefinition, setAllowBeanDefinitionOverriding, setAllowCircularReferences, setClassLoader, setId, setParent, setResourceLoaderaddApplicationListener, addBeanFactoryPostProcessor, close, containsBean, containsBeanDefinition, containsLocalBean, createEnvironment, destroy, destroyBeans, doClose, findAnnotationOnBean, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getApplicationName, getBean, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForAnnotation, getBeanNamesForType, 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, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, postProcessBeanFactory, prepareBeanFactory, prepareRefresh, publishEvent, publishEvent, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, resetCommonCaches, setDisplayName, setEnvironment, start, stop, toStringaddProtocolResolver, getProtocolResolvers, getResourceByPathclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcontainsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNamesaddProtocolResolverpublic StaticApplicationContext()
throws org.springframework.beans.BeansException
org.springframework.beans.BeansExceptionregisterSingleton(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.BeansExceptionregisterSingleton(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()protected void assertBeanFactoryActive()
assertBeanFactoryActive in class AbstractApplicationContextpublic final StaticMessageSource getStaticMessageSource()
public void registerSingleton(java.lang.String name,
java.lang.Class<?> clazz)
throws org.springframework.beans.BeansException
For more advanced needs, register with the underlying BeanFactory directly.
org.springframework.beans.BeansExceptionGenericApplicationContext.getDefaultListableBeanFactory()public void registerSingleton(java.lang.String name,
java.lang.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.BeansExceptionGenericApplicationContext.getDefaultListableBeanFactory()public void registerPrototype(java.lang.String name,
java.lang.Class<?> clazz)
throws org.springframework.beans.BeansException
For more advanced needs, register with the underlying BeanFactory directly.
org.springframework.beans.BeansExceptionGenericApplicationContext.getDefaultListableBeanFactory()public void registerPrototype(java.lang.String name,
java.lang.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.BeansExceptionGenericApplicationContext.getDefaultListableBeanFactory()public void addMessage(java.lang.String code,
java.util.Locale locale,
java.lang.String defaultMessage)
code - lookup codelocale - locale message should be found withindefaultMessage - message associated with this lookup codegetStaticMessageSource()