parent
6d3649858e
commit
f2fb0ec9e7
|
@ -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 {
|
|||
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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 {
|
|||
* 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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
|||
}
|
||||
|
||||
@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…
Reference in New Issue