提交 078f23d6 编写于 作者: J Juergen Hoeller

Polishing

上级 b93dd954
...@@ -256,17 +256,14 @@ class ConfigurationClassParser { ...@@ -256,17 +256,14 @@ class ConfigurationClassParser {
// Process any @ComponentScan annotations // Process any @ComponentScan annotations
AnnotationAttributes componentScan = AnnotationConfigUtils.attributesFor(sourceClass.getMetadata(), ComponentScan.class); AnnotationAttributes componentScan = AnnotationConfigUtils.attributesFor(sourceClass.getMetadata(), ComponentScan.class);
if (componentScan != null) { if (componentScan != null && !this.conditionEvaluator.shouldSkip(sourceClass.getMetadata(), ConfigurationPhase.REGISTER_BEAN)) {
// the config class is annotated with @ComponentScan -> perform the scan immediately // The config class is annotated with @ComponentScan -> perform the scan immediately
if (!this.conditionEvaluator.shouldSkip(sourceClass.getMetadata(), ConfigurationPhase.REGISTER_BEAN)) { Set<BeanDefinitionHolder> scannedBeanDefinitions =
Set<BeanDefinitionHolder> scannedBeanDefinitions = this.componentScanParser.parse(componentScan, sourceClass.getMetadata().getClassName());
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) {
// check the set of scanned definitions for any further config classes and parse recursively if necessary if (ConfigurationClassUtils.checkConfigurationClassCandidate(holder.getBeanDefinition(), this.metadataReaderFactory)) {
for (BeanDefinitionHolder holder : scannedBeanDefinitions) { parse(holder.getBeanDefinition().getBeanClassName(), holder.getBeanName());
if (ConfigurationClassUtils.checkConfigurationClassCandidate(holder.getBeanDefinition(), this.metadataReaderFactory)) {
parse(holder.getBeanDefinition().getBeanClassName(), holder.getBeanName());
}
} }
} }
} }
...@@ -301,7 +298,7 @@ class ConfigurationClassParser { ...@@ -301,7 +298,7 @@ class ConfigurationClassParser {
} }
} }
// No superclass, processing is complete // No superclass -> processing is complete
return null; return null;
} }
......
...@@ -149,19 +149,19 @@ public class MessageHeaders implements Map<String, Object>, Serializable { ...@@ -149,19 +149,19 @@ public class MessageHeaders implements Map<String, Object>, Serializable {
} }
public UUID getId() { public UUID getId() {
return this.get(ID, UUID.class); return get(ID, UUID.class);
} }
public Long getTimestamp() { public Long getTimestamp() {
return this.get(TIMESTAMP, Long.class); return get(TIMESTAMP, Long.class);
} }
public Object getReplyChannel() { public Object getReplyChannel() {
return this.get(REPLY_CHANNEL); return get(REPLY_CHANNEL);
} }
public Object getErrorChannel() { public Object getErrorChannel() {
return this.get(ERROR_CHANNEL); return get(ERROR_CHANNEL);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
...@@ -195,7 +195,7 @@ public class MessageHeaders implements Map<String, Object>, Serializable { ...@@ -195,7 +195,7 @@ public class MessageHeaders implements Map<String, Object>, Serializable {
} }
// Map implementation // Delegating Map implementation
public boolean containsKey(Object key) { public boolean containsKey(Object key) {
return this.headers.containsKey(key); return this.headers.containsKey(key);
......
...@@ -22,7 +22,6 @@ import java.util.Map; ...@@ -22,7 +22,6 @@ import java.util.Map;
import org.springframework.messaging.Message; import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.MessageHeaders;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/** /**
* An implementation of {@link Message} with a generic payload. * An implementation of {@link Message} with a generic payload.
...@@ -68,8 +67,8 @@ public class GenericMessage<T> implements Message<T>, Serializable { ...@@ -68,8 +67,8 @@ public class GenericMessage<T> implements Message<T>, Serializable {
* @param headers message headers * @param headers message headers
*/ */
public GenericMessage(T payload, MessageHeaders headers) { public GenericMessage(T payload, MessageHeaders headers) {
Assert.notNull(payload, "'payload must not be null"); Assert.notNull(payload, "Payload must not be null");
Assert.notNull(headers, "'headers' must not be null"); Assert.notNull(headers, "MessageHeaders must not be null");
this.payload = payload; this.payload = payload;
this.headers = headers; this.headers = headers;
} }
...@@ -84,31 +83,31 @@ public class GenericMessage<T> implements Message<T>, Serializable { ...@@ -84,31 +83,31 @@ public class GenericMessage<T> implements Message<T>, Serializable {
} }
public boolean equals(Object obj) { public boolean equals(Object other) {
if (this == obj) { if (this == other) {
return true; return true;
} }
if (obj != null && obj instanceof GenericMessage<?>) { if (!(other instanceof GenericMessage)) {
GenericMessage<?> other = (GenericMessage<?>) obj; return false;
return (ObjectUtils.nullSafeEquals(this.headers.getId(), other.headers.getId()) &&
this.headers.equals(other.headers) && this.payload.equals(other.payload));
} }
return false; GenericMessage<?> otherMessage = (GenericMessage<?>) other;
return (this.payload.equals(otherMessage.payload) && this.headers.equals(otherMessage.headers));
} }
public int hashCode() { public int hashCode() {
return this.headers.hashCode() * 23 + ObjectUtils.nullSafeHashCode(this.payload); return (this.payload.hashCode() * 23 + this.headers.hashCode());
} }
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(getClass().getSimpleName()); StringBuilder sb = new StringBuilder(getClass().getSimpleName());
sb.append(" [payload=");
if (this.payload instanceof byte[]) { if (this.payload instanceof byte[]) {
sb.append("[payload byte[").append(((byte[]) this.payload).length).append("]]"); sb.append("byte[").append(((byte[]) this.payload).length).append("]");
} }
else { else {
sb.append("[payload=").append(this.payload).append("]"); sb.append(this.payload);
} }
sb.append("[headers=").append(this.headers).append("]"); sb.append(", headers=").append(this.headers).append("]");
return sb.toString(); return sb.toString();
} }
......
...@@ -540,7 +540,7 @@ public class MessageHeaderAccessor { ...@@ -540,7 +540,7 @@ public class MessageHeaderAccessor {
@Override @Override
public String toString() { public String toString() {
return getClass().getSimpleName() + "[headers=" + this.headers + "]"; return getClass().getSimpleName() + " [headers=" + this.headers + "]";
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册