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_NAMEFACTORY_BEAN_PREFIXCLASSPATH_ALL_URL_PREFIXCLASSPATH_URL_PREFIX| 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,
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,
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, setResourceLoaderaddApplicationListener, 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, toStringgetClassLoader, getResourceByPath, setClassLoaderclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcontainsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNamesgetAliasesgetClassLoaderpublic StaticApplicationContext()
throws BeansException
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 BeansException
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 final StaticMessageSource getStaticMessageSource()
public void registerSingleton(String name, Class clazz) throws BeansException
For more advanced needs, register with the underlying BeanFactory directly.
public void registerSingleton(String name, Class clazz, MutablePropertyValues pvs) throws BeansException
For more advanced needs, register with the underlying BeanFactory directly.
public void registerPrototype(String name, Class clazz) throws BeansException
For more advanced needs, register with the underlying BeanFactory directly.
public void registerPrototype(String name, Class clazz, MutablePropertyValues pvs) throws BeansException
For more advanced needs, register with the underlying BeanFactory directly.
public void addMessage(String code, Locale locale, String defaultMessage)
code - lookup codelocale - locale message should be found withindefaultMessage - message associated with this lookup codegetStaticMessageSource()