Example usage for javax.script ScriptEngine ARGV

List of usage examples for javax.script ScriptEngine ARGV

Introduction

In this page you can find the example usage for javax.script ScriptEngine ARGV.

Prototype

String ARGV

To view the source code for javax.script ScriptEngine ARGV.

Click Source Link

Document

Reserved key for a named value that passes an array of positional arguments to a script.

Usage

From source file:com.galeoconsulting.leonardinius.rest.service.ScriptRunner.java

private ScriptEngine createScriptEngine(String scriptLanguage, Script script) {
    ScriptEngine engine = engineByLanguage(scriptLanguage);
    if (engine == null) {
        throw new IllegalStateException(
                String.format("Language '%s' script engine could not be found", scriptLanguage));
    }//  ww  w .j  a v  a  2 s .  co m
    updateBindings(engine, ScriptContext.ENGINE_SCOPE, new HashMap<String, Object>() {
        {
            put("log", LOG);
            put("selfScriptRunner", ScriptRunner.this);
        }
    });

    engine.getContext().setAttribute(ScriptEngine.FILENAME, scriptName(script.getFilename()),
            ScriptContext.ENGINE_SCOPE);
    engine.getContext().setAttribute(ScriptEngine.ARGV, getArgvs(script.getArgv()), ScriptContext.ENGINE_SCOPE);

    return engine;
}