if (scriptSource == null) {
return null;
}
if (!(ctx instanceof GroovyContext)) {
throw new SCXMLExpressionException(ERR_CTX_TYPE);
}
GroovyContext groovyCtx = (GroovyContext) ctx;
if (groovyCtx.getGroovyEvaluator() == null) {
groovyCtx.setGroovyEvaluator(this);
}
try {
final GroovyContext effective = getEffectiveContext(groovyCtx);
effective.setEvaluatingLocation(true);
boolean inGlobalContext = groovyCtx.getParent() instanceof SCXMLSystemContext;
Script script = getScript(effective, groovyCtx.getScriptBaseClass(), scriptSource);
Object result = script.run();
if (inGlobalContext && useInitialScriptAsBaseScript) {
groovyCtx.setScriptBaseClass(script.getClass().getName());
}
return result;
} catch (Exception e) {
String exMessage = e.getMessage() != null ? e.getMessage() : e.getClass().getCanonicalName();
throw new SCXMLExpressionException("evalScript('" + scriptSource + "'): " + exMessage, e);
}
}