Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,13 +36,14 @@ class BeanAnnotationHelper {
|
||||
public static String determineBeanNameFor(Method beanMethod) {
|
||||
// By default, the bean name is the name of the @Bean-annotated method
|
||||
String beanName = beanMethod.getName();
|
||||
|
||||
// Check to see if the user has explicitly set a custom bean name...
|
||||
Bean bean = AnnotatedElementUtils.findMergedAnnotation(beanMethod, Bean.class);
|
||||
if (bean != null && bean.name().length > 0) {
|
||||
beanName = bean.name()[0];
|
||||
if (bean != null) {
|
||||
String[] names = bean.name();
|
||||
if (names.length > 0) {
|
||||
beanName = names[0];
|
||||
}
|
||||
}
|
||||
|
||||
return beanName;
|
||||
}
|
||||
|
||||
|
||||
@@ -626,22 +626,20 @@ public class AnnotatedElementUtils {
|
||||
* attributes of the same name from higher levels, and
|
||||
* {@link AliasFor @AliasFor} semantics are fully supported, both
|
||||
* within a single annotation and within the annotation hierarchy.
|
||||
* <p>In contrast to {@link #getAllAnnotationAttributes}, the search
|
||||
* algorithm used by this method will stop searching the annotation
|
||||
* hierarchy once the first annotation of the specified
|
||||
* {@code annotationType} has been found. As a consequence, additional
|
||||
* annotations of the specified {@code annotationType} will be ignored.
|
||||
* <p>In contrast to {@link #getAllAnnotationAttributes}, the search algorithm
|
||||
* used by this method will stop searching the annotation hierarchy once the
|
||||
* first annotation of the specified {@code annotationType} has been found.
|
||||
* As a consequence, additional annotations of the specified
|
||||
* {@code annotationType} will be ignored.
|
||||
* <p>This method follows <em>find semantics</em> as described in the
|
||||
* {@linkplain AnnotatedElementUtils class-level javadoc}.
|
||||
* @param element the annotated element
|
||||
* @param annotationType the annotation type to find
|
||||
* @param classValuesAsString whether to convert Class references into
|
||||
* Strings or to preserve them as Class references
|
||||
* @param nestedAnnotationsAsMap whether to convert nested Annotation
|
||||
* instances into {@code AnnotationAttributes} maps or to preserve them
|
||||
* as Annotation instances
|
||||
* @return the merged {@code AnnotationAttributes}, or {@code null} if
|
||||
* not found
|
||||
* @param nestedAnnotationsAsMap whether to convert nested Annotation instances into
|
||||
* {@code AnnotationAttributes} maps or to preserve them as Annotation instances
|
||||
* @return the merged {@code AnnotationAttributes}, or {@code null} if not found
|
||||
* @since 4.2
|
||||
* @see #findMergedAnnotation(AnnotatedElement, Class)
|
||||
* @see #getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
|
||||
|
||||
@@ -29,12 +29,11 @@ import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* ASM visitor which looks for the annotations defined on a class or method, including
|
||||
* tracking meta-annotations.
|
||||
* ASM visitor which looks for annotations defined on a class or method,
|
||||
* including meta-annotations.
|
||||
*
|
||||
* <p>As of Spring 3.1.1, this visitor is fully recursive, taking into account any nested
|
||||
* annotations or nested annotation arrays. These annotations are in turn read into
|
||||
* {@link AnnotationAttributes} map structures.
|
||||
* <p>This visitor is fully recursive, taking into account any nested
|
||||
* annotations or nested annotation arrays.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
@@ -77,9 +76,7 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib
|
||||
Annotation[] metaAnnotations = AnnotationUtils.getAnnotations(annotationClass);
|
||||
if (!ObjectUtils.isEmpty(metaAnnotations)) {
|
||||
for (Annotation metaAnnotation : metaAnnotations) {
|
||||
if (!AnnotationUtils.isInJavaLangAnnotationPackage(metaAnnotation)) {
|
||||
recursivelyCollectMetaAnnotations(visited, metaAnnotation);
|
||||
}
|
||||
recursivelyCollectMetaAnnotations(visited, metaAnnotation);
|
||||
}
|
||||
}
|
||||
if (this.metaAnnotationMap != null) {
|
||||
@@ -111,7 +108,7 @@ final class AnnotationAttributesReadingVisitor extends RecursiveAnnotationAttrib
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Failed to introspect meta-annotations on [" + annotation + "]: " + ex);
|
||||
logger.debug("Failed to introspect meta-annotations on " + annotation + ": " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user