/** * Construct a new script eval exception with the specified original exception. */ public StandardScriptEvalException(ScriptException ex) { super(ex.getMessage()); this.scriptException = ex; }
/** * Construct a new script eval exception with the specified original exception. */ public StandardScriptEvalException(ScriptException ex) { super(ex.getMessage()); this.scriptException = ex; }
protected Object evaluate(String script, String language, Bindings bindings) { ScriptEngine scriptEngine = getEngineByName(language); try { return scriptEngine.eval(script, bindings); } catch (ScriptException e) { throw new ActivitiException("problem evaluating script: " + e.getMessage(), e); } }
@Override protected void innerProcess(CrawlURI curi) { // depending on previous configuration, engine may // be local to this thread or shared ScriptEngine engine = getEngine(); synchronized(engine) { // synchronization is harmless for local thread engine, // necessary for shared engine engine.put("curi",curi); engine.put("appCtx", appCtx); try { engine.eval("process(curi)"); } catch (ScriptException e) { logger.log(Level.WARNING,e.getMessage(),e); } finally { engine.put("curi", null); engine.put("appCtx", null); } } }
@Override public DecideResult innerDecide(CrawlURI uri) { // depending on previous configuration, engine may // be local to this thread or shared ScriptEngine engine = getEngine(); synchronized(engine) { // synchronization is harmless for local thread engine, // necessary for shared engine try { engine.put("object",uri); engine.put("appCtx", appCtx); return (DecideResult)engine.eval("decisionFor(object)"); } catch (ScriptException e) { logger.log(Level.WARNING,e.getMessage(),e); return DecideResult.NONE; } finally { engine.put("object", null); engine.put("appCtx", null); } } }
} catch ( ScriptException Signal ) { throw new RuntimeException( "Error while reading file \"" + fileName + "\" (reason: \"" + Signal.getMessage() + "\")" ); } finally { try {
/** * This method evaluates the case expression of a decision task and returns a string representation of the evaluated result. * * @param taskToSchedule: The decision task that has the case expression to be evaluated. * @param taskInput: the input which has the values that will be used in evaluating the case expression. * @return: A String representation of the evaluated result */ @VisibleForTesting String getEvaluatedCaseValue(WorkflowTask taskToSchedule, Map<String, Object> taskInput) { String expression = taskToSchedule.getCaseExpression(); String caseValue; if (expression != null) { logger.debug("Case being evaluated using decision expression: {}", expression); try { //Evaluate the expression by using the Nashhorn based script evaluator Object returnValue = ScriptEvaluator.eval(expression, taskInput); caseValue = (returnValue == null) ? "null" : returnValue.toString(); } catch (ScriptException e) { logger.error(e.getMessage(), e); throw new RuntimeException("Error while evaluating the script " + expression, e); } } else {//In case of no case expression, get the caseValueParam and treat it as a string representation of caseValue logger.debug("No Expression available on the decision task, case value being assigned as param name"); String paramName = taskToSchedule.getCaseValueParam(); caseValue = "" + taskInput.get(paramName); } return caseValue; } }
} catch (ScriptException e) { player.printError("Failed to execute:"); player.printRaw(e.getMessage()); logger.log(Level.WARNING, "Failed to execute script", e); } catch (NumberFormatException | WorldEditException e) {
public Object get() { try { return this.engine.eval(this.script); } catch (final ScriptException e) { throw new IllegalArgumentException(e.getMessage()); } }
public void accept(final Object a) { try { final Bindings bindings = new SimpleBindings(); bindings.put(A, a); this.engine.eval(this.script, bindings); } catch (final ScriptException e) { throw new IllegalArgumentException(e.getMessage()); } }
public boolean test(final Object a) { try { final Bindings bindings = new SimpleBindings(); bindings.put(A, a); return (boolean) this.engine.eval(this.script, bindings); } catch (final ScriptException e) { throw new IllegalArgumentException(e.getMessage()); } }
public Object apply(final Object a) { try { final Bindings bindings = new SimpleBindings(); bindings.put(A, a); return this.engine.eval(this.script, bindings); } catch (final ScriptException e) { throw new IllegalArgumentException(e.getMessage()); } }
public void accept(final Object a, final Object b) { try { final Bindings bindings = new SimpleBindings(); bindings.put(A, a); bindings.put(B, b); this.engine.eval(this.script, bindings); } catch (final ScriptException e) { throw new IllegalArgumentException(e.getMessage()); } }
public void accept(final Object a, final Object b, final Object c) { try { final Bindings bindings = new SimpleBindings(); bindings.put(A, a); bindings.put(B, b); bindings.put(C, c); this.engine.eval(this.script, bindings); } catch (final ScriptException e) { throw new IllegalArgumentException(e.getMessage()); } }
public ScriptRecordWriter(final DataOutputStream out, final TaskAttemptContext context) throws IOException { this.out = out; final Configuration configuration = context.getConfiguration(); this.engine = manager.getEngineByName(configuration.get(SCRIPT_ENGINE, "gremlin-groovy")); final FileSystem fs = FileSystem.get(configuration); try { this.engine.eval(new InputStreamReader(fs.open(new Path(configuration.get(SCRIPT_FILE))))); } catch (final ScriptException e) { throw new IOException(e.getMessage(),e); } }
public Object evaluate(ScriptEngine scriptEngine, VariableScope variableScope, Bindings bindings) { String source = getScriptSource(variableScope); try { return scriptEngine.eval(source, bindings); } catch (ScriptException e) { String activityIdMessage = getActivityIdExceptionMessage(variableScope); throw new ScriptEvaluationException("Unable to evaluate script" + activityIdMessage + ": " + e.getMessage(), e); } }
public Object evaluate(ScriptEngine scriptEngine, VariableScope variableScope, Bindings bindings) { String source = getScriptSource(variableScope); try { return scriptEngine.eval(source, bindings); } catch (ScriptException e) { String activityIdMessage = getActivityIdExceptionMessage(variableScope); throw new ScriptEvaluationException("Unable to evaluate script" + activityIdMessage + ": " + e.getMessage(), e); } }
public CompiledScript compile(ScriptEngine scriptEngine, String language, String src) { if(scriptEngine instanceof Compilable && !scriptEngine.getFactory().getLanguageName().equalsIgnoreCase("ecmascript")) { Compilable compilingEngine = (Compilable) scriptEngine; try { CompiledScript compiledScript = compilingEngine.compile(src); LOG.debugCompiledScriptUsing(language); return compiledScript; } catch (ScriptException e) { throw new ScriptCompilationException("Unable to compile script: " + e.getMessage(), e); } } else { // engine does not support compilation return null; } }
public Object evaluate(ScriptEngine scriptEngine, VariableScope variableScope, Bindings bindings) { try { LOG.debugEvaluatingCompiledScript(language); return getCompiledScript().eval(bindings); } catch (ScriptException e) { if (e.getCause() instanceof BpmnError) { throw (BpmnError) e.getCause(); } String activityIdMessage = getActivityIdExceptionMessage(variableScope); throw new ScriptEvaluationException("Unable to evaluate script" + activityIdMessage +": " + e.getMessage(), e); } }
public Object evaluate(ScriptEngine scriptEngine, VariableScope variableScope, Bindings bindings) { try { LOG.debugEvaluatingCompiledScript(language); return getCompiledScript().eval(bindings); } catch (ScriptException e) { if (e.getCause() instanceof BpmnError) { throw (BpmnError) e.getCause(); } String activityIdMessage = getActivityIdExceptionMessage(variableScope); throw new ScriptEvaluationException("Unable to evaluate script" + activityIdMessage +": " + e.getMessage(), e); } }