Description
Diego Plentz opened SPR-12802 and commented
ClassPathScanningCandidateComponentProvider doesn't find interfaces when used with AnnotationTypeFilter. AnnotationTypeFilter has a constructor that explicitly says that it can be used to find annotated interfaces:
public AnnotationTypeFilter(Class<? extends Annotation> annotationType,
boolean considerMetaAnnotations,
boolean considerInterfaces)
Create a new AnnotationTypeFilter for the given annotation type.
Parameters:
annotationType - the annotation type to match
considerMetaAnnotations - whether to also match on meta-annotations
considerInterfaces - whether to also match interfaces
But, since ClassPathScanningCandidateComponentProvider implementation filter interfaces out in the isCandidateComponent(AnnotatedBeanDefinition beanDefinition) method, the type filter doesn't work as expected.
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider();
provider.addIncludeFilter(new AnnotationTypeFilter(MyCustomAnnotation.class, false, true));
Set<BeanDefinition> findCandidateComponents = provider.findCandidateComponents("com.foo");
Affects: 4.1.5
Issue Links:
- Introduce a mechanism for abstract types at component scanning [SPR-11663] #16286 Introduce a mechanism for abstract types at component scanning