diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/ObjectToStringTransformerParser.java b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/ObjectToStringTransformerParser.java
index 74c7ab5f01..2ba8796ec4 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/ObjectToStringTransformerParser.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/ObjectToStringTransformerParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2013 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.
@@ -16,25 +16,31 @@
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;
+import org.springframework.integration.transformer.ObjectToStringTransformer;
+import org.springframework.util.StringUtils;
+import org.w3c.dom.Element;
/**
* Parser for the 'object-to-string-transformer' element.
- *
+ *
* @author Mark Fisher
+ * @author Gary Russell
*/
public class ObjectToStringTransformerParser extends AbstractTransformerParser {
@Override
protected String getTransformerClassName() {
- return IntegrationNamespaceUtils.BASE_PACKAGE + ".transformer.ObjectToStringTransformer";
+ return ObjectToStringTransformer.class.getName();
}
@Override
protected void parseTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
+ String charset = element.getAttribute("charset");
+ if (StringUtils.hasText(charset)) {
+ builder.addConstructorArgValue(charset);
+ }
}
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToStringTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToStringTransformer.java
index df3af1de3a..3650b8e8e8 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToStringTransformer.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/ObjectToStringTransformer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2008 the original author or authors.
+ * Copyright 2002-2013 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.
@@ -16,18 +16,47 @@
package org.springframework.integration.transformer;
+import org.springframework.util.Assert;
+
+
/**
* A simple transformer that creates an outbound payload by invoking the
- * inbound payload Object's toString() method.
- *
+ * inbound payload Object's toString() method. Unless the
+ * payload is a byte[] or char[]. If the payload
+ * is a byte[], it will be transformed to a String containing the
+ * array's contents, using the {@link #charset}
+ * which, by default, is "UTF-8". If the payload is a char[], it will be
+ * transformed to a String object with the array's contents.
+ *
* @author Mark Fisher
+ * @author Andrew Cowlin
+ * @author Gary Russell
* @since 1.0.1
*/
public class ObjectToStringTransformer extends AbstractPayloadTransformer