[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;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionReader;
|
import org.springframework.beans.factory.support.BeanDefinitionReader;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import org.springframework.context.support.GenericApplicationContext;
|
import org.springframework.context.support.GenericApplicationContext;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Document AnnotationConfigContextLoader.
|
* TODO Document AnnotationConfigContextLoader.
|
||||||
|
|
@ -56,25 +54,22 @@ public class AnnotationConfigContextLoader extends AbstractGenericContextLoader
|
||||||
|
|
||||||
AnnotationConfigApplicationContext annotationConfigApplicationContext = (AnnotationConfigApplicationContext) context;
|
AnnotationConfigApplicationContext annotationConfigApplicationContext = (AnnotationConfigApplicationContext) context;
|
||||||
|
|
||||||
List<Class<?>> configClasses = new ArrayList<Class<?>>();
|
Class<?>[] configClasses = new Class<?>[locations.length];
|
||||||
for (String location : locations) {
|
for (int i = 0; i < locations.length; i++) {
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = getClass().getClassLoader().loadClass(location);
|
Class<?> clazz = getClass().getClassLoader().loadClass(locations[i]);
|
||||||
configClasses.add(clazz);
|
configClasses[i] = clazz;
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException e) {
|
catch (ClassNotFoundException e) {
|
||||||
throw new IllegalArgumentException(String.format(
|
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()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Registering configuration classes: " + configClasses);
|
logger.debug("Registering configuration classes: " + ObjectUtils.nullSafeToString(configClasses));
|
||||||
}
|
|
||||||
|
|
||||||
for (Class<?> configClass : configClasses) {
|
|
||||||
annotationConfigApplicationContext.register(configClass);
|
|
||||||
}
|
}
|
||||||
|
annotationConfigApplicationContext.register(configClasses);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue