66
66
import org .springframework .core .type .classreading .MetadataReader ;
67
67
import org .springframework .core .type .classreading .MetadataReaderFactory ;
68
68
import org .springframework .core .type .filter .AssignableTypeFilter ;
69
+ import org .springframework .util .Assert ;
69
70
import org .springframework .util .LinkedMultiValueMap ;
70
71
import org .springframework .util .MultiValueMap ;
71
72
import org .springframework .util .StringUtils ;
@@ -315,9 +316,7 @@ private void processPropertySource(AnnotationAttributes propertySource) throws I
315
316
String name = propertySource .getString ("name" );
316
317
String [] locations = propertySource .getStringArray ("value" );
317
318
boolean ignoreResourceNotFound = propertySource .getBoolean ("ignoreResourceNotFound" );
318
- if (locations .length == 0 ) {
319
- throw new IllegalArgumentException ("At least one @PropertySource(value) location is required" );
320
- }
319
+ Assert .isTrue (locations .length > 0 , "At least one @PropertySource(value) location is required" );
321
320
for (String location : locations ) {
322
321
try {
323
322
String resolvedLocation = this .environment .resolveRequiredPlaceholders (location );
@@ -401,6 +400,7 @@ private void processImports(ConfigurationClass configClass, SourceClass currentS
401
400
if (importCandidates .isEmpty ()) {
402
401
return ;
403
402
}
403
+
404
404
if (checkForCircularImports && this .importStack .contains (configClass )) {
405
405
this .problemReporter .error (new CircularImportProblem (configClass , this .importStack , configClass .getMetadata ()));
406
406
}
@@ -409,12 +409,13 @@ private void processImports(ConfigurationClass configClass, SourceClass currentS
409
409
try {
410
410
for (SourceClass candidate : importCandidates ) {
411
411
if (candidate .isAssignable (ImportSelector .class )) {
412
- // the candidate class is an ImportSelector -> delegate to it to determine imports
412
+ // Candidate class is an ImportSelector -> delegate to it to determine imports
413
413
Class <?> candidateClass = candidate .loadClass ();
414
414
ImportSelector selector = BeanUtils .instantiateClass (candidateClass , ImportSelector .class );
415
415
invokeAwareMethods (selector );
416
416
if (selector instanceof DeferredImportSelector ) {
417
- this .deferredImportSelectors .add (new DeferredImportSelectorHolder (configClass , (DeferredImportSelector ) selector ));
417
+ this .deferredImportSelectors .add (
418
+ new DeferredImportSelectorHolder (configClass , (DeferredImportSelector ) selector ));
418
419
}
419
420
else {
420
421
String [] importClassNames = selector .selectImports (currentSourceClass .getMetadata ());
@@ -423,15 +424,19 @@ private void processImports(ConfigurationClass configClass, SourceClass currentS
423
424
}
424
425
}
425
426
else if (candidate .isAssignable (ImportBeanDefinitionRegistrar .class )) {
426
- // the candidate class is an ImportBeanDefinitionRegistrar -> delegate to it to register additional bean definitions
427
+ // Candidate class is an ImportBeanDefinitionRegistrar ->
428
+ // delegate to it to register additional bean definitions
427
429
Class <?> candidateClass = candidate .loadClass ();
428
- ImportBeanDefinitionRegistrar registrar = BeanUtils .instantiateClass (candidateClass , ImportBeanDefinitionRegistrar .class );
430
+ ImportBeanDefinitionRegistrar registrar =
431
+ BeanUtils .instantiateClass (candidateClass , ImportBeanDefinitionRegistrar .class );
429
432
invokeAwareMethods (registrar );
430
433
configClass .addImportBeanDefinitionRegistrar (registrar , currentSourceClass .getMetadata ());
431
434
}
432
435
else {
433
- // candidate class not an ImportSelector or ImportBeanDefinitionRegistrar -> process it as a @Configuration class
434
- this .importStack .registerImport (currentSourceClass .getMetadata (), candidate .getMetadata ().getClassName ());
436
+ // Candidate class not an ImportSelector or ImportBeanDefinitionRegistrar ->
437
+ // process it as a @Configuration class
438
+ this .importStack .registerImport (
439
+ currentSourceClass .getMetadata (), candidate .getMetadata ().getClassName ());
435
440
processConfigurationClass (candidate .asConfigClass (configClass ));
436
441
}
437
442
}
@@ -645,12 +650,12 @@ public DeferredImportSelector getImportSelector() {
645
650
646
651
647
652
/**
648
- * Simple wrapper that allows annotated source classes to be dealt with in a uniform
649
- * manor , regardless of how they are loaded.
653
+ * Simple wrapper that allows annotated source classes to be dealt with
654
+ * in a uniform manner , regardless of how they are loaded.
650
655
*/
651
656
private class SourceClass {
652
657
653
- private final Object source ; // Class or MetaDataReader
658
+ private final Object source ; // Class or MetadataReader
654
659
655
660
private final AnnotationMetadata metadata ;
656
661
0 commit comments