Avoid synthesizable annotation creation for @Bean/@Scope on scanning

Includes consistent (non-)use of AnnotationUtils/AnnotatedElementUtils.

Issue: SPR-16933
This commit is contained in:
Juergen Hoeller
2018-08-01 12:18:10 +02:00
parent 8c1290084d
commit 77e75fdf87
4 changed files with 37 additions and 33 deletions

View File

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