resolved package dependency tangles

This commit is contained in:
Juergen Hoeller
2011-11-29 01:16:09 +00:00
parent 686ae8f7b3
commit d6d169ac56
5 changed files with 57 additions and 78 deletions

View File

@@ -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>&quot;value&quot;</code> attribute of a
* single-element Annotation, given an annotation instance.

View File

@@ -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