Polishing

This commit is contained in:
Juergen Hoeller
2014-08-23 01:28:10 +02:00
parent 54ba5c5e7b
commit 93ad7f8def
3 changed files with 23 additions and 25 deletions

View File

@@ -242,17 +242,14 @@ class ConfigurationClassParser {
// Process any @ComponentScan annotations
AnnotationAttributes componentScan = AnnotationConfigUtils.attributesFor(sourceClass.getMetadata(), ComponentScan.class);
if (componentScan != null) {
// the config class is annotated with @ComponentScan -> perform the scan immediately
if (!this.conditionEvaluator.shouldSkip(sourceClass.getMetadata(), ConfigurationPhase.REGISTER_BEAN)) {
Set<BeanDefinitionHolder> scannedBeanDefinitions =
this.componentScanParser.parse(componentScan, sourceClass.getMetadata().getClassName());
// check the set of scanned definitions for any further config classes and parse recursively if necessary
for (BeanDefinitionHolder holder : scannedBeanDefinitions) {
if (ConfigurationClassUtils.checkConfigurationClassCandidate(holder.getBeanDefinition(), this.metadataReaderFactory)) {
parse(holder.getBeanDefinition().getBeanClassName(), holder.getBeanName());
}
if (componentScan != null && !this.conditionEvaluator.shouldSkip(sourceClass.getMetadata(), ConfigurationPhase.REGISTER_BEAN)) {
// The config class is annotated with @ComponentScan -> perform the scan immediately
Set<BeanDefinitionHolder> scannedBeanDefinitions =
this.componentScanParser.parse(componentScan, sourceClass.getMetadata().getClassName());
// Check the set of scanned definitions for any further config classes and parse recursively if necessary
for (BeanDefinitionHolder holder : scannedBeanDefinitions) {
if (ConfigurationClassUtils.checkConfigurationClassCandidate(holder.getBeanDefinition(), this.metadataReaderFactory)) {
parse(holder.getBeanDefinition().getBeanClassName(), holder.getBeanName());
}
}
}
@@ -292,7 +289,7 @@ class ConfigurationClassParser {
}
}
// No superclass, processing is complete
// No superclass -> processing is complete
return null;
}

View File

@@ -107,19 +107,19 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
public UUID getId() {
return this.get(ID, UUID.class);
return get(ID, UUID.class);
}
public Long getTimestamp() {
return this.get(TIMESTAMP, Long.class);
return get(TIMESTAMP, Long.class);
}
public Object getReplyChannel() {
return this.get(REPLY_CHANNEL);
return get(REPLY_CHANNEL);
}
public Object getErrorChannel() {
return this.get(ERROR_CHANNEL);
return get(ERROR_CHANNEL);
}
@SuppressWarnings("unchecked")
@@ -156,7 +156,7 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
}
// Map implementation
// Delegating Map implementation
public boolean containsKey(Object key) {
return this.headers.containsKey(key);

View File

@@ -71,20 +71,21 @@ public class GenericMessage<T> implements Message<T>, Serializable {
}
public boolean equals(Object obj) {
if (this == obj) {
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (obj != null && obj instanceof GenericMessage<?>) {
GenericMessage<?> other = (GenericMessage<?>) obj;
return (ObjectUtils.nullSafeEquals(this.headers.getId(), other.headers.getId()) &&
this.headers.equals(other.headers) && this.payload.equals(other.payload));
if (!(other instanceof GenericMessage)) {
return false;
}
return false;
GenericMessage<?> otherMsg = (GenericMessage<?>) other;
// Using nullSafeEquals for proper array equals comparisons
return (ObjectUtils.nullSafeEquals(this.payload, otherMsg.payload) && this.headers.equals(otherMsg.headers));
}
public int hashCode() {
return (this.headers.hashCode() * 23 + ObjectUtils.nullSafeHashCode(this.payload));
// Using nullSafeHashCode for proper array hashCode handling
return (ObjectUtils.nullSafeHashCode(this.payload) * 23 + this.headers.hashCode());
}
public String toString() {