spring-framework / org.springframework.context.support / StaticApplicationContext

StaticApplicationContext

open class StaticApplicationContext : GenericApplicationContext

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.

Author
Rod Johnson

Author
Juergen Hoeller

See Also
#registerSingleton#registerPrototype#registerBeanDefinition#refresh

Constructors

<init>

StaticApplicationContext()

Create a new StaticApplicationContext.

StaticApplicationContext(parent: ApplicationContext)

Create a new StaticApplicationContext with the given parent.

Functions

addMessage

open fun addMessage(code: String, locale: Locale, defaultMessage: String): Unit

Associate the given message with the given code.

getStaticMessageSource

fun getStaticMessageSource(): StaticMessageSource

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

registerPrototype

open fun registerPrototype(name: String, clazz: Class<*>): Unit
open fun registerPrototype(name: String, clazz: Class<*>, pvs: MutablePropertyValues): Unit

Register a prototype bean with the underlying bean factory.

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

registerSingleton

open fun registerSingleton(name: String, clazz: Class<*>): Unit
open fun registerSingleton(name: String, clazz: Class<*>, pvs: MutablePropertyValues): Unit

Register a singleton bean with the underlying bean factory.

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

Inheritors

StaticWebApplicationContext

open class StaticWebApplicationContext : StaticApplicationContext, ConfigurableWebApplicationContext, ThemeSource

Static org.springframework.web.context.WebApplicationContext implementation for testing. Not intended for use in production applications.

Implements the org.springframework.web.context.ConfigurableWebApplicationContext interface to allow for direct replacement of an XmlWebApplicationContext, despite not actually supporting external configuration files.

Interprets resource paths as servlet context resources, i.e. as paths beneath the web application root. Absolute paths, e.g. for files outside the web app root, can be accessed via "file:" URLs, as implemented by org.springframework.core.io.DefaultResourceLoader.

In addition to the special beans detected by org.springframework.context.support.AbstractApplicationContext, this class detects a bean of type org.springframework.ui.context.ThemeSource in the context, under the special bean name "themeSource".