diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/IntegrationNamespaceHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/IntegrationNamespaceHandler.java
index 8133e1976a..387ba4956a 100644
--- a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/IntegrationNamespaceHandler.java
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/IntegrationNamespaceHandler.java
@@ -108,6 +108,7 @@ public class IntegrationNamespaceHandler implements NamespaceHandler {
registerBeanDefinitionParser("header-enricher", new StandardHeaderEnricherParser());
registerBeanDefinitionParser("object-to-string-transformer", new ObjectToStringTransformerParser());
registerBeanDefinitionParser("payload-serializing-transformer", new PayloadSerializingTransformerParser());
+ registerBeanDefinitionParser("payload-deserializing-transformer", new PayloadDeserializingTransformerParser());
registerBeanDefinitionParser("inbound-channel-adapter", new MethodInvokingInboundChannelAdapterParser());
registerBeanDefinitionParser("outbound-channel-adapter", new MethodInvokingOutboundChannelAdapterParser());
registerBeanDefinitionParser("gateway", new GatewayParser());
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParser.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParser.java
new file mode 100644
index 0000000000..0021d73297
--- /dev/null
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParser.java
@@ -0,0 +1,40 @@
+/*
+ * 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.config.xml;
+
+import org.w3c.dom.Element;
+
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.ParserContext;
+
+/**
+ * Parser for the 'payload-deserializing-transformer' element.
+ *
+ * @author Mark Fisher
+ */
+public class PayloadDeserializingTransformerParser extends AbstractTransformerParser {
+
+ @Override
+ protected String getTransformerClassName() {
+ return IntegrationNamespaceUtils.BASE_PACKAGE + ".transformer.PayloadDeserializingTransformer";
+ }
+
+ @Override
+ protected void parseTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
+ }
+
+}
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 a312f63b70..c9c1fccdd6 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
@@ -572,14 +572,14 @@
]]>
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -607,6 +607,14 @@
+
+
+
+ Defines a Transformer that deserializes a byte array payload into an Object.
+
+
+
+
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParserTests-context.xml b/org.springframework.integration/src/test/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParserTests-context.xml
new file mode 100644
index 0000000000..e5267e1dae
--- /dev/null
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParserTests-context.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParserTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParserTests.java
new file mode 100644
index 0000000000..4dc785d633
--- /dev/null
+++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/xml/PayloadDeserializingTransformerParserTests.java
@@ -0,0 +1,122 @@
+/*
+ * 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.config.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.integration.channel.PollableChannel;
+import org.springframework.integration.core.Message;
+import org.springframework.integration.core.MessageChannel;
+import org.springframework.integration.message.GenericMessage;
+import org.springframework.integration.transformer.MessageTransformationException;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author Mark Fisher
+ */
+@ContextConfiguration
+@RunWith(SpringJUnit4ClassRunner.class)
+public class PayloadDeserializingTransformerParserTests {
+
+ @Autowired
+ @Qualifier("directInput")
+ private MessageChannel directInput;
+
+ @Autowired
+ @Qualifier("queueInput")
+ private MessageChannel queueInput;
+
+ @Autowired
+ @Qualifier("output")
+ private PollableChannel output;
+
+
+ @Test
+ public void directChannelWithSerializedStringMessage() throws Exception {
+ byte[] bytes = serialize("foo");
+ directInput.send(new GenericMessage(bytes));
+ Message> result = output.receive(0);
+ assertNotNull(result);
+ assertTrue(result.getPayload() instanceof String);
+ assertEquals("foo", result.getPayload());
+ }
+
+ @Test
+ public void queueChannelWithSerializedStringMessage() throws Exception {
+ byte[] bytes = serialize("foo");
+ queueInput.send(new GenericMessage(bytes));
+ Message> result = output.receive(3000);
+ assertNotNull(result);
+ assertTrue(result.getPayload() instanceof String);
+ assertEquals("foo", result.getPayload());
+ }
+
+ @Test
+ public void directChannelWithSerializedObjectMessage() throws Exception {
+ byte[] bytes = serialize(new TestBean());
+ directInput.send(new GenericMessage(bytes));
+ Message> result = output.receive(0);
+ assertNotNull(result);
+ assertEquals(TestBean.class, result.getPayload().getClass());
+ assertEquals("test", ((TestBean) result.getPayload()).name);
+ }
+
+ @Test
+ public void queueChannelWithSerializedObjectMessage() throws Exception {
+ byte[] bytes = serialize(new TestBean());
+ queueInput.send(new GenericMessage(bytes));
+ Message> result = output.receive(3000);
+ assertNotNull(result);
+ assertEquals(TestBean.class, result.getPayload().getClass());
+ assertEquals("test", ((TestBean) result.getPayload()).name);
+ }
+
+ @Test(expected = MessageTransformationException.class)
+ public void invalidPayload() {
+ byte[] bytes = new byte[] { 1, 2, 3 };
+ directInput.send(new GenericMessage(bytes));
+ }
+
+
+ private static byte[] serialize(Object object) throws Exception {
+ ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
+ ObjectOutputStream objectStream = new ObjectOutputStream(byteStream);
+ objectStream.writeObject(object);
+ return byteStream.toByteArray();
+ }
+
+
+ @SuppressWarnings("serial")
+ private static class TestBean implements Serializable {
+
+ public final String name = "test";
+
+ }
+
+}