Refactor AnnotationUtils#findAllAnnotationAttributes

Remove all convenience variants of #findAllAnnotationAttributes and
refactor the remaining method to accept a MetadataReaderFactory
instead of creating its own SimpleMetadataReaderFactory internally.
This allows clients to use non-default class loaders as well as
customize the particular MetadataReaderFactory to be used (e.g.
'simple' vs 'caching', etc).

Issue: SPR-8752
This commit is contained in:
Chris Beams
2011-10-09 20:32:21 +00:00
parent 3bb01ee68b
commit 6837111bda
3 changed files with 16 additions and 25 deletions

View File

@@ -39,6 +39,7 @@ import java.util.Map;
import org.junit.Test;
import org.springframework.core.Ordered;
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
import org.springframework.stereotype.Component;
/**
@@ -221,7 +222,9 @@ public class AnnotationUtilsTests {
@Test
public void findAllComponentAnnotationAttributes() throws IOException {
List<Map<String,Object>> allAttribs =
AnnotationUtils.findAllAnnotationAttributes(Component.class, HasLocalAndMetaComponentAnnotation.class.getName());
AnnotationUtils.findAllAnnotationAttributes(Component.class,
HasLocalAndMetaComponentAnnotation.class.getName(), false,
new SimpleMetadataReaderFactory());
Object value = null;
for (Map<String, Object> attribs : allAttribs) {