类 AnnotationConfigContextLoader
- java.lang.Object
- org.springframework.test.context.support.AbstractContextLoader
- org.springframework.test.context.support.AbstractGenericContextLoader
- org.springframework.test.context.support.AnnotationConfigContextLoader
- 所有已实现的接口:
ContextLoader
,SmartContextLoader
public class AnnotationConfigContextLoader extends AbstractGenericContextLoader
Concrete implementation ofAbstractGenericContextLoader
that loads bean definitions from component classes.See the Javadoc for
@ContextConfiguration
for a definition of component class.Note:
AnnotationConfigContextLoader
supports component classes rather than the String-based resource locations defined by the legacyContextLoader
API. Thus, althoughAnnotationConfigContextLoader
extendsAbstractGenericContextLoader
,AnnotationConfigContextLoader
does not support any String-based methods defined byAbstractContextLoader
orAbstractGenericContextLoader
. Consequently,AnnotationConfigContextLoader
should chiefly be considered aSmartContextLoader
rather than aContextLoader
.
构造器概要
构造器 构造器 说明 AnnotationConfigContextLoader()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected BeanDefinitionReader
createBeanDefinitionReader(GenericApplicationContext context)
AnnotationConfigContextLoader
should be used as aSmartContextLoader
, not as a legacyContextLoader
.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 aSmartContextLoader
, not as a legacyContextLoader
.protected String
getResourceSuffix()
AnnotationConfigContextLoader
should be used as aSmartContextLoader
, not as a legacyContextLoader
.protected void
loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig)
Register classes in the suppliedcontext
from the classes in the suppliedMergedContextConfiguration
.protected String[]
modifyLocations(Class<?> clazz, String... locations)
AnnotationConfigContextLoader
should be used as aSmartContextLoader
, not as a legacyContextLoader
.void
processContextConfiguration(ContextConfigurationAttributes configAttributes)
Process component classes in the suppliedContextConfigurationAttributes
.protected void
validateMergedContextConfiguration(MergedContextConfiguration mergedConfig)
Ensure that the suppliedMergedContextConfiguration
does not containlocations
.从类继承的方法 org.springframework.test.context.support.AbstractGenericContextLoader
createContext, customizeBeanFactory, customizeContext, loadContext, loadContext, prepareContext
从类继承的方法 org.springframework.test.context.support.AbstractContextLoader
customizeContext, getResourceSuffixes, isGenerateDefaultLocations, prepareContext, processLocations
构造器详细资料
AnnotationConfigContextLoader
public AnnotationConfigContextLoader()
方法详细资料
processContextConfiguration
public void processContextConfiguration(ContextConfigurationAttributes configAttributes)
Process component classes in the suppliedContextConfigurationAttributes
.If the component classes are
null
or empty andAbstractContextLoader.isGenerateDefaultLocations()
returnstrue
, thisSmartContextLoader
will attempt todetect default configuration classes
. If defaults are detected they will beset
in the supplied configuration attributes. Otherwise, properties in the supplied configuration attributes will not be modified.- 指定者:
processContextConfiguration
在接口中SmartContextLoader
- 覆盖:
processContextConfiguration
在类中AbstractContextLoader
- 参数:
configAttributes
- the context configuration attributes to process- 另请参阅:
SmartContextLoader.processContextConfiguration(ContextConfigurationAttributes)
,AbstractContextLoader.isGenerateDefaultLocations()
,detectDefaultConfigurationClasses(Class)
detectDefaultConfigurationClasses
protected Class<?>[] detectDefaultConfigurationClasses(Class<?> declaringClass)
Detect the default configuration classes for the supplied test class.The default implementation simply delegates to
AnnotationConfigContextLoaderUtils.detectDefaultConfigurationClasses(Class)
.- 参数:
declaringClass
- the test class that declared@ContextConfiguration
- 返回:
- an array of default configuration classes, potentially empty but never
null
- 另请参阅:
AnnotationConfigContextLoaderUtils
modifyLocations
protected String[] modifyLocations(Class<?> clazz, String... locations)
AnnotationConfigContextLoader
should be used as aSmartContextLoader
, not as a legacyContextLoader
. Consequently, this method is not supported.- 覆盖:
modifyLocations
在类中AbstractContextLoader
- 参数:
clazz
- the class with which the locations are associatedlocations
- the resource locations to be modified- 返回:
- an array of modified application context resource locations
- 抛出:
UnsupportedOperationException
- in this implementation- 另请参阅:
AbstractContextLoader.modifyLocations(java.lang.Class<?>, java.lang.String...)
generateDefaultLocations
protected String[] generateDefaultLocations(Class<?> clazz)
AnnotationConfigContextLoader
should be used as aSmartContextLoader
, not as a legacyContextLoader
. Consequently, this method is not supported.- 覆盖:
generateDefaultLocations
在类中AbstractContextLoader
- 参数:
clazz
- the class for which the default locations are to be generated- 返回:
- an array of default application context resource locations
- 抛出:
UnsupportedOperationException
- in this implementation- 另请参阅:
AbstractContextLoader.generateDefaultLocations(java.lang.Class<?>)
getResourceSuffix
protected String getResourceSuffix()
AnnotationConfigContextLoader
should be used as aSmartContextLoader
, not as a legacyContextLoader
. Consequently, this method is not supported.- 指定者:
getResourceSuffix
在类中AbstractContextLoader
- 返回:
- the resource suffix; never
null
or empty - 抛出:
UnsupportedOperationException
- in this implementation- 另请参阅:
AbstractContextLoader.getResourceSuffix()
validateMergedContextConfiguration
protected void validateMergedContextConfiguration(MergedContextConfiguration mergedConfig)
Ensure that the suppliedMergedContextConfiguration
does not containlocations
.- 覆盖:
validateMergedContextConfiguration
在类中AbstractGenericContextLoader
- 参数:
mergedConfig
- the merged configuration to validate- 从以下版本开始:
- 4.0.4
- 另请参阅:
AbstractGenericContextLoader.validateMergedContextConfiguration(org.springframework.test.context.MergedContextConfiguration)
loadBeanDefinitions
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig)
Register classes in the suppliedcontext
from the classes in the suppliedMergedContextConfiguration
.Each class must represent a component class. An
AnnotatedBeanDefinitionReader
is used to register the appropriate bean definitions.Note that this method does not call
createBeanDefinitionReader(org.springframework.context.support.GenericApplicationContext)
sinceAnnotatedBeanDefinitionReader
is not an instance ofBeanDefinitionReader
.- 覆盖:
loadBeanDefinitions
在类中AbstractGenericContextLoader
- 参数:
context
- the context in which the component classes should be registeredmergedConfig
- the merged configuration from which the classes should be retrieved- 另请参阅:
AbstractGenericContextLoader.loadBeanDefinitions(org.springframework.context.support.GenericApplicationContext, org.springframework.test.context.MergedContextConfiguration)
createBeanDefinitionReader
protected BeanDefinitionReader createBeanDefinitionReader(GenericApplicationContext context)
AnnotationConfigContextLoader
should be used as aSmartContextLoader
, not as a legacyContextLoader
. Consequently, this method is not supported.- 指定者:
createBeanDefinitionReader
在类中AbstractGenericContextLoader
- 参数:
context
- the context for which theBeanDefinitionReader
should be created- 返回:
- a
BeanDefinitionReader
for the supplied context - 抛出:
UnsupportedOperationException
- in this implementation- 另请参阅:
loadBeanDefinitions(org.springframework.context.support.GenericApplicationContext, org.springframework.test.context.MergedContextConfiguration)
,AbstractGenericContextLoader.createBeanDefinitionReader(org.springframework.context.support.GenericApplicationContext)