diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/transform/PayloadFactoryMediator.java b/modules/core/src/main/java/org/apache/synapse/mediators/transform/PayloadFactoryMediator.java index ef87351660..8f4b00e2fa 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/transform/PayloadFactoryMediator.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/transform/PayloadFactoryMediator.java @@ -84,16 +84,6 @@ public class PayloadFactoryMediator extends AbstractMediator { private static final Log log = LogFactory.getLog(PayloadFactoryMediator.class); public PayloadFactoryMediator() { - //ignore DTDs for XML Input - inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); - inputFactory.setProperty(XMLInputFactory.IS_COALESCING, true); - Map props = StAXUtils.loadFactoryProperties("XMLInputFactory.properties"); - if (props != null) { - for (Object o : props.entrySet()) { - Map.Entry entry = (Map.Entry) o; - inputFactory.setProperty((String) entry.getKey(), entry.getValue()); - } - } } /** diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/FreeMarkerTemplateProcessor.java b/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/FreeMarkerTemplateProcessor.java index a12acb4c00..a097afd1f3 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/FreeMarkerTemplateProcessor.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/FreeMarkerTemplateProcessor.java @@ -34,6 +34,7 @@ import org.apache.axiom.om.OMElement; import org.apache.axiom.om.OMNode; import org.apache.axiom.om.OMText; +import org.apache.axiom.om.util.StAXUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -60,6 +61,7 @@ import java.util.Map; import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLInputFactory; import static org.apache.synapse.mediators.transform.pfutils.Constants.ARGS_INJECTING_NAME; import static org.apache.synapse.mediators.transform.pfutils.Constants.ARGS_INJECTING_PREFIX; @@ -119,6 +121,7 @@ public void init() { compileFreeMarkerTemplate(format, getMediaType()); templateLoaded = true; } + this.readInputFactoryProperties(); } @Override diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/RegexTemplateProcessor.java b/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/RegexTemplateProcessor.java index d96889408e..1a6ba8958c 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/RegexTemplateProcessor.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/RegexTemplateProcessor.java @@ -47,7 +47,7 @@ public String processTemplate(String template, String mediaType, MessageContext @Override public void init() { - // nothing to do since no pre processing is needed + this.readInputFactoryProperties(); } /** diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/TemplateProcessor.java b/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/TemplateProcessor.java index c225954ccb..d7d5f65e5e 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/TemplateProcessor.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/transform/pfutils/TemplateProcessor.java @@ -23,6 +23,7 @@ import org.apache.axiom.om.OMException; import org.apache.axiom.om.impl.builder.StAXBuilder; import org.apache.axiom.om.impl.builder.StAXOMBuilder; +import org.apache.axiom.om.util.StAXUtils; import org.apache.axis2.AxisFault; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -526,4 +527,19 @@ protected void handleException(String msg) { public abstract boolean getTemplateStatus(); + /** + * Read XMLInputFactory properties from XMLInputFactory.properties file. + */ + public void readInputFactoryProperties() { + //ignore DTDs for XML Input + inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); + inputFactory.setProperty(XMLInputFactory.IS_COALESCING, true); + Map props = StAXUtils.loadFactoryProperties("XMLInputFactory.properties"); + if (props != null) { + for (Object o : props.entrySet()) { + Map.Entry entry = (Map.Entry) o; + inputFactory.setProperty((String) entry.getKey(), entry.getValue()); + } + } + } }