diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/spring-integration-1.0.xsd b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/spring-integration-1.0.xsd
index f609db5a5f..0e43b530df 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/spring-integration-1.0.xsd
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/spring-integration-1.0.xsd
@@ -59,7 +59,6 @@
-
@@ -422,7 +421,7 @@
-
+
Defines an endpoint that passes a Message to the
@@ -430,6 +429,22 @@
modifying it.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 69ba41d4ea..f2d6d12a89 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
@@ -16,7 +16,9 @@
package org.springframework.integration.handler;
+import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.core.Message;
+import org.springframework.util.Assert;
/**
* A simple MessageHandler implementation that passes the request Message
@@ -26,11 +28,20 @@ import org.springframework.integration.core.Message;
*
* @author Mark Fisher
*/
-public class BridgeHandler extends AbstractReplyProducingMessageHandler {
+public class BridgeHandler extends AbstractReplyProducingMessageHandler implements InitializingBean {
+
+ public void afterPropertiesSet() {
+ this.verifyOutputChannel();
+ }
@Override
protected void handleRequestMessage(Message> requestMessage, ReplyMessageHolder replyMessageHolder) {
+ this.verifyOutputChannel();
replyMessageHolder.set(requestMessage);
}
+ private void verifyOutputChannel() {
+ Assert.state(super.getOutputChannel() != null, "Bridge handler requires an output channel");
+ }
+
}
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java
new file mode 100644
index 0000000000..cb5908bb9a
--- /dev/null
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/handler/BridgeHandlerTests.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2002-2009 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 static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+
+import org.springframework.integration.channel.QueueChannel;
+import org.springframework.integration.core.Message;
+import org.springframework.integration.message.MessageHandlingException;
+import org.springframework.integration.message.StringMessage;
+
+/**
+ * @author Mark Fisher
+ */
+public class BridgeHandlerTests {
+
+ @Test
+ public void simpleBridge() {
+ QueueChannel outputChannel = new QueueChannel();
+ BridgeHandler handler = new BridgeHandler();
+ handler.setOutputChannel(outputChannel);
+ Message> request = new StringMessage("test");
+ handler.handleMessage(request);
+ Message> reply = outputChannel.receive(0);
+ assertNotNull(reply);
+ assertEquals(request, reply);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void missingOutputChannelVerifiedUponInitialization() {
+ BridgeHandler handler = new BridgeHandler();
+ handler.afterPropertiesSet();
+ }
+
+ @Test(expected = MessageHandlingException.class)
+ public void missingOutputChannelVerifiedAtRuntime() {
+ BridgeHandler handler = new BridgeHandler();
+ Message> request = new StringMessage("test");
+ handler.handleMessage(request);
+ }
+
+}