From 477e8e1a9efeb40b2b83ff4a63f6d3a7652eca49 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Fri, 30 Apr 2010 03:15:26 +0000 Subject: [PATCH] simplifying MessageHistory --- .../NotificationListeningMessageProducer.java | 7 +- .../aggregator/AbstractMessageAggregator.java | 5 +- .../aggregator/CorrelatingMessageHandler.java | 5 +- .../integration/aggregator/Resequencer.java | 5 +- .../channel/AbstractMessageChannel.java | 13 +- .../context/IntegrationObjectSupport.java | 24 ++-- .../endpoint/HandlerInvocationChain.java | 18 +-- .../endpoint/MessageProducerSupport.java | 5 +- .../integration/filter/MessageFilter.java | 5 +- .../handler/ArgumentArrayMessageMapper.java | 9 +- .../integration/handler/BridgeHandler.java | 5 +- .../integration/handler/LoggingHandler.java | 5 +- .../handler/MessageHandlerChain.java | 12 +- .../handler/ServiceActivatingHandler.java | 5 +- .../integration/history/MessageHistory.java | 8 +- .../history/MessageHistoryEvent.java | 8 +- .../router/AbstractMessageRouter.java | 5 +- .../router/RecipientListRouter.java | 5 +- .../splitter/AbstractMessageSplitter.java | 5 +- .../support/ComponentMetadata.java | 119 ------------------ .../support/ComponentMetadataProvider.java | 33 ----- .../MessageTransformingHandler.java | 5 +- .../gateway/GatewayProxyFactoryBeanTests.java | 3 +- .../history/MessageHistoryTests.java | 21 ++-- 24 files changed, 71 insertions(+), 264 deletions(-) delete mode 100644 org.springframework.integration/src/main/java/org/springframework/integration/support/ComponentMetadata.java delete mode 100644 org.springframework.integration/src/main/java/org/springframework/integration/support/ComponentMetadataProvider.java diff --git a/org.springframework.integration.jmx/src/main/java/org/springframework/integration/jmx/NotificationListeningMessageProducer.java b/org.springframework.integration.jmx/src/main/java/org/springframework/integration/jmx/NotificationListeningMessageProducer.java index e86adea2e2..5c2549f57b 100644 --- a/org.springframework.integration.jmx/src/main/java/org/springframework/integration/jmx/NotificationListeningMessageProducer.java +++ b/org.springframework.integration.jmx/src/main/java/org/springframework/integration/jmx/NotificationListeningMessageProducer.java @@ -30,7 +30,6 @@ import org.apache.commons.logging.LogFactory; import org.springframework.integration.core.Message; import org.springframework.integration.endpoint.MessageProducerSupport; import org.springframework.integration.message.MessageBuilder; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.Assert; /** @@ -104,9 +103,9 @@ public class NotificationListeningMessageProducer extends MessageProducerSupport } @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("notification-listener"); - metadata.setAttribute("transport", "jmx"); + public String getComponentType() { + // TODO: provide header: ("transport", "jmx"); + return "notification-listener"; } /** diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/AbstractMessageAggregator.java b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/AbstractMessageAggregator.java index 73b5eca149..efc1f1c91a 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/AbstractMessageAggregator.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/AbstractMessageAggregator.java @@ -21,7 +21,6 @@ import java.util.List; import org.springframework.integration.core.Message; import org.springframework.integration.message.MessageBuilder; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; @@ -61,8 +60,8 @@ public abstract class AbstractMessageAggregator extends } @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("aggregator"); + public String getComponentType() { + return "aggregator"; } @Override diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageHandler.java index d5168b1249..a972ec716b 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageHandler.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageHandler.java @@ -42,7 +42,6 @@ import org.springframework.integration.handler.AbstractMessageHandler; import org.springframework.integration.message.MessageBuilder; import org.springframework.integration.store.MessageStore; import org.springframework.integration.store.SimpleMessageStore; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.scheduling.TaskScheduler; import org.springframework.util.Assert; @@ -171,8 +170,8 @@ public class CorrelatingMessageHandler extends AbstractMessageHandler implements } @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("aggregator"); + public String getComponentType() { + return "aggregator"; } @Override diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/Resequencer.java b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/Resequencer.java index deb2b946e9..80f9c12551 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/Resequencer.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/Resequencer.java @@ -23,7 +23,6 @@ import java.util.SortedSet; import java.util.TreeSet; import org.springframework.integration.core.Message; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.CollectionUtils; /** @@ -64,8 +63,8 @@ public class Resequencer extends AbstractMessageBarrierHandler message) { - if (message != null) { - message.getHeaders().getHistory().addEvent(this.metadata); + if (message != null && this.endpointName != null) { + message.getHeaders().getHistory().addEvent(this.endpointName, this.handlerType); } this.handler.handleMessage(message); } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java index 71fcb7f456..7f5a1f5060 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/MessageProducerSupport.java @@ -20,7 +20,6 @@ import org.springframework.integration.channel.MessageChannelTemplate; import org.springframework.integration.core.Message; import org.springframework.integration.core.MessageChannel; import org.springframework.integration.core.MessageProducer; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.Assert; /** @@ -33,8 +32,6 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements private volatile MessageChannel outputChannel; - private final ComponentMetadata componentMetadata = new ComponentMetadata(); - private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate(); @@ -53,7 +50,7 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements protected boolean sendMessage(Message message) { if (message != null) { - message.getHeaders().getHistory().addEvent(this.componentMetadata); + message.getHeaders().getHistory().addEvent(this.getBeanName(), this.getComponentType()); } return this.channelTemplate.send(message, this.outputChannel); } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/filter/MessageFilter.java b/org.springframework.integration/src/main/java/org/springframework/integration/filter/MessageFilter.java index 913dd3f86c..4a121b82bd 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/filter/MessageFilter.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/filter/MessageFilter.java @@ -22,7 +22,6 @@ import org.springframework.integration.handler.AbstractReplyProducingMessageHand import org.springframework.integration.message.MessageDeliveryException; import org.springframework.integration.message.MessageRejectedException; import org.springframework.integration.selector.MessageSelector; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.Assert; /** @@ -83,8 +82,8 @@ public class MessageFilter extends AbstractReplyProducingMessageHandler { } @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("filter"); + public String getComponentType() { + return "filter"; } @Override diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java index df5ff032c7..f395be978b 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/ArgumentArrayMessageMapper.java @@ -39,7 +39,6 @@ import org.springframework.integration.core.Message; import org.springframework.integration.core.MessagingException; import org.springframework.integration.message.InboundMessageMapper; import org.springframework.integration.message.MessageBuilder; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.Assert; import org.springframework.util.StringUtils; @@ -123,7 +122,7 @@ public class ArgumentArrayMessageMapper implements InboundMessageMapper parameterList; - private final ComponentMetadata metadata = new ComponentMetadata(); + private final String gatewayName; public ArgumentArrayMessageMapper(Method method, String gatewayName) { @@ -131,9 +130,7 @@ public class ArgumentArrayMessageMapper implements InboundMessageMapper toMessage(Object[] arguments) { @@ -145,7 +142,7 @@ public class ArgumentArrayMessageMapper implements InboundMessageMapper message = this.mapArgumentsToMessage(arguments); if (message != null) { - message.getHeaders().getHistory().addEvent(this.metadata); + message.getHeaders().getHistory().addEvent(this.gatewayName, "gateway"); } return message; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/BridgeHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/BridgeHandler.java index f6c6f0f654..969a4952d3 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/BridgeHandler.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/BridgeHandler.java @@ -17,7 +17,6 @@ package org.springframework.integration.handler; import org.springframework.integration.core.Message; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.Assert; /** @@ -37,8 +36,8 @@ import org.springframework.util.Assert; public class BridgeHandler extends AbstractReplyProducingMessageHandler { @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("bridge"); + public String getComponentType() { + return "bridge"; } @Override diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/LoggingHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/LoggingHandler.java index c4dc472703..4231178ad2 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/LoggingHandler.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/LoggingHandler.java @@ -20,7 +20,6 @@ import java.io.PrintWriter; import java.io.StringWriter; import org.springframework.integration.core.Message; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.StringUtils; /** @@ -66,8 +65,8 @@ public class LoggingHandler extends AbstractMessageHandler { } @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("logging-channel-adapter"); + public String getComponentType() { + return "logging-channel-adapter"; } @Override diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java index 44123a55ff..bfe758f6e8 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java @@ -26,7 +26,6 @@ import org.springframework.integration.core.MessageProducer; import org.springframework.integration.filter.MessageFilter; import org.springframework.integration.message.MessageHandler; import org.springframework.integration.message.MessageHandlingException; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.Assert; /** @@ -91,8 +90,8 @@ public class MessageHandlerChain extends IntegrationObjectSupport implements Mes @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("chain"); + public String getComponentType() { + return "chain"; } private void initialize() { @@ -128,9 +127,6 @@ public class MessageHandlerChain extends IntegrationObjectSupport implements Mes nextHandler.handleMessage(message); return true; } - public String getName() { - return null; - } }; ((MessageProducer) handler).setOutputChannel(nextChannel); } @@ -150,10 +146,6 @@ public class MessageHandlerChain extends IntegrationObjectSupport implements Mes private class ReplyForwardingMessageChannel implements MessageChannel { - public String getName() { - return MessageHandlerChain.this.getBeanName(); - } - public boolean send(Message message) { return this.send(message, -1); } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java index ca5d457c6b..2f8f73f035 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/ServiceActivatingHandler.java @@ -21,7 +21,6 @@ import java.lang.reflect.Method; import org.springframework.integration.annotation.ServiceActivator; import org.springframework.integration.core.Message; import org.springframework.integration.message.MessageHandlingException; -import org.springframework.integration.support.ComponentMetadata; /** * @author Mark Fisher @@ -45,8 +44,8 @@ public class ServiceActivatingHandler extends AbstractReplyProducingMessageHandl @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("service-activator"); + public String getComponentType() { + return "service-activator"; } @Override diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/history/MessageHistory.java b/org.springframework.integration/src/main/java/org/springframework/integration/history/MessageHistory.java index b0f8b6b335..d2393971f9 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/history/MessageHistory.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/history/MessageHistory.java @@ -16,8 +16,6 @@ package org.springframework.integration.history; -import org.springframework.integration.support.ComponentMetadata; - import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; @@ -40,9 +38,9 @@ public class MessageHistory implements Iterable, Serializab /** * Add a new event with the provided component metadata. */ - public MessageHistoryEvent addEvent(ComponentMetadata metadata) { - if (metadata != null && metadata.getComponentName() != null) { - MessageHistoryEvent event = new MessageHistoryEvent(metadata.getComponentType(), metadata.getComponentName()); + public MessageHistoryEvent addEvent(String name, String type) { + if (name != null) { + MessageHistoryEvent event = new MessageHistoryEvent(name, type); this.events.add(event); return event; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/history/MessageHistoryEvent.java b/org.springframework.integration/src/main/java/org/springframework/integration/history/MessageHistoryEvent.java index 830d8acef6..ee3fed0049 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/history/MessageHistoryEvent.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/history/MessageHistoryEvent.java @@ -27,19 +27,19 @@ import java.io.Serializable; */ public class MessageHistoryEvent implements Serializable { - private final String type; - private final String name; + private final String type; + private final long timestamp; /** * Create a MessageHistoryEvent with the metadata of the source component. */ - public MessageHistoryEvent(String type, String name) { - this.type = type; + public MessageHistoryEvent(String name, String type) { this.name = name; + this.type = type; this.timestamp = System.currentTimeMillis(); } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java b/org.springframework.integration/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java index 30af45f060..4a16419cb0 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java @@ -26,7 +26,6 @@ import org.springframework.integration.core.MessageHeaders; import org.springframework.integration.handler.AbstractMessageHandler; import org.springframework.integration.message.MessageBuilder; import org.springframework.integration.message.MessageDeliveryException; -import org.springframework.integration.support.ComponentMetadata; /** * Base class for Message Routers. @@ -97,8 +96,8 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler { } @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("router"); + public String getComponentType() { + return "router"; } @Override diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/router/RecipientListRouter.java b/org.springframework.integration/src/main/java/org/springframework/integration/router/RecipientListRouter.java index 5f86ce8ae3..dedcefada2 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/router/RecipientListRouter.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/router/RecipientListRouter.java @@ -27,7 +27,6 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.integration.core.Message; import org.springframework.integration.core.MessageChannel; import org.springframework.integration.selector.MessageSelector; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.Assert; /** @@ -89,8 +88,8 @@ public class RecipientListRouter extends AbstractMessageRouter implements Initia } @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("recipient-list-router"); + public String getComponentType() { + return "recipient-list-router"; } @Override diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java b/org.springframework.integration/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java index c92726fc9d..67550d5957 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/splitter/AbstractMessageSplitter.java @@ -26,7 +26,6 @@ import org.springframework.integration.core.MessageChannel; import org.springframework.integration.core.MessageHeaders; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; import org.springframework.integration.message.MessageBuilder; -import org.springframework.integration.support.ComponentMetadata; /** * Base class for Message-splitting handlers. @@ -92,8 +91,8 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess } @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("splitter"); + public String getComponentType() { + return "splitter"; } /** diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/support/ComponentMetadata.java b/org.springframework.integration/src/main/java/org/springframework/integration/support/ComponentMetadata.java deleted file mode 100644 index 015ea72388..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/support/ComponentMetadata.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.support; - -import java.io.Serializable; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -/** - * Metadata describing a messaging component including the - * component's name and type as well as any other attributes. - * - * @author Mark Fisher - * @since 2.0 - */ -public class ComponentMetadata implements Serializable { - - public static final String COMPONENT_NAME = "componentName"; - - public static final String COMPONENT_TYPE = "componentType"; - - - private final Map attributes = new HashMap(); - - - /** - * Create a new ComponentMetadata instance with no attributes. - */ - public ComponentMetadata() { - } - - /** - * Create a new ComponentMetadata instance that copies all attributes - * from the provided ComponentMetadata. - */ - public ComponentMetadata(ComponentMetadata metadata) { - this.attributes.putAll(metadata.getAttributes()); - } - - - public ComponentMetadata setComponentName(String componentName) { - this.setAttribute(COMPONENT_NAME, componentName); - return this; - } - - public ComponentMetadata setComponentType(String componentType) { - this.setAttribute(COMPONENT_TYPE, componentType); - return this; - } - - public String getComponentName() { - return this.getAttribute(COMPONENT_NAME, String.class); - } - - public String getComponentType() { - return this.getAttribute(COMPONENT_TYPE, String.class); - } - - public ComponentMetadata setAttribute(String key, String value) { - this.attributes.put(key, value); - return this; - } - - public ComponentMetadata setAttribute(String key, Number value) { - this.attributes.put(key, value); - return this; - } - - public ComponentMetadata setAttribute(String key, Boolean value) { - this.attributes.put(key, value); - return this; - } - - public Object getAttribute(String key) { - return this.attributes.get(key); - } - - @SuppressWarnings("unchecked") - public T getAttribute(String key, Class type) { - Object value = this.attributes.get(key); - if (value != null && type.isAssignableFrom(value.getClass())) { - return (T) value; - } - return null; - } - - public Map getAttributes() { - return Collections.unmodifiableMap(this.attributes); - } - - public boolean equals(Object other) { - return (other instanceof ComponentMetadata - && this.attributes.equals(((ComponentMetadata) other).attributes)); - } - - public int hashCode() { - return 17 * this.attributes.hashCode(); - } - - public String toString() { - return this.attributes.toString(); - } - -} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/support/ComponentMetadataProvider.java b/org.springframework.integration/src/main/java/org/springframework/integration/support/ComponentMetadataProvider.java deleted file mode 100644 index a5f7a898d8..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/support/ComponentMetadataProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.support; - -/** - * Interface to be implemented by messaging components - * that provide {@link ComponentMetadata}. - * - * @author Mark Fisher - * @since 2.0 - */ -public interface ComponentMetadataProvider { - - /** - * Returns the {@link ComponentMetadata} - */ - ComponentMetadata getComponentMetadata(); - -} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java index 025c35ec78..f3961d0864 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/transformer/MessageTransformingHandler.java @@ -19,7 +19,6 @@ package org.springframework.integration.transformer; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.integration.core.Message; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; -import org.springframework.integration.support.ComponentMetadata; import org.springframework.util.Assert; /** @@ -45,8 +44,8 @@ public class MessageTransformingHandler extends AbstractReplyProducingMessageHan @Override - protected void populateComponentMetadata(ComponentMetadata metadata) { - metadata.setComponentType("transformer"); + public String getComponentType() { + return "transformer"; } @Override diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java index 0ce9056caf..71846feb7f 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/gateway/GatewayProxyFactoryBeanTests.java @@ -283,13 +283,12 @@ public class GatewayProxyFactoryBeanTests { MessageHistoryEvent event1 = historyIterator.next(); MessageHistoryEvent event2 = historyIterator.next(); MessageHistoryEvent event3 = historyIterator.next(); - // assertEquals("echo", event1.getAttribute("method", String.class)); + //assertEquals("echo", event1.getAttribute("method", String.class)); assertEquals("testGateway", event1.getName()); assertEquals("channel", event2.getType()); assertEquals("testChannel", event2.getName()); assertEquals("bridge", event3.getType()); assertEquals("testBridge", event3.getName()); - System.out.println(message); } @Test diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/history/MessageHistoryTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/history/MessageHistoryTests.java index 9cde0ed6c1..93ebbbae69 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/history/MessageHistoryTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/history/MessageHistoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,41 +13,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.springframework.integration.history; -import org.junit.Test; -import org.springframework.integration.support.ComponentMetadata; +package org.springframework.integration.history; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import org.junit.Test; + /** * @author Oleg Zhurakousky * @since 2.0 */ public class MessageHistoryTests { + private long times = 1000; + private ExecutorService executor = Executors.newCachedThreadPool(); @Test public void testConcurrentModificationsOnObjectMethods() throws Exception{ final MessageHistory history = new MessageHistory(); final MessageHistory otherHistory = new MessageHistory(); - executor.execute(new Runnable() { public void run() { for (int i = 0; i < times; i++) { - ComponentMetadata event = new ComponentMetadata(); - event.setAttribute("foo", "foo"); - event.setAttribute("bar", "bar"); - event.setComponentName("MessageHistoryTests"); - history.addEvent(event); - otherHistory.addEvent(event); + history.addEvent("testName", "testType"); + otherHistory.addEvent("testName", "testType"); } } }); - executor.execute(new Runnable() { public void run() { for (int i = 0; i < times; i++) { @@ -72,4 +68,5 @@ public class MessageHistoryTests { executor.shutdown(); executor.awaitTermination(3, TimeUnit.SECONDS); } + }