Polishing

This commit is contained in:
Juergen Hoeller
2018-08-10 18:00:17 +02:00
parent 1695ef7e87
commit 951b39cc7a
9 changed files with 77 additions and 66 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@@ -83,9 +83,8 @@ public class InjectionMetadata {
Collection<InjectedElement> elementsToIterate =
(checkedElements != null ? checkedElements : this.injectedElements);
if (!elementsToIterate.isEmpty()) {
boolean debug = logger.isDebugEnabled();
for (InjectedElement element : elementsToIterate) {
if (debug) {
if (logger.isDebugEnabled()) {
logger.debug("Processing injected element of bean '" + beanName + "': " + element);
}
element.inject(target, beanName, pvs);
@@ -94,6 +93,7 @@ public class InjectionMetadata {
}
/**
* Clear property skipping for the contained elements.
* @since 3.2.13
*/
public void clear(@Nullable PropertyValues pvs) {
@@ -113,6 +113,9 @@ public class InjectionMetadata {
}
/**
* A single injected element.
*/
public abstract static class InjectedElement {
protected final Member member;
@@ -226,6 +229,7 @@ public class InjectionMetadata {
}
/**
* Clear property skipping for this element.
* @since 3.2.13
*/
protected void clearPropertySkipping(@Nullable PropertyValues pvs) {

View File

@@ -538,29 +538,29 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
@Override
public String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) {
List<String> results = new ArrayList<>();
List<String> result = new ArrayList<>();
for (String beanName : this.beanDefinitionNames) {
BeanDefinition beanDefinition = getBeanDefinition(beanName);
if (!beanDefinition.isAbstract() && findAnnotationOnBean(beanName, annotationType) != null) {
results.add(beanName);
result.add(beanName);
}
}
for (String beanName : this.manualSingletonNames) {
if (!results.contains(beanName) && findAnnotationOnBean(beanName, annotationType) != null) {
results.add(beanName);
if (!result.contains(beanName) && findAnnotationOnBean(beanName, annotationType) != null) {
result.add(beanName);
}
}
return StringUtils.toStringArray(results);
return StringUtils.toStringArray(result);
}
@Override
public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) {
String[] beanNames = getBeanNamesForAnnotation(annotationType);
Map<String, Object> results = new LinkedHashMap<>(beanNames.length);
Map<String, Object> result = new LinkedHashMap<>(beanNames.length);
for (String beanName : beanNames) {
results.put(beanName, getBean(beanName));
result.put(beanName, getBean(beanName));
}
return results;
return result;
}
/**