Java Code Examples for javax.script.ScriptEngine#ENGINE

The following examples show how to use javax.script.ScriptEngine#ENGINE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NashornScriptEngineFactory.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getParameter(final String key) {
    switch (key) {
    case ScriptEngine.NAME:
        return "javascript";
    case ScriptEngine.ENGINE:
        return "Oracle Nashorn";
    case ScriptEngine.ENGINE_VERSION:
        return Version.version();
    case ScriptEngine.LANGUAGE:
        return "ECMAScript";
    case ScriptEngine.LANGUAGE_VERSION:
        return "ECMA - 262 Edition 5.1";
    case "THREADING":
        // The engine implementation is not thread-safe. Can't be
        // used to execute scripts concurrently on multiple threads.
        return null;
    default:
        return null;
    }
}
 
Example 2
Source File: NashornScriptEngineFactory.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getParameter(final String key) {
    switch (key) {
    case ScriptEngine.NAME:
        return "javascript";
    case ScriptEngine.ENGINE:
        return "Oracle Nashorn";
    case ScriptEngine.ENGINE_VERSION:
        return Version.version();
    case ScriptEngine.LANGUAGE:
        return "ECMAScript";
    case ScriptEngine.LANGUAGE_VERSION:
        return "ECMA - 262 Edition 5.1";
    case "THREADING":
        // The engine implementation is not thread-safe. Can't be
        // used to execute scripts concurrently on multiple threads.
        return null;
    default:
        return null;
    }
}
 
Example 3
Source File: NashornScriptEngineFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getParameter(final String key) {
    switch (key) {
    case ScriptEngine.NAME:
        return "javascript";
    case ScriptEngine.ENGINE:
        return "Oracle Nashorn";
    case ScriptEngine.ENGINE_VERSION:
        return Version.version();
    case ScriptEngine.LANGUAGE:
        return "ECMAScript";
    case ScriptEngine.LANGUAGE_VERSION:
        return "ECMA - 262 Edition 5.1";
    case "THREADING":
        // The engine implementation is not thread-safe. Can't be
        // used to execute scripts concurrently on multiple threads.
        return null;
    default:
        return null;
    }
}
 
Example 4
Source File: IndentScriptEngineHack.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Object getParameter(String key) {
    switch (key) {
        case ScriptEngine.ENGINE:
            return getEngineName();
        case ScriptEngine.ENGINE_VERSION:
            return getEngineVersion();
        case ScriptEngine.LANGUAGE:
            return getLanguageName();
        case ScriptEngine.LANGUAGE_VERSION:
            return getLanguageVersion();
        case ScriptEngine.NAME:
            return getNames().get(0);
    }
    return null;
}
 
Example 5
Source File: NashornScriptEngineFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getParameter(final String key) {
    switch (key) {
    case ScriptEngine.NAME:
        return "javascript";
    case ScriptEngine.ENGINE:
        return "Oracle Nashorn";
    case ScriptEngine.ENGINE_VERSION:
        return Version.version();
    case ScriptEngine.LANGUAGE:
        return "ECMAScript";
    case ScriptEngine.LANGUAGE_VERSION:
        return "ECMA - 262 Edition 5.1";
    case "THREADING":
        // The engine implementation is not thread-safe. Can't be
        // used to execute scripts concurrently on multiple threads.
        return null;
    default:
        return null;
    }
}
 
Example 6
Source File: NashornScriptEngineFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getParameter(final String key) {
    switch (key) {
    case ScriptEngine.NAME:
        return "javascript";
    case ScriptEngine.ENGINE:
        return "Oracle Nashorn";
    case ScriptEngine.ENGINE_VERSION:
        return Version.version();
    case ScriptEngine.LANGUAGE:
        return "ECMAScript";
    case ScriptEngine.LANGUAGE_VERSION:
        return "ECMA - 262 Edition 5.1";
    case "THREADING":
        // The engine implementation is not thread-safe. Can't be
        // used to execute scripts concurrently on multiple threads.
        return null;
    default:
        return null;
    }
}
 
Example 7
Source File: NashornScriptEngineFactory.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getParameter(final String key) {
    switch (key) {
    case ScriptEngine.NAME:
        return "javascript";
    case ScriptEngine.ENGINE:
        return "Oracle Nashorn";
    case ScriptEngine.ENGINE_VERSION:
        return Version.version();
    case ScriptEngine.LANGUAGE:
        return "ECMAScript";
    case ScriptEngine.LANGUAGE_VERSION:
        return "ECMA - 262 Edition 5.1";
    case "THREADING":
        // The engine implementation is not thread-safe. Can't be
        // used to execute scripts concurrently on multiple threads.
        return null;
    default:
        return null;
    }
}
 
Example 8
Source File: NashornScriptEngineFactory.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getParameter(final String key) {
    switch (key) {
    case ScriptEngine.NAME:
        return "javascript";
    case ScriptEngine.ENGINE:
        return "Oracle Nashorn";
    case ScriptEngine.ENGINE_VERSION:
        return Version.version();
    case ScriptEngine.LANGUAGE:
        return "ECMAScript";
    case ScriptEngine.LANGUAGE_VERSION:
        return "ECMA - 262 Edition 5.1";
    case "THREADING":
        // The engine implementation is not thread-safe. Can't be
        // used to execute scripts concurrently on multiple threads.
        return null;
    default:
        throw new IllegalArgumentException("Invalid key");
    }
}
 
Example 9
Source File: NashornScriptEngineFactory.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getParameter(final String key) {
    switch (key) {
    case ScriptEngine.NAME:
        return "javascript";
    case ScriptEngine.ENGINE:
        return "Oracle Nashorn";
    case ScriptEngine.ENGINE_VERSION:
        return Version.version();
    case ScriptEngine.LANGUAGE:
        return "ECMAScript";
    case ScriptEngine.LANGUAGE_VERSION:
        return "ECMA - 262 Edition 5.1";
    case "THREADING":
        // The engine implementation is not thread-safe. Can't be
        // used to execute scripts concurrently on multiple threads.
        return null;
    default:
        throw new IllegalArgumentException("Invalid key");
    }
}
 
Example 10
Source File: NashornScriptEngineFactory.java    From jdk8u_nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getParameter(final String key) {
    switch (key) {
    case ScriptEngine.NAME:
        return "javascript";
    case ScriptEngine.ENGINE:
        return "Oracle Nashorn";
    case ScriptEngine.ENGINE_VERSION:
        return Version.version();
    case ScriptEngine.LANGUAGE:
        return "ECMAScript";
    case ScriptEngine.LANGUAGE_VERSION:
        return "ECMA - 262 Edition 5.1";
    case "THREADING":
        // The engine implementation is not thread-safe. Can't be
        // used to execute scripts concurrently on multiple threads.
        return null;
    default:
        return null;
    }
}
 
Example 11
Source File: NashornScriptEngineFactory.java    From nashorn with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object getParameter(final String key) {
    switch (key) {
    case ScriptEngine.NAME:
        return "javascript";
    case ScriptEngine.ENGINE:
        return "Oracle Nashorn";
    case ScriptEngine.ENGINE_VERSION:
        return Version.version();
    case ScriptEngine.LANGUAGE:
        return "ECMAScript";
    case ScriptEngine.LANGUAGE_VERSION:
        return "ECMA - 262 Edition 5.1";
    case "THREADING":
        // The engine implementation is not thread-safe. Can't be
        // used to execute scripts concurrently on multiple threads.
        return null;
    default:
        throw new IllegalArgumentException("Invalid key");
    }
}
 
Example 12
Source File: ScriptEngineFactoryImpl.java    From es6draft with MIT License 6 votes vote down vote up
@Override
public Object getParameter(String key) {
    switch (key) {
    case ScriptEngine.ENGINE:
        return getEngineName();
    case ScriptEngine.ENGINE_VERSION:
        return getEngineVersion();
    case ScriptEngine.NAME:
        return getNames().get(0);
    case ScriptEngine.LANGUAGE:
        return getLanguageName();
    case ScriptEngine.LANGUAGE_VERSION:
        return getLanguageVersion();
    case "THREADING":
        return null;
    default:
        return null;
    }
}
 
Example 13
Source File: JexlScriptEngineFactory.java    From commons-jexl with Apache License 2.0 6 votes vote down vote up
@Override
public Object getParameter(String key) {
    switch (key) {
        case ScriptEngine.ENGINE:
            return getEngineName();
        case ScriptEngine.ENGINE_VERSION:
            return getEngineVersion();
        case ScriptEngine.NAME:
            return getNames();
        case ScriptEngine.LANGUAGE:
            return getLanguageName();
        case ScriptEngine.LANGUAGE_VERSION:
            return getLanguageVersion();
        case "THREADING":
            /*
             * To implement multithreading, the scripting engine context (inherited from AbstractScriptEngine)
             * would need to be made thread-safe; so would the setContext/getContext methods.
             * It is easier to share the underlying Uberspect and JEXL engine instance, especially
             * with an expression cache.
             */
        default:
            return null;
    }
}
 
Example 14
Source File: TestJavaScriptGOM.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Verify that the scripting engine is running.
 */
public void testScriptRuns() throws ScriptException {

    final String[] attrs = new String[] {
            ScriptEngine.ENGINE,
            ScriptEngine.ENGINE_VERSION,
            ScriptEngine.LANGUAGE,
            ScriptEngine.LANGUAGE_VERSION,
    };
    
    if (log.isInfoEnabled()) {

        for (String s : attrs) {

            log.info(s + "=" + jsEngine.get(s));

        }
        
    }

    jsEngine.eval("print('Hello, world!');");

}