INT-1654 added 'outputProperties' to ResultToStringTransformer

This commit is contained in:
Mark Fisher
2010-12-01 16:35:33 -05:00
parent fadddf94b9
commit 7db581b40b

View File

@@ -16,6 +16,8 @@
package org.springframework.integration.xml.transformer;
import java.util.Properties;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
@@ -36,6 +38,8 @@ import org.springframework.xml.transform.StringResult;
*/
public class ResultToStringTransformer implements ResultTransformer {
private volatile Properties outputProperties;
private final TransformerFactory transformerFactory;
@@ -44,6 +48,10 @@ public class ResultToStringTransformer implements ResultTransformer {
}
public void setOutputProperties(Properties outputProperties) {
this.outputProperties = outputProperties;
}
public Object transformResult(Result result) {
String returnString = null;
if (result instanceof StringResult) {
@@ -68,9 +76,14 @@ public class ResultToStringTransformer implements ResultTransformer {
}
private Transformer getNewTransformer() throws TransformerConfigurationException {
Transformer transformer = null;
synchronized (this.transformerFactory) {
return this.transformerFactory.newTransformer();
transformer = this.transformerFactory.newTransformer();
}
if (this.outputProperties != null) {
transformer.setOutputProperties(this.outputProperties);
}
return transformer;
}
}