|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2011 the original author or authors. |
| 2 | + * Copyright 2002-2012 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -54,17 +54,22 @@ public class InjectionMetadata {
|
54 | 54 |
|
55 | 55 |
|
56 | 56 | public InjectionMetadata(Class targetClass, Collection<InjectedElement> elements) {
|
57 |
| - this.injectedElements = Collections.synchronizedSet(new LinkedHashSet<InjectedElement>()); |
58 |
| - for (InjectedElement element : elements) { |
59 |
| - if (logger.isDebugEnabled()) { |
60 |
| - logger.debug("Found injected element on class [" + targetClass.getName() + "]: " + element); |
| 57 | + if (!elements.isEmpty()) { |
| 58 | + this.injectedElements = Collections.synchronizedSet(new LinkedHashSet<InjectedElement>(elements.size())); |
| 59 | + for (InjectedElement element : elements) { |
| 60 | + if (logger.isDebugEnabled()) { |
| 61 | + logger.debug("Found injected element on class [" + targetClass.getName() + "]: " + element); |
| 62 | + } |
| 63 | + this.injectedElements.add(element); |
61 | 64 | }
|
62 |
| - this.injectedElements.add(element); |
| 65 | + } |
| 66 | + else { |
| 67 | + this.injectedElements = Collections.emptySet(); |
63 | 68 | }
|
64 | 69 | }
|
65 | 70 |
|
66 | 71 | public void checkConfigMembers(RootBeanDefinition beanDefinition) {
|
67 |
| - synchronized(this.injectedElements) { |
| 72 | + synchronized (this.injectedElements) { |
68 | 73 | for (Iterator<InjectedElement> it = this.injectedElements.iterator(); it.hasNext();) {
|
69 | 74 | Member member = it.next().getMember();
|
70 | 75 | if (!beanDefinition.isExternallyManagedConfigMember(member)) {
|
@@ -170,26 +175,30 @@ protected void inject(Object target, String requestingBeanName, PropertyValues p
|
170 | 175 | * affected property as processed for other processors to ignore it.
|
171 | 176 | */
|
172 | 177 | protected boolean checkPropertySkipping(PropertyValues pvs) {
|
173 |
| - if (this.skip == null) { |
174 |
| - if (pvs != null) { |
175 |
| - synchronized (pvs) { |
176 |
| - if (this.skip == null) { |
177 |
| - if (this.pd != null) { |
178 |
| - if (pvs.contains(this.pd.getName())) { |
179 |
| - // Explicit value provided as part of the bean definition. |
180 |
| - this.skip = true; |
181 |
| - return true; |
182 |
| - } |
183 |
| - else if (pvs instanceof MutablePropertyValues) { |
184 |
| - ((MutablePropertyValues) pvs).registerProcessedProperty(this.pd.getName()); |
185 |
| - } |
186 |
| - } |
187 |
| - } |
| 178 | + if (this.skip != null) { |
| 179 | + return this.skip; |
| 180 | + } |
| 181 | + if (pvs == null) { |
| 182 | + this.skip = false; |
| 183 | + return false; |
| 184 | + } |
| 185 | + synchronized (pvs) { |
| 186 | + if (this.skip != null) { |
| 187 | + return this.skip; |
| 188 | + } |
| 189 | + if (this.pd != null) { |
| 190 | + if (pvs.contains(this.pd.getName())) { |
| 191 | + // Explicit value provided as part of the bean definition. |
| 192 | + this.skip = true; |
| 193 | + return true; |
| 194 | + } |
| 195 | + else if (pvs instanceof MutablePropertyValues) { |
| 196 | + ((MutablePropertyValues) pvs).registerProcessedProperty(this.pd.getName()); |
188 | 197 | }
|
189 | 198 | }
|
190 | 199 | this.skip = false;
|
| 200 | + return false; |
191 | 201 | }
|
192 |
| - return this.skip; |
193 | 202 | }
|
194 | 203 |
|
195 | 204 | /**
|
|
0 commit comments