Browse Source

Polishing

pull/635/head
Juergen Hoeller 10 years ago
parent
commit
078f23d6e6
  1. 21
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java
  2. 10
      spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java
  3. 27
      spring-messaging/src/main/java/org/springframework/messaging/support/GenericMessage.java
  4. 2
      spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java

21
spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassParser.java

@ -256,17 +256,14 @@ class ConfigurationClassParser { @@ -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 { @@ -301,7 +298,7 @@ class ConfigurationClassParser {
}
}
// No superclass, processing is complete
// No superclass -> processing is complete
return null;
}

10
spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java

@ -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() {
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 { @@ -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);

27
spring-messaging/src/main/java/org/springframework/messaging/support/GenericMessage.java

@ -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.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 { @@ -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 { @@ -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();
}

2
spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java

@ -540,7 +540,7 @@ public class MessageHeaderAccessor { @@ -540,7 +540,7 @@ public class MessageHeaderAccessor {
@Override
public String toString() {
return getClass().getSimpleName() + "[headers=" + this.headers + "]";
return getClass().getSimpleName() + " [headers=" + this.headers + "]";
}

Loading…
Cancel
Save