|
16 | 16 |
|
17 | 17 | package org.springframework.boot.test.context;
|
18 | 18 |
|
| 19 | +import java.lang.annotation.Annotation; |
19 | 20 | import java.util.Collections;
|
20 | 21 | import java.util.LinkedHashMap;
|
21 | 22 | import java.util.Map;
|
|
29 | 30 | import org.springframework.util.ClassUtils;
|
30 | 31 |
|
31 | 32 | /**
|
32 |
| - * Internal utility class to scan for a {@link SpringBootConfiguration} class. |
| 33 | + * Utility class to scan for a {@link SpringBootConfiguration} or custom annotation. |
33 | 34 | *
|
34 | 35 | * @author Phillip Webb
|
| 36 | + * @author Artsiom Yudovin |
| 37 | + * @since 2.1.0 |
35 | 38 | */
|
36 |
| -final class SpringBootConfigurationFinder { |
| 39 | +public final class SpringBootConfigurationFinder { |
37 | 40 |
|
38 | 41 | private static final Map<String, Class<?>> cache = Collections
|
39 | 42 | .synchronizedMap(new Cache(40));
|
40 | 43 |
|
41 | 44 | private final ClassPathScanningCandidateComponentProvider scanner;
|
42 | 45 |
|
43 |
| - SpringBootConfigurationFinder() { |
| 46 | + /** |
| 47 | + * Default constructor initializing finder to scan for a {@link SpringBootConfiguration} annotation. |
| 48 | + */ |
| 49 | + public SpringBootConfigurationFinder() { |
| 50 | + this(SpringBootConfiguration.class); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Customiable constructor allow to provide the custom annotation to scan for. |
| 55 | + * @param annotationType Annotation to scan for. |
| 56 | + */ |
| 57 | + public SpringBootConfigurationFinder(Class<? extends Annotation> annotationType) { |
44 | 58 | this.scanner = new ClassPathScanningCandidateComponentProvider(false);
|
45 | 59 | this.scanner.addIncludeFilter(
|
46 |
| - new AnnotationTypeFilter(SpringBootConfiguration.class)); |
| 60 | + new AnnotationTypeFilter(annotationType)); |
47 | 61 | this.scanner.setResourcePattern("*.class");
|
48 | 62 | }
|
49 | 63 |
|
|
0 commit comments