Hello,
I have implemented a Custom Exception Handler which dumps all input data (input parameters) to a file, whenever an exception occurs. It works fine for ruleapps which use a XML based XOM (XSD-XOM). Below are some working code fragments provided for better understanding:
Class ExcepHandler.java:
@Override
public void handleActionException(Exception arg0, RuleInstance ruleInstance) throws Exception {
logger.log(Level.SEVERE, "Exception while executing action of rule: " + ruleInstance.getRuleName(), arg0);
dumpInData();
throw arg0;
}
Class Dump.java:
public static void dumpInData(Map<String, Object> inData, RunningEngine re){
// No XmlBindingService available for Java-XOM rules...
xmlBindingService.set(re.getService(XmlBindingService.class));
xmlDriver.set(xmlBindingService.get().getDataDriver());
for (String inParamName : inData.keySet()) {
Object inParamObject = inData.get(inParamName);
if (inParamObject instanceof IlrXmlObject) {
StringWriter sw = new StringWriter();
xmlDriver.get().writeObject(xmlObject, sw);
}
}
}
The above code lets you write all input data into an XML file.
Problem: There is no XML driver available for ruleapps which use a Java model (Java-XOM). The object inData is not of type IlrXmlObject. It is a custom Java type class (e.g. MyInputData). Regardless of how you call the rule app (XML payload, JSON payload), the object type is not IlrXMLObject.
How do I retrieve the input data/input parameters robustly for Java-XOM ruleapps? Is it possible to retrieve the input data as a JSON payload and dump it into a file, similar to the code above?