|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.test.context.support.AbstractContextLoader org.springframework.test.context.support.AbstractGenericContextLoader
public abstract class AbstractGenericContextLoader
Abstract, generic extension of AbstractContextLoader
that loads a
GenericApplicationContext
.
ContextLoader
SPI, the
context will be loaded from the locations provided to
loadContext(String...)
.SmartContextLoader
SPI, the context will be loaded from the MergedContextConfiguration
provided to loadContext(MergedContextConfiguration)
. In such cases, a
SmartContextLoader
will decide whether to load the context from
locations or
configuration classes
.Concrete subclasses must provide an appropriate implementation of
createBeanDefinitionReader()
,
potentially overriding loadBeanDefinitions()
as well.
loadContext(MergedContextConfiguration)
,
loadContext(String...)
Field Summary | |
---|---|
protected static Log |
logger
|
Constructor Summary | |
---|---|
AbstractGenericContextLoader()
|
Method Summary | |
---|---|
protected abstract BeanDefinitionReader |
createBeanDefinitionReader(GenericApplicationContext context)
Factory method for creating a new BeanDefinitionReader for loading
bean definitions into the supplied context . |
protected void |
customizeBeanFactory(DefaultListableBeanFactory beanFactory)
Customize the internal bean factory of the ApplicationContext created by this ContextLoader . |
protected void |
customizeContext(GenericApplicationContext context)
Customize the GenericApplicationContext created by this
ContextLoader after bean definitions have been
loaded into the context but before the context is refreshed. |
protected void |
loadBeanDefinitions(GenericApplicationContext context,
MergedContextConfiguration mergedConfig)
Load bean definitions into the supplied context
from the configuration locations or classes in the supplied
MergedContextConfiguration . |
ConfigurableApplicationContext |
loadContext(MergedContextConfiguration mergedConfig)
Load a Spring ApplicationContext from the supplied MergedContextConfiguration . |
ConfigurableApplicationContext |
loadContext(String... locations)
Load a Spring ApplicationContext from the supplied locations . |
protected void |
prepareContext(GenericApplicationContext context)
Prepare the GenericApplicationContext created by this ContextLoader . |
Methods inherited from class org.springframework.test.context.support.AbstractContextLoader |
---|
generateDefaultLocations, getResourceSuffix, isGenerateDefaultLocations, modifyLocations, processContextConfiguration, processLocations |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Log logger
Constructor Detail |
---|
public AbstractGenericContextLoader()
Method Detail |
---|
public final ConfigurableApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception
MergedContextConfiguration
.
Implementation details:
GenericApplicationContext
instance.MergedContextConfiguration
in the
Environment
of the context.#prepareContext()
to allow for customizing the context
before bean definitions are loaded.#customizeBeanFactory()
to allow for customizing the
context's DefaultListableBeanFactory
.#loadBeanDefinitions()
to populate the context
from the configuration locations or classes in the supplied
MergedContextConfiguration
.AnnotationConfigUtils
for
registering
annotation configuration processors.#customizeContext()
to allow for customizing the context
before it is refreshed.Refreshes
the
context and registers a JVM shutdown hook for it.
mergedConfig
- the merged context configuration to use to load the
application context
Exception
- if context loading failedSmartContextLoader.loadContext(MergedContextConfiguration)
,
GenericApplicationContext
public final ConfigurableApplicationContext loadContext(String... locations) throws Exception
locations
.
Implementation details:
GenericApplicationContext
instance.#prepareContext()
to allow for customizing the context
before bean definitions are loaded.#customizeBeanFactory()
to allow for customizing the
context's DefaultListableBeanFactory
.#createBeanDefinitionReader()
to create a
BeanDefinitionReader
which is then used to populate the context
from the specified config locations.AnnotationConfigUtils
for
registering
annotation configuration processors.#customizeContext()
to allow for customizing the context
before it is refreshed.Refreshes
the
context and registers a JVM shutdown hook for it.Note: this method does not provide a means to set active bean definition
profiles for the loaded context. See loadContext(MergedContextConfiguration)
for an alternative.
locations
- the resource locations to use to load the application context
Exception
- if context loading failedContextLoader.loadContext(java.lang.String...)
,
GenericApplicationContext
,
loadContext(MergedContextConfiguration)
protected void prepareContext(GenericApplicationContext context)
GenericApplicationContext
created by this ContextLoader
.
Called before bean definitions are read.
The default implementation is empty. Can be overridden in subclasses to
customize GenericApplicationContext
's standard settings.
context
- the context that should be preparedloadContext(MergedContextConfiguration)
,
loadContext(String...)
,
GenericApplicationContext.setAllowBeanDefinitionOverriding(boolean)
,
GenericApplicationContext.setResourceLoader(org.springframework.core.io.ResourceLoader)
,
GenericApplicationContext.setId(java.lang.String)
protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory)
ContextLoader
.
The default implementation is empty but can be overridden in subclasses
to customize DefaultListableBeanFactory
's standard settings.
beanFactory
- the bean factory created by this ContextLoader
loadContext(MergedContextConfiguration)
,
loadContext(String...)
,
DefaultListableBeanFactory.setAllowBeanDefinitionOverriding(boolean)
,
DefaultListableBeanFactory.setAllowEagerClassLoading(boolean)
,
AbstractAutowireCapableBeanFactory.setAllowCircularReferences(boolean)
,
AbstractAutowireCapableBeanFactory.setAllowRawInjectionDespiteWrapping(boolean)
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig)
context
from the configuration locations or classes in the supplied
MergedContextConfiguration
.
The default implementation delegates to the BeanDefinitionReader
returned by #createBeanDefinitionReader()
to
load
the
bean definitions.
Subclasses must provide an appropriate implementation of
#createBeanDefinitionReader()
. Alternatively subclasses may
provide a no-op implementation of createBeanDefinitionReader()
and override this method to provide a custom strategy for loading or
registering bean definitions.
context
- the context into which the bean definitions should be loadedmergedConfig
- the merged context configurationloadContext(MergedContextConfiguration)
protected abstract BeanDefinitionReader createBeanDefinitionReader(GenericApplicationContext context)
BeanDefinitionReader
for loading
bean definitions into the supplied context
.
context
- the context for which the BeanDefinitionReader
should be created
BeanDefinitionReader
for the supplied contextloadContext(String...)
,
loadBeanDefinitions(org.springframework.context.support.GenericApplicationContext, org.springframework.test.context.MergedContextConfiguration)
,
BeanDefinitionReader
protected void customizeContext(GenericApplicationContext context)
GenericApplicationContext
created by this
ContextLoader
after bean definitions have been
loaded into the context but before the context is refreshed.
The default implementation is empty but can be overridden in subclasses to customize the application context.
context
- the newly created application contextloadContext(MergedContextConfiguration)
,
loadContext(String...)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |