|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.test.context.support.AbstractContextLoader
org.springframework.test.context.support.AbstractGenericContextLoader
org.springframework.test.context.support.AnnotationConfigContextLoader
public class AnnotationConfigContextLoader
Concrete implementation of AbstractGenericContextLoader that loads
bean definitions from
configuration classes.
Note: AnnotationConfigContextLoader supports
configuration classes
rather than the String-based resource locations defined by the legacy
ContextLoader API. Thus,
although AnnotationConfigContextLoader extends
AbstractGenericContextLoader, AnnotationConfigContextLoader
does not support any String-based methods defined by
AbstractContextLoader or AbstractGenericContextLoader.
Consequently, AnnotationConfigContextLoader should chiefly be
considered a SmartContextLoader
rather than a ContextLoader.
#processContextConfiguration(),
#detectDefaultConfigurationClasses(),
#loadBeanDefinitions()| Constructor Summary | |
|---|---|
AnnotationConfigContextLoader()
|
|
| Method Summary | |
|---|---|
protected BeanDefinitionReader |
createBeanDefinitionReader(GenericApplicationContext context)
AnnotationConfigContextLoader should be used as a
SmartContextLoader,
not as a legacy ContextLoader. |
protected Class<?>[] |
detectDefaultConfigurationClasses(Class<?> declaringClass)
Detect the default configuration classes for the supplied test class. |
protected String[] |
generateDefaultLocations(Class<?> clazz)
AnnotationConfigContextLoader should be used as a
SmartContextLoader,
not as a legacy ContextLoader. |
protected String |
getResourceSuffix()
AnnotationConfigContextLoader should be used as a
SmartContextLoader,
not as a legacy ContextLoader. |
protected void |
loadBeanDefinitions(GenericApplicationContext context,
MergedContextConfiguration mergedConfig)
Register configuration classes
in the supplied context from the classes
in the supplied MergedContextConfiguration. |
protected String[] |
modifyLocations(Class<?> clazz,
String... locations)
AnnotationConfigContextLoader should be used as a
SmartContextLoader,
not as a legacy ContextLoader. |
void |
processContextConfiguration(ContextConfigurationAttributes configAttributes)
Process configuration classes in the supplied ContextConfigurationAttributes. |
| Methods inherited from class org.springframework.test.context.support.AbstractGenericContextLoader |
|---|
customizeBeanFactory, customizeContext, loadContext, loadContext, prepareContext |
| Methods inherited from class org.springframework.test.context.support.AbstractContextLoader |
|---|
isGenerateDefaultLocations, processLocations |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AnnotationConfigContextLoader()
| Method Detail |
|---|
public void processContextConfiguration(ContextConfigurationAttributes configAttributes)
ContextConfigurationAttributes.
If the configuration classes are null or empty and
AbstractContextLoader.isGenerateDefaultLocations() returns true, this
SmartContextLoader will attempt to detect default configuration classes.
If defaults are detected they will be
set in the
supplied configuration attributes. Otherwise, properties in the supplied
configuration attributes will not be modified.
processContextConfiguration in interface SmartContextLoaderprocessContextConfiguration in class AbstractContextLoaderconfigAttributes - the context configuration attributes to processorg.springframework.test.context.SmartContextLoader#processContextConfiguration(),
AbstractContextLoader.isGenerateDefaultLocations(),
#detectDefaultConfigurationClasses()protected Class<?>[] detectDefaultConfigurationClasses(Class<?> declaringClass)
The returned class array will contain all static inner classes of
the supplied class that meet the requirements for @Configuration
class implementations as specified in the documentation for
@Configuration.
The implementation of this method adheres to the contract defined in the
SmartContextLoader
SPI. Specifically, this method uses introspection to detect default
configuration classes that comply with the constraints required of
@Configuration class implementations. If a potential candidate
configuration class does meet these requirements, this method will log a
warning, and the potential candidate class will be ignored.
declaringClass - the test class that declared @ContextConfiguration
null
protected String[] modifyLocations(Class<?> clazz,
String... locations)
AnnotationConfigContextLoader should be used as a
SmartContextLoader,
not as a legacy ContextLoader.
Consequently, this method is not supported.
modifyLocations in class AbstractContextLoaderclazz - the class with which the locations are associatedlocations - the resource locations to be modified
UnsupportedOperationExceptionAbstractContextLoader.modifyLocations(java.lang.Class>, java.lang.String...)protected String[] generateDefaultLocations(Class<?> clazz)
AnnotationConfigContextLoader should be used as a
SmartContextLoader,
not as a legacy ContextLoader.
Consequently, this method is not supported.
generateDefaultLocations in class AbstractContextLoaderclazz - the class for which the default locations are to be generated
UnsupportedOperationExceptionAbstractContextLoader.generateDefaultLocations(java.lang.Class>)protected String getResourceSuffix()
AnnotationConfigContextLoader should be used as a
SmartContextLoader,
not as a legacy ContextLoader.
Consequently, this method is not supported.
getResourceSuffix in class AbstractContextLoadernull or empty
UnsupportedOperationExceptionAbstractContextLoader.getResourceSuffix()
protected void loadBeanDefinitions(GenericApplicationContext context,
MergedContextConfiguration mergedConfig)
configuration classes
in the supplied context from the classes
in the supplied MergedContextConfiguration.
Each class must represent an annotated configuration class or component. An
AnnotatedBeanDefinitionReader is used to register the appropriate
bean definitions.
Note that this method does not call createBeanDefinitionReader(org.springframework.context.support.GenericApplicationContext)
since AnnotatedBeanDefinitionReader is not an instance of
BeanDefinitionReader.
loadBeanDefinitions in class AbstractGenericContextLoadercontext - the context in which the configuration classes should be registeredmergedConfig - the merged configuration from which the classes should be retrievedAbstractGenericContextLoader.loadBeanDefinitions(org.springframework.context.support.GenericApplicationContext, org.springframework.test.context.MergedContextConfiguration)protected BeanDefinitionReader createBeanDefinitionReader(GenericApplicationContext context)
AnnotationConfigContextLoader should be used as a
SmartContextLoader,
not as a legacy ContextLoader.
Consequently, this method is not supported.
createBeanDefinitionReader in class AbstractGenericContextLoadercontext - the context for which the BeanDefinitionReader
should be created
BeanDefinitionReader for the supplied context
UnsupportedOperationExceptionloadBeanDefinitions(org.springframework.context.support.GenericApplicationContext, org.springframework.test.context.MergedContextConfiguration),
AbstractGenericContextLoader.createBeanDefinitionReader(org.springframework.context.support.GenericApplicationContext)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||