|
1 | 1 | /* |
2 | | - * Copyright 2002-2012 the original author or authors. |
| 2 | + * Copyright 2002-2013 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. |
|
28 | 28 | import org.springframework.core.annotation.AnnotationAttributes; |
29 | 29 | import org.springframework.core.env.Environment; |
30 | 30 | import org.springframework.core.io.ResourceLoader; |
| 31 | +import org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter; |
31 | 32 | import org.springframework.core.type.filter.AnnotationTypeFilter; |
32 | 33 | import org.springframework.core.type.filter.AssignableTypeFilter; |
33 | 34 | import org.springframework.core.type.filter.TypeFilter; |
@@ -64,7 +65,7 @@ public ComponentScanAnnotationParser(ResourceLoader resourceLoader, Environment |
64 | 65 | } |
65 | 66 |
|
66 | 67 |
|
67 | | - public Set<BeanDefinitionHolder> parse(AnnotationAttributes componentScan, String declaringClass) { |
| 68 | + public Set<BeanDefinitionHolder> parse(AnnotationAttributes componentScan, final String declaringClass) { |
68 | 69 | ClassPathBeanDefinitionScanner scanner = |
69 | 70 | new ClassPathBeanDefinitionScanner(this.registry, componentScan.getBoolean("useDefaultFilters")); |
70 | 71 |
|
@@ -120,6 +121,12 @@ public Set<BeanDefinitionHolder> parse(AnnotationAttributes componentScan, Strin |
120 | 121 | basePackages.add(ClassUtils.getPackageName(declaringClass)); |
121 | 122 | } |
122 | 123 |
|
| 124 | + scanner.addExcludeFilter(new AbstractTypeHierarchyTraversingFilter(false, false) { |
| 125 | + @Override |
| 126 | + protected boolean matchClassName(String className) { |
| 127 | + return declaringClass.equals(className); |
| 128 | + } |
| 129 | + }); |
123 | 130 | return scanner.doScan(StringUtils.toStringArray(basePackages)); |
124 | 131 | } |
125 | 132 |
|
|
0 commit comments