30
30
import org .springframework .core .BridgeMethodResolver ;
31
31
import org .springframework .core .type .AnnotationMetadata ;
32
32
import org .springframework .core .type .classreading .MetadataReader ;
33
+ import org .springframework .core .type .classreading .MetadataReaderFactory ;
33
34
import org .springframework .core .type .classreading .SimpleMetadataReaderFactory ;
34
35
import org .springframework .util .Assert ;
35
36
@@ -354,30 +355,32 @@ else if (value instanceof Class[]) {
354
355
}
355
356
356
357
/**
357
- * Return a list of attribute maps for all declarations of the given target annotation
358
- * on the given annotated class. Meta annotations are ordered first in the list, and if
359
- * the target annotation is declared directly on the class, its map of attributes will be
358
+ * Return a list of attribute maps for all declarations of the given annotation
359
+ * on the given annotated class using the given MetadataReaderFactory to introspect
360
+ * annotation metadata. Meta-annotations are ordered first in the list, and if the
361
+ * target annotation is declared directly on the class, its map of attributes will be
360
362
* ordered last in the list.
361
363
* @param targetAnnotation the annotation to search for, both locally and as a meta-annotation
362
- * @param annotatedClassName the class to search
364
+ * @param annotatedClassName the class to inspect
363
365
* @param classValuesAsString whether class attributes should be returned as strings
366
+ * @param metadataReaderFactory factory used to create metadata readers for each type
364
367
* @since 3.1
365
- * @see {@link #findAllAnnotationAttributes(Class, String)}
366
368
*/
367
369
public static List <Map <String , Object >> findAllAnnotationAttributes (
368
- Class <? extends Annotation > targetAnnotation , String annotatedClassName , boolean classValuesAsString ) throws IOException {
370
+ Class <? extends Annotation > targetAnnotation , String annotatedClassName ,
371
+ boolean classValuesAsString , MetadataReaderFactory metadataReaderFactory ) throws IOException {
369
372
370
373
List <Map <String , Object >> allAttribs = new ArrayList <Map <String , Object >>();
371
374
372
- MetadataReader reader = new SimpleMetadataReaderFactory () .getMetadataReader (annotatedClassName );
375
+ MetadataReader reader = metadataReaderFactory .getMetadataReader (annotatedClassName );
373
376
AnnotationMetadata metadata = reader .getAnnotationMetadata ();
374
377
String targetAnnotationType = targetAnnotation .getName ();
375
378
376
379
for (String annotationType : metadata .getAnnotationTypes ()) {
377
380
if (annotationType .equals (targetAnnotationType )) {
378
381
continue ;
379
382
}
380
- MetadataReader metaReader = new SimpleMetadataReaderFactory () .getMetadataReader (annotationType );
383
+ MetadataReader metaReader = metadataReaderFactory .getMetadataReader (annotationType );
381
384
Map <String , Object > targetAttribs =
382
385
metaReader .getAnnotationMetadata ().getAnnotationAttributes (targetAnnotationType , classValuesAsString );
383
386
if (targetAttribs != null ) {
@@ -394,21 +397,6 @@ public static List<Map<String, Object>> findAllAnnotationAttributes(
394
397
return allAttribs ;
395
398
}
396
399
397
- /**
398
- * Return a list of attribute maps for all declarations of the given target annotation
399
- * on the given annotated class. Meta annotations are ordered first in the list, and if
400
- * the target annotation is declared directly on the class, its map of attributes will be
401
- * ordered last in the list.
402
- * @param targetAnnotation the annotation to search for, both locally and as a meta-annotation
403
- * @param annotatedClassName the class to search
404
- * @since 3.1
405
- * @see {@link #findAllAnnotationAttributes(Class, String, boolean)}
406
- */
407
- public static List <Map <String , Object >> findAllAnnotationAttributes (
408
- Class <? extends Annotation > targetAnnotation , String annotatedClassName ) throws IOException {
409
- return findAllAnnotationAttributes (targetAnnotation , annotatedClassName , false );
410
- }
411
-
412
400
/**
413
401
* Retrieve the <em>value</em> of the <code>"value"</code> attribute of a
414
402
* single-element Annotation, given an annotation instance.
0 commit comments