Top Description Fields Constructors Methods
org.springframework.context.support

public Class StaticApplicationContext

extends GenericApplicationContext
Class Inheritance
Imports
java.util.Locale, org.springframework.beans.BeansException, .MutablePropertyValues, org.springframework.beans.factory.config.BeanDefinition, org.springframework.beans.factory.support.GenericBeanDefinition, org.springframework.context.ApplicationContext, org.springframework.lang.Nullable

org.springframework.context.ApplicationContext implementation which supports programmatic registration of beans and messages, rather than reading bean definitions from external configuration sources. Mainly useful for testing.
Authors
Rod Johnson, Juergen Hoeller
See Also
registerSingleton, registerPrototype, registerBeanDefinition, refresh

Field Summary

Modifier and TypeField and Description
private final StaticMessageSource

Constructor Summary

AccessConstructor and Description
public
StaticApplicationContext()

Create a new StaticApplicationContext.

public
StaticApplicationContext(ApplicationContext parent)

Create a new StaticApplicationContext with the given parent.

Method Summary

Modifier and TypeMethod and Description
public void
addMessage(String
lookup code
code
,
Locale
the locale message should be found within
locale
,
String
message associated with this lookup code
defaultMessage
)

Associate the given message with the given code.

protected void
assertBeanFactoryActive()

Overrides org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive.

Overridden to turn it into a no-op, to be more lenient towards test cases.

public final StaticMessageSource
getStaticMessageSource()

Return the internal StaticMessageSource used by this context.

public void
registerPrototype(String name, Class<?> clazz)

Register a prototype bean with the underlying bean factory.

public void
registerPrototype(String name, Class<?> clazz, MutablePropertyValues pvs)

Register a prototype bean with the underlying bean factory.

public void
registerSingleton(String name, Class<?> clazz)

Register a singleton bean with the underlying bean factory.

public void
registerSingleton(String name, Class<?> clazz, MutablePropertyValues pvs)

Register a singleton bean with the underlying bean factory.

Inherited from org.springframework.context.support.GenericApplicationContext:
cancelRefreshcloseBeanFactorygetAutowireCapableBeanFactorygetBeanDefinitiongetBeanFactorygetClassLoadergetDefaultListableBeanFactorygetResourcegetResourcesisAliasisBeanDefinitionOverridableisBeanNameInUserefreshBeanFactoryrefreshForAotProcessingregisterAliasregisterBeanregisterBeanregisterBeanregisterBeanregisterBeanregisterBeanregisterBeanDefinitionremoveAliasremoveBeanDefinitionsetAllowBeanDefinitionOverridingsetAllowCircularReferencessetApplicationStartupsetClassLoadersetParentsetResourceLoader

Field Detail

staticMessageSourceback to summary
private final StaticMessageSource staticMessageSource

Constructor Detail

StaticApplicationContextback to summary
public StaticApplicationContext() throws BeansException

Create a new StaticApplicationContext.

See Also
registerSingleton, registerPrototype, registerBeanDefinition, refresh
StaticApplicationContextback to summary
public StaticApplicationContext(ApplicationContext parent) throws BeansException

Create a new StaticApplicationContext with the given parent.

See Also
registerSingleton, registerPrototype, registerBeanDefinition, refresh

Method Detail

addMessageback to summary
public void addMessage(String code, Locale locale, String defaultMessage)

Associate the given message with the given code.

Parameters
code:String

lookup code

locale:Locale

the locale message should be found within

defaultMessage:String

message associated with this lookup code

See Also
getStaticMessageSource
assertBeanFactoryActiveback to summary
protected void assertBeanFactoryActive()

Overrides org.springframework.context.support.AbstractApplicationContext.assertBeanFactoryActive.

Overridden to turn it into a no-op, to be more lenient towards test cases.

Annotations
@Override
getStaticMessageSourceback to summary
public final StaticMessageSource getStaticMessageSource()

Return the internal StaticMessageSource used by this context. Can be used to register messages on it.

See Also
addMessage
registerPrototypeback to summary
public void registerPrototype(String name, Class<?> clazz) throws BeansException

Register a prototype bean with the underlying bean factory.

For more advanced needs, register with the underlying BeanFactory directly.

See Also
getDefaultListableBeanFactory
registerPrototypeback to summary
public void registerPrototype(String name, Class<?> clazz, MutablePropertyValues pvs) throws BeansException

Register a prototype bean with the underlying bean factory.

For more advanced needs, register with the underlying BeanFactory directly.

See Also
getDefaultListableBeanFactory
registerSingletonback to summary
public void registerSingleton(String name, Class<?> clazz) throws BeansException

Register a singleton bean with the underlying bean factory.

For more advanced needs, register with the underlying BeanFactory directly.

See Also
getDefaultListableBeanFactory
registerSingletonback to summary
public void registerSingleton(String name, Class<?> clazz, MutablePropertyValues pvs) throws BeansException

Register a singleton bean with the underlying bean factory.

For more advanced needs, register with the underlying BeanFactory directly.

See Also
getDefaultListableBeanFactory