Skip to content

Commit

Permalink
Add changes to read XMLInputFactory.properties
Browse files Browse the repository at this point in the history
Read XMLInputFactory.properties in both regex and freemarker template processors.
  • Loading branch information
GDLMadushanka committed Dec 5, 2023
1 parent ce6c782 commit d3a4270
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public void init() {
compileFreeMarkerTemplate(format, getMediaType());
templateLoaded = true;
}
this.readInputFactoryProperties();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}
}
}

0 comments on commit d3a4270

Please sign in to comment.