Evaluator eval = exctx.getEvaluator();
for (TransitionalState ts : statesToInvoke) {
if (ts.getInvokes().isEmpty()) {
continue;
}
Context context = scInstance.getContext(ts);
for (Invoke i : ts.getInvokes()) {
String src = i.getSrc();
if (src == null) {
String srcexpr = i.getSrcexpr();
Object srcObj;
try {
context.setLocal(Context.NAMESPACES_KEY, i.getNamespaces());
srcObj = eval.eval(context, srcexpr);
context.setLocal(Context.NAMESPACES_KEY, null);
src = String.valueOf(srcObj);
} catch (SCXMLExpressionException see) {
exctx.getInternalIOProcessor().addEvent(new TriggerEvent(TriggerEvent.ERROR_EXECUTION, TriggerEvent.ERROR_EVENT));
exctx.getErrorReporter().onError(ErrorConstants.EXPRESSION_ERROR, see.getMessage(), i);
}
}
String source = src;
PathResolver pr = i.getPathResolver();
if (pr != null) {
source = i.getPathResolver().resolvePath(src);
}
Invoker inv;
try {
inv = exctx.newInvoker(i.getType());
} catch (InvokerException ie) {
exctx.getInternalIOProcessor().addEvent(new TriggerEvent("failed.invoke."+ts.getId(), TriggerEvent.ERROR_EVENT));
continue;
}
List<Param> params = i.params();
Map<String, Object> args = new HashMap<String, Object>();
for (Param p : params) {
String argExpr = p.getExpr();
Object argValue = null;
context.setLocal(Context.NAMESPACES_KEY, p.getNamespaces());
// Do we have an "expr" attribute?
if (argExpr != null && argExpr.trim().length() > 0) {
try {
argValue = eval.eval(context, argExpr);
} catch (SCXMLExpressionException see) {
exctx.getInternalIOProcessor().addEvent(new TriggerEvent(TriggerEvent.ERROR_EXECUTION, TriggerEvent.ERROR_EVENT));
exctx.getErrorReporter().onError(ErrorConstants.EXPRESSION_ERROR, see.getMessage(), i);
}
} else {
// No. Does value of "name" attribute refer to a valid
// location in the data model?
try {
argValue = eval.evalLocation(context, p.getName());
if (argValue == null) {
// Generate error, 4.3.1 in WD-scxml-20080516
exctx.getInternalIOProcessor().addEvent(new TriggerEvent(ts.getId() + ERR_ILLEGAL_ALLOC, TriggerEvent.ERROR_EVENT));
}
} catch (SCXMLExpressionException see) {
exctx.getInternalIOProcessor().addEvent(new TriggerEvent(TriggerEvent.ERROR_EXECUTION, TriggerEvent.ERROR_EVENT));
exctx.getErrorReporter().onError(ErrorConstants.EXPRESSION_ERROR, see.getMessage(), i);
}
}
context.setLocal(Context.NAMESPACES_KEY, null);
args.put(p.getName(), argValue);
}
String invokeId = exctx.setInvoker(i, inv);
inv.setInvokeId(invokeId);
inv.setParentIOProcessor(exctx.getExternalIOProcessor());