类 AnnotationConfigWebContextLoader
- java.lang.Object
- org.springframework.test.context.support.AbstractContextLoader
- org.springframework.test.context.web.AbstractGenericWebContextLoader
- org.springframework.test.context.web.AnnotationConfigWebContextLoader
- 所有已实现的接口:
ContextLoader,SmartContextLoader
public class AnnotationConfigWebContextLoader extends AbstractGenericWebContextLoader
Concrete implementation ofAbstractGenericWebContextLoaderthat loads bean definitions from annotated classes.See the Javadoc for
@ContextConfigurationfor a definition of annotated class.Note:
AnnotationConfigWebContextLoadersupports annotated classes rather than the String-based resource locations defined by the legacyContextLoaderAPI. Thus, althoughAnnotationConfigWebContextLoaderextendsAbstractGenericWebContextLoader,AnnotationConfigWebContextLoaderdoes not support any String-based methods defined byAbstractContextLoaderorAbstractGenericWebContextLoader. Consequently,AnnotationConfigWebContextLoadershould chiefly be considered aSmartContextLoaderrather than aContextLoader.
构造器概要
构造器 构造器 说明 AnnotationConfigWebContextLoader()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected Class<?>[]detectDefaultConfigurationClasses(Class<?> declaringClass)Detect the default configuration classes for the supplied test class.protected String[]generateDefaultLocations(Class<?> clazz)AnnotationConfigWebContextLoadershould be used as aSmartContextLoader, not as a legacyContextLoader.protected StringgetResourceSuffix()AnnotationConfigWebContextLoadershould be used as aSmartContextLoader, not as a legacyContextLoader.protected voidloadBeanDefinitions(GenericWebApplicationContext context, WebMergedContextConfiguration webMergedConfig)Register classes in the supplied context from the classes in the suppliedWebMergedContextConfiguration.protected String[]modifyLocations(Class<?> clazz, String... locations)AnnotationConfigWebContextLoadershould be used as aSmartContextLoader, not as a legacyContextLoader.voidprocessContextConfiguration(ContextConfigurationAttributes configAttributes)Process annotated classes in the suppliedContextConfigurationAttributes.protected voidvalidateMergedContextConfiguration(WebMergedContextConfiguration webMergedConfig)Ensure that the suppliedWebMergedContextConfigurationdoes not containlocations.从类继承的方法 org.springframework.test.context.web.AbstractGenericWebContextLoader
configureWebResources, customizeBeanFactory, customizeContext, loadContext, loadContext
从类继承的方法 org.springframework.test.context.support.AbstractContextLoader
customizeContext, getResourceSuffixes, isGenerateDefaultLocations, prepareContext, processLocations
构造器详细资料
AnnotationConfigWebContextLoader
public AnnotationConfigWebContextLoader()
方法详细资料
processContextConfiguration
public void processContextConfiguration(ContextConfigurationAttributes configAttributes)
Process annotated classes in the suppliedContextConfigurationAttributes.If the annotated classes are
nullor empty andAbstractContextLoader.isGenerateDefaultLocations()returnstrue, thisSmartContextLoaderwill 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在接口中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)
AnnotationConfigWebContextLoadershould 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)
AnnotationConfigWebContextLoadershould 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()
AnnotationConfigWebContextLoadershould be used as aSmartContextLoader, not as a legacyContextLoader. Consequently, this method is not supported.- 指定者:
getResourceSuffix在类中AbstractContextLoader- 返回:
- the resource suffix; never
nullor empty - 抛出:
UnsupportedOperationException- in this implementation- 另请参阅:
AbstractContextLoader.getResourceSuffix()
loadBeanDefinitions
protected void loadBeanDefinitions(GenericWebApplicationContext context, WebMergedContextConfiguration webMergedConfig)
Register classes in the supplied context from the classes in the suppliedWebMergedContextConfiguration.Each class must represent an annotated class. An
AnnotatedBeanDefinitionReaderis used to register the appropriate bean definitions.- 指定者:
loadBeanDefinitions在类中AbstractGenericWebContextLoader- 参数:
context- the context in which the annotated classes should be registeredwebMergedConfig- the merged configuration from which the classes should be retrieved- 另请参阅:
AbstractGenericWebContextLoader.loadBeanDefinitions(org.springframework.web.context.support.GenericWebApplicationContext, org.springframework.test.context.web.WebMergedContextConfiguration)
validateMergedContextConfiguration
protected void validateMergedContextConfiguration(WebMergedContextConfiguration webMergedConfig)
Ensure that the suppliedWebMergedContextConfigurationdoes not containlocations.- 覆盖:
validateMergedContextConfiguration在类中AbstractGenericWebContextLoader- 参数:
webMergedConfig- the merged configuration to validate- 从以下版本开始:
- 4.0.4
- 另请参阅:
AbstractGenericWebContextLoader.validateMergedContextConfiguration(org.springframework.test.context.web.WebMergedContextConfiguration)