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
deleted file mode 100644
index d6460a2d92..0000000000
--- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2002-2008 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.handler;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.springframework.integration.message.Message;
-
-/**
- * A message handler implementation that passes incoming messages through a
- * chain of handlers. The chain will be broken by any handler throwing an
- * exception or returning null.
- *
- * @author Mark Fisher
- */
-public class MessageHandlerChain implements MessageHandler {
-
- private final List handlers = new CopyOnWriteArrayList();
-
-
- /**
- * Add a handler to the end of the chain.
- */
- public void add(MessageHandler handler) {
- this.handlers.add(handler);
- }
-
- /**
- * Add a handler to the chain at the specified index.
- */
- public void add(int index, MessageHandler handler) {
- this.handlers.add(index, handler);
- }
-
- public void setHandlers(List handlers) {
- this.handlers.clear();
- this.handlers.addAll(handlers);
- }
-
- /**
- * Get an immutable list of handlers
- */
- public List getHandlers() {
- return Collections.unmodifiableList(handlers);
- }
-
- public final Message> handle(Message> message) {
- for (MessageHandler next : handlers) {
- message = next.handle(message);
- if (message == null) {
- return null;
- }
- }
- return message;
- }
-
-}
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/handler/MessageFilterTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/handler/MessageFilterTests.java
index 32fc6ed470..030af6cb0d 100644
--- a/org.springframework.integration/src/test/java/org/springframework/integration/handler/MessageFilterTests.java
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/handler/MessageFilterTests.java
@@ -16,16 +16,11 @@
package org.springframework.integration.handler;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.concurrent.atomic.AtomicBoolean;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import org.junit.Test;
-import org.springframework.integration.handler.MessageFilter;
-import org.springframework.integration.handler.MessageHandler;
-import org.springframework.integration.handler.MessageHandlerChain;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.message.selector.MessageSelector;
@@ -37,42 +32,23 @@ public class MessageFilterTests {
@Test
public void testFilterAcceptsMessage() {
- final AtomicBoolean secondHandlerReceived = new AtomicBoolean();
- MessageHandlerChain chain = new MessageHandlerChain();
MessageFilter filter = new MessageFilter(new MessageSelector() {
public boolean accept(Message> message) {
return true;
}
});
- chain.add(filter);
- chain.add(new MessageHandler() {
- public Message> handle(Message> message) {
- secondHandlerReceived.set(true);
- return null;
- }
- });
- chain.handle(new StringMessage("test"));
- assertTrue(secondHandlerReceived.get());
+ Message> message = new StringMessage("test");
+ assertEquals(message, filter.handle(message));
}
@Test
public void testFilterRejectsMessage() {
- final AtomicBoolean secondHandlerReceived = new AtomicBoolean();
- MessageHandlerChain chain = new MessageHandlerChain();
MessageFilter filter = new MessageFilter(new MessageSelector() {
public boolean accept(Message> message) {
return false;
}
});
- chain.add(filter);
- chain.add(new MessageHandler() {
- public Message> handle(Message> message) {
- secondHandlerReceived.set(true);
- return null;
- }
- });
- chain.handle(new StringMessage("test"));
- assertFalse(secondHandlerReceived.get());
+ assertNull(filter.handle(new StringMessage("test")));
}
}
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/handler/MessageHandlerChainTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/handler/MessageHandlerChainTests.java
deleted file mode 100644
index 50b5cb2e54..0000000000
--- a/org.springframework.integration/src/test/java/org/springframework/integration/handler/MessageHandlerChainTests.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2002-2008 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.handler;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-import org.springframework.integration.message.Message;
-import org.springframework.integration.message.StringMessage;
-
-/**
- * @author Mark Fisher
- */
-public class MessageHandlerChainTests {
-
- @Test
- public void testChain() {
- MessageHandlerChain chain = new MessageHandlerChain();
- chain.add(new TestHandler("a"));
- chain.add(new TestHandler("b"));
- chain.add(new TestHandler("c"));
- chain.add(new TestHandler("d"));
- Message> result = chain.handle(new StringMessage("!"));
- assertEquals("!abcd", result.getPayload());
- }
-
-
- private static class TestHandler implements MessageHandler {
-
- private String text;
-
- TestHandler(String text) {
- this.text = text;
- }
-
- public Message> handle(Message> message) {
- return new StringMessage(message.getPayload() + text);
- }
- }
-
-}