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

Polishing

上级 b93dd954
......@@ -256,17 +256,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());
}
}
}
......@@ -301,7 +298,7 @@ class ConfigurationClassParser {
}
}
// No superclass, processing is complete
// No superclass -> processing is complete
return null;
}
......
......@@ -149,19 +149,19 @@ public 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")
......@@ -195,7 +195,7 @@ public class MessageHeaders implements Map<String, Object>, Serializable {
}
// Map implementation
// Delegating Map implementation
public boolean containsKey(Object key) {
return this.headers.containsKey(key);
......
......@@ -22,7 +22,6 @@ import java.util.Map;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* An implementation of {@link Message} with a generic payload.
......@@ -68,8 +67,8 @@ public class GenericMessage<T> implements Message<T>, Serializable {
* @param headers message headers
*/
public GenericMessage(T payload, MessageHeaders headers) {
Assert.notNull(payload, "'payload must not be null");
Assert.notNull(headers, "'headers' must not be null");
Assert.notNull(payload, "Payload must not be null");
Assert.notNull(headers, "MessageHeaders must not be null");
this.payload = payload;
this.headers = headers;
}
......@@ -84,31 +83,31 @@ 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<?> otherMessage = (GenericMessage<?>) other;
return (this.payload.equals(otherMessage.payload) && this.headers.equals(otherMessage.headers));
}
public int hashCode() {
return this.headers.hashCode() * 23 + ObjectUtils.nullSafeHashCode(this.payload);
return (this.payload.hashCode() * 23 + this.headers.hashCode());
}
public String toString() {
StringBuilder sb = new StringBuilder(getClass().getSimpleName());
sb.append(" [payload=");
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 {
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();
}
......
......@@ -540,7 +540,7 @@ public class MessageHeaderAccessor {
@Override
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.
先完成此消息的编辑!
想要评论请 注册