use of javax.script.ScriptException in project incubator-atlas by apache.
the class Titan1Graph method executeGremlinScript.
private Object executeGremlinScript(String gremlinQuery) throws AtlasBaseException {
GremlinGroovyScriptEngine scriptEngine = getGremlinScriptEngine();
try {
Bindings bindings = scriptEngine.createBindings();
bindings.put("graph", getGraph());
bindings.put("g", getGraph().traversal());
Object result = scriptEngine.eval(gremlinQuery, bindings);
return result;
} catch (ScriptException e) {
throw new AtlasBaseException(AtlasErrorCode.GREMLIN_SCRIPT_EXECUTION_FAILED, gremlinQuery);
} finally {
releaseGremlinScriptEngine(scriptEngine);
}
}
use of javax.script.ScriptException in project midpoint by Evolveum.
the class Jsr223ScriptEvaluator method createCompiledScript.
private CompiledScript createCompiledScript(String codeString, String contextDescription) throws ExpressionEvaluationException {
CompiledScript compiledScript = scriptCache.get(codeString);
if (compiledScript != null) {
return compiledScript;
}
try {
InternalMonitor.recordScriptCompile();
compiledScript = ((Compilable) scriptEngine).compile(codeString);
} catch (ScriptException e) {
throw new ExpressionEvaluationException(e.getMessage() + " in " + contextDescription, e);
}
scriptCache.put(codeString, compiledScript);
return compiledScript;
}
use of javax.script.ScriptException in project jmeter by apache.
the class JSR223Timer method delay.
/** {@inheritDoc} */
@Override
public long delay() {
long delay = 0;
try {
ScriptEngine scriptEngine = getScriptEngine();
Object o = processFileOrScript(scriptEngine, null);
if (o == null) {
log.warn("Script did not return a value");
return 0;
}
delay = Long.parseLong(o.toString());
} catch (NumberFormatException | IOException | ScriptException e) {
log.error("Problem in JSR223 script, {}", getName(), e);
}
return delay;
}
use of javax.script.ScriptException in project jmeter by apache.
the class JSR223PreProcessor method process.
@Override
public void process() {
try {
ScriptEngine scriptEngine = getScriptEngine();
processFileOrScript(scriptEngine, null);
} catch (ScriptException | IOException e) {
log.error("Problem in JSR223 script, {}", getName(), e);
}
}
use of javax.script.ScriptException in project jmeter by apache.
the class JSR223TestElement method getScriptEngine.
/**
* @return {@link ScriptEngine} for language defaulting to groovy if language is not set
* @throws ScriptException when no {@link ScriptEngine} could be found
*/
protected ScriptEngine getScriptEngine() throws ScriptException {
String lang = getScriptLanguageWithDefault();
ScriptEngine scriptEngine = getInstance().getEngineByName(lang);
if (scriptEngine == null) {
throw new ScriptException("Cannot find engine named: '" + lang + "', ensure you set language field in JSR223 Test Element: " + getName());
}
return scriptEngine;
}
Aggregations