Browse Source

Minor polishing of related files

Issue: SPR-10181
pull/337/merge
Juergen Hoeller 11 years ago
parent
commit
f2fb0ec9e7
  1. 4
      spring-context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java
  2. 4
      spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java
  3. 15
      spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java
  4. 10
      spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java

4
spring-context/src/main/java/org/springframework/context/annotation/AnnotationScopeMetadataResolver.java

@ -23,8 +23,6 @@ import org.springframework.beans.factory.config.BeanDefinition; @@ -23,8 +23,6 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.util.Assert;
import static org.springframework.context.annotation.MetadataUtils.*;
/**
* A {@link ScopeMetadataResolver} implementation that by default checks for
* the presence of Spring's {@link Scope} annotation on the bean class.
@ -79,7 +77,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { @@ -79,7 +77,7 @@ public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver {
ScopeMetadata metadata = new ScopeMetadata();
if (definition instanceof AnnotatedBeanDefinition) {
AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
AnnotationAttributes attributes = attributesFor(annDef.getMetadata(), this.scopeAnnotationType);
AnnotationAttributes attributes = MetadataUtils.attributesFor(annDef.getMetadata(), this.scopeAnnotationType);
if (attributes != null) {
metadata.setScopeName(attributes.getString("value"));
ScopedProxyMode proxyMode = attributes.getEnum("proxyMode");

4
spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

@ -419,8 +419,8 @@ public abstract class AnnotationUtils { @@ -419,8 +419,8 @@ public abstract class AnnotationUtils {
Annotation[] realAnnotations = (Annotation[]) value;
AnnotationAttributes[] mappedAnnotations = new AnnotationAttributes[realAnnotations.length];
for (int i = 0; i < realAnnotations.length; i++) {
mappedAnnotations[i] = getAnnotationAttributes(realAnnotations[i], classValuesAsString,
nestedAnnotationsAsMap);
mappedAnnotations[i] = getAnnotationAttributes(
realAnnotations[i], classValuesAsString, nestedAnnotationsAsMap);
}
attrs.put(method.getName(), mappedAnnotations);
}

15
spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java

@ -75,9 +75,9 @@ public interface AnnotatedTypeMetadata { @@ -75,9 +75,9 @@ public interface AnnotatedTypeMetadata {
* Retrieve all attributes of all annotations of the given type, if any (i.e. if
* defined on the underlying method, as direct annotation or as meta-annotation).
* @param annotationType the annotation type to look for
* @return a MultiMap of attributes, with the attribute name as key (e.g. "value") and
* a list of the defined attribute values as Map value. This return value will
* be {@code null} if no matching annotation is defined.
* @return a MultiMap of attributes, with the attribute name as key (e.g. "value")
* and a list of the defined attribute values as Map value. This return value will
* be {@code null} if no matching annotation is defined.
*/
MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationType);
@ -86,12 +86,11 @@ public interface AnnotatedTypeMetadata { @@ -86,12 +86,11 @@ public interface AnnotatedTypeMetadata {
* defined on the underlying method, as direct annotation or as meta-annotation).
* @param annotationType the annotation type to look for
* @param classValuesAsString whether to convert class references to String
* @return a MultiMap of attributes, with the attribute name as key (e.g. "value") and
* a list of the defined attribute values as Map value. This return value will
* be {@code null} if no matching annotation is defined.
* @return a MultiMap of attributes, with the attribute name as key (e.g. "value")
* and a list of the defined attribute values as Map value. This return value will
* be {@code null} if no matching annotation is defined.
* @see #getAllAnnotationAttributes(String)
*/
MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationType,
boolean classValuesAsString);
MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationType, boolean classValuesAsString);
}

10
spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor.java

@ -115,8 +115,7 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito @@ -115,8 +115,7 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito
public AnnotationAttributes getAnnotationAttributes(String annotationType, boolean classValuesAsString) {
List<AnnotationAttributes> attributes = this.attributeMap.get(annotationType);
AnnotationAttributes raw = (attributes == null ? null : attributes.get(0));
return AnnotationReadingVisitorUtils.convertClassValues(this.classLoader, raw,
classValuesAsString);
return AnnotationReadingVisitorUtils.convertClassValues(this.classLoader, raw, classValuesAsString);
}
@Override
@ -125,16 +124,15 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito @@ -125,16 +124,15 @@ public class AnnotationMetadataReadingVisitor extends ClassMetadataReadingVisito
}
@Override
public MultiValueMap<String, Object> getAllAnnotationAttributes(
String annotationType, boolean classValuesAsString) {
public MultiValueMap<String, Object> getAllAnnotationAttributes(String annotationType, boolean classValuesAsString) {
MultiValueMap<String, Object> allAttributes = new LinkedMultiValueMap<String, Object>();
List<AnnotationAttributes> attributes = this.attributeMap.get(annotationType);
if (attributes == null) {
return null;
}
for (AnnotationAttributes raw : attributes) {
for (Map.Entry<String, Object> entry : AnnotationReadingVisitorUtils.convertClassValues(
this.classLoader, raw, classValuesAsString).entrySet()) {
for (Map.Entry<String, Object> entry :
AnnotationReadingVisitorUtils.convertClassValues(this.classLoader, raw, classValuesAsString).entrySet()) {
allAttributes.add(entry.getKey(), entry.getValue());
}
}

Loading…
Cancel
Save