[SPR-6184] AnnotationConfigContextLoader now calls AnnotationConfigApplicationContext's register(Class<?>...) method in one go, via var-args.
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4142 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
parent
d20150b0d5
commit
3c25a17ddf
|
|
@ -16,15 +16,13 @@
|
|||
|
||||
package org.springframework.test.context.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReader;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* TODO Document AnnotationConfigContextLoader.
|
||||
|
|
@ -56,25 +54,22 @@ public class AnnotationConfigContextLoader extends AbstractGenericContextLoader
|
|||
|
||||
AnnotationConfigApplicationContext annotationConfigApplicationContext = (AnnotationConfigApplicationContext) context;
|
||||
|
||||
List<Class<?>> configClasses = new ArrayList<Class<?>>();
|
||||
for (String location : locations) {
|
||||
Class<?>[] configClasses = new Class<?>[locations.length];
|
||||
for (int i = 0; i < locations.length; i++) {
|
||||
try {
|
||||
Class<?> clazz = getClass().getClassLoader().loadClass(location);
|
||||
configClasses.add(clazz);
|
||||
Class<?> clazz = getClass().getClassLoader().loadClass(locations[i]);
|
||||
configClasses[i] = clazz;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"The supplied resource location [%s] does not represent a class.", location), e);
|
||||
"The supplied resource location [%s] does not represent a class.", locations[i]), e);
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Registering configuration classes: " + configClasses);
|
||||
}
|
||||
|
||||
for (Class<?> configClass : configClasses) {
|
||||
annotationConfigApplicationContext.register(configClass);
|
||||
logger.debug("Registering configuration classes: " + ObjectUtils.nullSafeToString(configClasses));
|
||||
}
|
||||
annotationConfigApplicationContext.register(configClasses);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue