protected Map< Class< ? extends Annotation >, Collection< Class< ? > > > findClassesInternal(
Collection< String > basePackages, List<Class< ? extends Annotation > > annotations)
throws IOException, ClassNotFoundException {
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
MetadataReaderFactory factory = new CachingMetadataReaderFactory(resolver);
final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes =
new HashMap< Class< ? extends Annotation >, Collection< Class< ? > > >();
final Map< Class< ? extends Annotation >, Collection< String > > matchingInterfaces =
new HashMap< Class< ? extends Annotation >, Collection< String > >();
final Map<String, String[]> nonMatchingClasses = new HashMap<String, String[]>();
for (Class< ? extends Annotation > annotation: annotations) {
classes.put(annotation, new HashSet< Class < ? > >());
matchingInterfaces.put(annotation, new HashSet< String >());
}
if (basePackages == null || basePackages.isEmpty()) {
return classes;
}
for (final String basePackage: basePackages) {
final boolean scanAllPackages = basePackage.equals(ALL_PACKAGES);
final String packageSearchPath = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
+ (scanAllPackages ? "" : ClassUtils.convertClassNameToResourcePath(basePackage))
+ ALL_CLASS_FILES;
final Resource[] resources = resolver.getResources(packageSearchPath);
for (final Resource resource: resources) {
final MetadataReader reader = factory.getMetadataReader(resource);
final AnnotationMetadata metadata = reader.getAnnotationMetadata();