|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2013 the original author or authors. |
| 2 | + * Copyright 2002-2014 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
17 | 17 | package org.springframework.context.annotation;
|
18 | 18 |
|
19 | 19 | import java.io.IOException;
|
| 20 | +import java.util.HashSet; |
| 21 | +import java.util.Set; |
20 | 22 |
|
21 | 23 | import org.apache.commons.logging.Log;
|
22 | 24 | import org.apache.commons.logging.LogFactory;
|
@@ -46,8 +48,18 @@ abstract class ConfigurationClassUtils {
|
46 | 48 | private static final String CONFIGURATION_CLASS_ATTRIBUTE =
|
47 | 49 | Conventions.getQualifiedAttributeName(ConfigurationClassPostProcessor.class, "configurationClass");
|
48 | 50 |
|
| 51 | + |
49 | 52 | private static final Log logger = LogFactory.getLog(ConfigurationClassUtils.class);
|
50 | 53 |
|
| 54 | + private static final Set<String> candidateIndicators = new HashSet<String>(4); |
| 55 | + |
| 56 | + static { |
| 57 | + candidateIndicators.add(Component.class.getName()); |
| 58 | + candidateIndicators.add(ComponentScan.class.getName()); |
| 59 | + candidateIndicators.add(Import.class.getName()); |
| 60 | + candidateIndicators.add(ImportResource.class.getName()); |
| 61 | + } |
| 62 | + |
51 | 63 |
|
52 | 64 | /**
|
53 | 65 | * Check whether the given bean definition is a candidate for a configuration class
|
@@ -119,16 +131,23 @@ public static boolean isFullConfigurationCandidate(AnnotationMetadata metadata)
|
119 | 131 |
|
120 | 132 | /**
|
121 | 133 | * Check the given metadata for a lite configuration class candidate
|
122 |
| - * (i.e. a class annotated with {@code @Component} or just having |
| 134 | + * (e.g. a class annotated with {@code @Component} or just having |
123 | 135 | * {@code @Import} declarations or {@code @Bean methods}).
|
124 | 136 | * @param metadata the metadata of the annotated class
|
125 | 137 | * @return {@code true} if the given class is to be processed as a lite
|
126 | 138 | * configuration class, just registering it and scanning it for {@code @Bean} methods
|
127 | 139 | */
|
128 | 140 | public static boolean isLiteConfigurationCandidate(AnnotationMetadata metadata) {
|
129 | 141 | // Do not consider an interface or an annotation...
|
130 |
| - return (!metadata.isInterface() && (metadata.isAnnotated(Component.class.getName()) || |
131 |
| - metadata.isAnnotated(Import.class.getName()) || metadata.hasAnnotatedMethods(Bean.class.getName()))); |
| 142 | + if (metadata.isInterface()) { |
| 143 | + return false; |
| 144 | + } |
| 145 | + for (String indicator : candidateIndicators) { |
| 146 | + if (metadata.isAnnotated(indicator)) { |
| 147 | + return true; |
| 148 | + } |
| 149 | + } |
| 150 | + return metadata.hasAnnotatedMethods(Bean.class.getName()); |
132 | 151 | }
|
133 | 152 |
|
134 | 153 | /**
|
|
0 commit comments