resolved package dependency tangles
This commit is contained in:
@@ -28,10 +28,6 @@ import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.springframework.core.BridgeMethodResolver;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.core.type.classreading.MetadataReader;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -354,49 +350,6 @@ public abstract class AnnotationUtils {
|
||||
return attrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of attribute maps for all declarations of the given annotation
|
||||
* on the given annotated class using the given MetadataReaderFactory to introspect
|
||||
* annotation metadata. Meta-annotations are ordered first in the list, and if the
|
||||
* target annotation is declared directly on the class, its map of attributes will be
|
||||
* ordered last in the list.
|
||||
* @param targetAnnotation the annotation to search for, both locally and as a meta-annotation
|
||||
* @param annotatedClassName the class to inspect
|
||||
* @param classValuesAsString whether class attributes should be returned as strings
|
||||
* @param metadataReaderFactory factory used to create metadata readers for each type
|
||||
* @since 3.1
|
||||
*/
|
||||
public static List<Map<String, Object>> findAllAnnotationAttributes(
|
||||
Class<? extends Annotation> targetAnnotation, String annotatedClassName,
|
||||
boolean classValuesAsString, MetadataReaderFactory metadataReaderFactory) throws IOException {
|
||||
|
||||
List<Map<String, Object>> allAttribs = new ArrayList<Map<String, Object>>();
|
||||
|
||||
MetadataReader reader = metadataReaderFactory.getMetadataReader(annotatedClassName);
|
||||
AnnotationMetadata metadata = reader.getAnnotationMetadata();
|
||||
String targetAnnotationType = targetAnnotation.getName();
|
||||
|
||||
for (String annotationType : metadata.getAnnotationTypes()) {
|
||||
if (annotationType.equals(targetAnnotationType)) {
|
||||
continue;
|
||||
}
|
||||
MetadataReader metaReader = metadataReaderFactory.getMetadataReader(annotationType);
|
||||
Map<String, Object> targetAttribs =
|
||||
metaReader.getAnnotationMetadata().getAnnotationAttributes(targetAnnotationType, classValuesAsString);
|
||||
if (targetAttribs != null) {
|
||||
allAttribs.add(targetAttribs);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> localAttribs =
|
||||
metadata.getAnnotationAttributes(targetAnnotationType, classValuesAsString);
|
||||
if (localAttribs != null) {
|
||||
allAttribs.add(localAttribs);
|
||||
}
|
||||
|
||||
return allAttribs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the <em>value</em> of the <code>"value"</code> attribute of a
|
||||
* single-element Annotation, given an annotation instance.
|
||||
|
||||
@@ -14,20 +14,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core.io;
|
||||
package org.springframework.core.io.support;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.core.env.PropertiesPropertySource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Subclass of {@link PropertiesPropertySource} that loads a {@link Properties}
|
||||
* object from a given {@link Resource} or resource location such as
|
||||
* object from a given {@link org.springframework.core.io.Resource} or resource location such as
|
||||
* {@code "classpath:/com/myco/foo.properties"} or {@code "file:/path/to/file.properties"}.
|
||||
*
|
||||
* @author Chris Beams
|
||||
@@ -219,21 +219,6 @@ public class AnnotationUtilsTests {
|
||||
assertNotNull(order);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findAllComponentAnnotationAttributes() throws IOException {
|
||||
List<Map<String,Object>> allAttribs =
|
||||
AnnotationUtils.findAllAnnotationAttributes(Component.class,
|
||||
HasLocalAndMetaComponentAnnotation.class.getName(), false,
|
||||
new SimpleMetadataReaderFactory());
|
||||
|
||||
Object value = null;
|
||||
for (Map<String, Object> attribs : allAttribs) {
|
||||
value = attribs.get("value");
|
||||
}
|
||||
|
||||
assertThat(allAttribs.size(), is(3));
|
||||
assertEquals("local", value);
|
||||
}
|
||||
|
||||
@Component(value="meta1")
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -14,18 +14,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core.io;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
package org.springframework.core.io.support;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.easymock.internal.matchers.StartsWith;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ResourcePropertySource}.
|
||||
Reference in New Issue
Block a user