Skip to content

Commit

Permalink
renamed MessageHistory's static 'addComponentToHistory' method to 'wr…
Browse files Browse the repository at this point in the history
…ite'; simpler and more consistent with the new 'read' method
  • Loading branch information
markfisher committed Aug 30, 2010
1 parent 7afe4eb commit a5638e4
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public final boolean send(Message<?> message, long timeout) {
Assert.notNull(message, "message must not be null");
Assert.notNull(message.getPayload(), "message payload must not be null");
if (this.shouldTrack) {
message = MessageHistory.addComponentToHistory(message, this);
message = MessageHistory.write(message, this);
}
message = this.convertPayloadIfNecessary(message);
message = this.interceptors.preSend(message, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected void onInit() {

protected void sendMessage(Message<?> message) {
if (message != null) {
message = MessageHistory.addComponentToHistory(message, this);
message = MessageHistory.write(message, this);
}
this.messagingTemplate.send(this.outputChannel, message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected Message<?> toMessage(Object object) {
try {
message = this.inboundMapper.toMessage(object);
if (this.shouldTrack) {
message = MessageHistory.addComponentToHistory(message, this);
message = MessageHistory.write(message, this);
}
}
catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public final void handleMessage(Message<?> message) {
}
try {
if (message != null && this.shouldTrack) {
message = MessageHistory.addComponentToHistory(message, this);
message = MessageHistory.write(message, this);
}
this.handleMessageInternal(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static MessageHistory read(Message<?> message) {
message.getHeaders().get(HEADER_NAME, MessageHistory.class) : null;
}

public static <T> Message<T> addComponentToHistory(Message<T> message, NamedComponent component) {
public static <T> Message<T> write(Message<T> message, NamedComponent component) {
Assert.notNull(message, "Message must not be null");
Assert.notNull(component, "Component must not be null");
Properties metadata = extractMetadata(component);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ public class MessageHistoryTests {
public void addComponents() {
StringMessage original = new StringMessage("foo");
assertNull(MessageHistory.read(original));
Message<String> result1 = MessageHistory.addComponentToHistory(original, new TestComponent(1));
Message<String> result1 = MessageHistory.write(original, new TestComponent(1));
MessageHistory history1 = MessageHistory.read(result1);
assertNotNull(history1);
assertEquals("testComponent-1", history1.toString());
Message<String> result2 = MessageHistory.addComponentToHistory(result1, new TestComponent(2));
Message<String> result2 = MessageHistory.write(result1, new TestComponent(2));
MessageHistory history2 = MessageHistory.read(result2);
assertNotNull(history2);
assertEquals("testComponent-1,testComponent-2", history2.toString());
}

@Test(expected = UnsupportedOperationException.class)
public void verifyImmutability() {
Message<?> message = MessageHistory.addComponentToHistory(MessageBuilder.withPayload("test").build(), new TestComponent(1));
Message<?> message = MessageHistory.write(MessageBuilder.withPayload("test").build(), new TestComponent(1));
MessageHistory history = MessageHistory.read(message);
history.add(new Properties());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public void onMessage(javax.jms.Message jmsMessage, Session session) throws JMSE
Message<?> requestMessage = (object instanceof Message<?>) ?
MessageBuilder.fromMessage((Message<?>) object).copyHeaders(headers).build() :
MessageBuilder.withPayload(object).copyHeaders(headers).build();
requestMessage = MessageHistory.addComponentToHistory(requestMessage, this);
requestMessage = MessageHistory.write(requestMessage, this);
if (!this.expectReply) {
this.send(requestMessage);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Message<Object> receive() {
MessageBuilder<Object> builder = (convertedObject instanceof Message)
? MessageBuilder.fromMessage((Message<Object>) convertedObject) : MessageBuilder.withPayload(convertedObject);
convertedMessage = builder.copyHeadersIfAbsent(mappedHeaders).build();
convertedMessage = MessageHistory.addComponentToHistory(convertedMessage, this);
convertedMessage = MessageHistory.write(convertedMessage, this);
}
catch (Exception e) {
throw new MessagingException(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public final void handleMessage(Message<?> message) {
if (message == null) {
throw new IllegalArgumentException("message must not be null");
}
final Message<?> messageToSend = MessageHistory.addComponentToHistory(message, this);
final Message<?> messageToSend = MessageHistory.write(message, this);
this.getJmsTemplate().convertAndSend(messageToSend, new MessagePostProcessor() {
public javax.jms.Message postProcessMessage(javax.jms.Message jmsMessage)
throws JMSException {
Expand Down

0 comments on commit a5638e4

Please sign in to comment.