commandObject);
}
// now set the any dynamic properties evaluating XPath's on the current message
for (String name : messageSetterProperties.keySet()) {
SynapseXPath xpath = messageSetterProperties.get(name);
String value = xpath.stringValueOf(synCtx);
PropertyHelper.setInstanceProperty(name, value, commandObject);
}
synLog.traceOrDebug("POJO initialized successfully, invoking the execute() method");
// then call the execute method if the Command interface is implemented
if (commandObject instanceof Command) {
try {
((Command) commandObject).execute();
} catch (Exception e) {
handleException("Error invoking POJO command class : "
+ command.getClass(), e, synCtx);
}
} else {
try {
Method exeMethod = command.getMethod("execute");
exeMethod.invoke(commandObject);
} catch (NoSuchMethodException e) {
handleException("Cannot locate an execute() method on POJO class : " +
command.getClass(), e, synCtx);
} catch (Exception e) {
handleException("Error invoking the execute() method on POJO class : " +
command.getClass(), e, synCtx);
}
}
// then set the context properties back to the messageContext from the command
for (String name : contextGetterProperties.keySet()) {
synCtx.setProperty(contextGetterProperties.get(name),
getInstanceProperty(name, commandObject, synCtx));
}
// now set the any message properties evaluating XPath's on the current message back
// to the message from the command
for (String name : messageGetterProperties.keySet()) {
SynapseXPath xpath = messageGetterProperties.get(name);
Object resultValue = getInstanceProperty(name, commandObject, synCtx);
try {
List list = EIPUtils.getMatchingElements(synCtx.getEnvelope(), xpath);