diff --git a/org.springframework.integration.file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java b/org.springframework.integration.file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java
index ab2b07d7af..74e9117028 100644
--- a/org.springframework.integration.file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java
+++ b/org.springframework.integration.file/src/main/java/org/springframework/integration/file/FileWritingMessageHandler.java
@@ -31,7 +31,14 @@ import org.springframework.util.FileCopyUtils;
* A {@link MessageHandler} implementation that writes the Message payload to a
* file. If the payload is a File object, it will copy the File to this
* consumer's directory. If the payload is a byte array or String, it will
- * write it directly. Otherwise, it will invoke toString on the payload Object.
+ * write it directly. Otherwise, the payload type is unsupported, and an
+ * Exception will be thrown.
+ *
+ * Other transformers may be useful to precede this handler. For example,
+ * any Serializable object payload can be converted into a byte array by the
+ * {@link org.springframework.integration.transformer.PayloadSerializingTransformer}.
+ * Likewise, any Object can be converted to a String based on its toString()
+ * method by the {@link org.springframework.integration.transformer.ObjectToStringTransformer}.
*
* @author Mark Fisher
*/
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/transformer/PayloadDeserializingTransformer.java b/org.springframework.integration/src/main/java/org/springframework/integration/transformer/PayloadDeserializingTransformer.java
new file mode 100644
index 0000000000..cc429644ae
--- /dev/null
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/transformer/PayloadDeserializingTransformer.java
@@ -0,0 +1,54 @@
+/*
+ * 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.transformer;
+
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamException;
+
+/**
+ * Transformer that deserializes the inbound byte array payload to an object.
+ *
The byte array payload must be a result of serialization.
+ *
+ * @author Mark Fisher
+ * @since 1.0.1
+ */
+public class PayloadDeserializingTransformer extends AbstractPayloadTransformer {
+
+ @Override
+ protected Object transformPayload(byte[] payload) throws Exception {
+ ByteArrayInputStream byteStream = new ByteArrayInputStream(payload);
+ ObjectInputStream objectStream = null;
+ try {
+ objectStream = new ObjectInputStream(byteStream);
+ return objectStream.readObject();
+ }
+ catch (ObjectStreamException e) {
+ throw new IllegalArgumentException(
+ "Failed to deserialize payload. Is the byte array a result of Object serialization?", e);
+ }
+ finally {
+ try {
+ objectStream.close();
+ }
+ catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+}
diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/transformer/PayloadSerializingTransformer.java b/org.springframework.integration/src/main/java/org/springframework/integration/transformer/PayloadSerializingTransformer.java
new file mode 100644
index 0000000000..3c8a02ecec
--- /dev/null
+++ b/org.springframework.integration/src/main/java/org/springframework/integration/transformer/PayloadSerializingTransformer.java
@@ -0,0 +1,46 @@
+/*
+ * 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.transformer;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import org.springframework.util.Assert;
+
+/**
+ * Transformer that serializes the inbound payload into a byte array.
+ *
The payload instance must be Serializable.
+ *
+ * @author Mark Fisher
+ * @since 1.0.1
+ */
+public class PayloadSerializingTransformer extends AbstractPayloadTransformer