Search in sources :

Example 1 with ScriptEngineFactory

use of javax.script.ScriptEngineFactory in project orientdb by orientechnologies.

the class OScriptManager method getEngine.

public ScriptEngine getEngine(final String iLanguage) {
    if (iLanguage == null)
        throw new OCommandScriptException("No language was specified");
    final String lang = iLanguage.toLowerCase();
    final ScriptEngineFactory scriptEngineFactory = engines.get(lang);
    if (scriptEngineFactory == null)
        throw new OCommandScriptException("Unsupported language: " + iLanguage + ". Supported languages are: " + getSupportedLanguages());
    return scriptEngineFactory.getScriptEngine();
}
Also used : OSQLScriptEngineFactory(com.orientechnologies.orient.core.sql.OSQLScriptEngineFactory) ScriptEngineFactory(javax.script.ScriptEngineFactory)

Example 2 with ScriptEngineFactory

use of javax.script.ScriptEngineFactory in project es6draft by anba.

the class ScriptEngineFactoryTest method setUp.

@Before
public void setUp() {
    ScriptEngineManager manager = new ScriptEngineManager();
    for (ScriptEngineFactory factory : manager.getEngineFactories()) {
        if (ENGINE_NAME.equals(factory.getEngineName())) {
            this.factory = factory;
            return;
        }
    }
    fail("script engine factory not found");
}
Also used : ScriptEngineFactory(javax.script.ScriptEngineFactory) ScriptEngineManager(javax.script.ScriptEngineManager) Before(org.junit.Before)

Example 3 with ScriptEngineFactory

use of javax.script.ScriptEngineFactory in project camel by apache.

the class ScriptBuilder method lookupScriptEngineFactory.

protected static ScriptEngineFactory lookupScriptEngineFactory(String language) {
    ScriptEngineManager manager = new ScriptEngineManager();
    for (ScriptEngineFactory factory : manager.getEngineFactories()) {
        // some script names has alias
        String[] names = getScriptNames(language);
        for (String name : names) {
            if (factory.getLanguageName().equals(name)) {
                return factory;
            }
        }
    }
    // fallback to get engine by name
    ScriptEngine engine = createScriptEngine(language, true);
    if (engine != null) {
        return engine.getFactory();
    }
    return null;
}
Also used : ScriptEngineFactory(javax.script.ScriptEngineFactory) ScriptEngineManager(javax.script.ScriptEngineManager) ScriptEngine(javax.script.ScriptEngine)

Example 4 with ScriptEngineFactory

use of javax.script.ScriptEngineFactory in project hazelcast by hazelcast.

the class OSGiScriptEngineManager method getEngineFactories.

@Override
public List<ScriptEngineFactory> getEngineFactories() {
    List<ScriptEngineFactory> osgiFactories = new ArrayList<ScriptEngineFactory>();
    for (ScriptEngineManagerInfo info : scriptEngineManagerInfoList) {
        for (ScriptEngineFactory factory : info.scriptEngineManager.getEngineFactories()) {
            OSGiScriptEngineFactory scriptEngineFactory = new OSGiScriptEngineFactory(factory, info.classloader);
            osgiFactories.add(scriptEngineFactory);
        }
    }
    return osgiFactories;
}
Also used : ScriptEngineFactory(javax.script.ScriptEngineFactory) ArrayList(java.util.ArrayList)

Example 5 with ScriptEngineFactory

use of javax.script.ScriptEngineFactory in project hazelcast by hazelcast.

the class HazelcastOSGiScriptEngineFactoryTest method registerAndGetScriptEngineByExtensionSuccessfully.

@Test
public void registerAndGetScriptEngineByExtensionSuccessfully() {
    ScriptEngineManager scriptEngineManager = ScriptEngineManagerContext.getScriptEngineManager();
    GroovyScriptEngineFactory groovyScriptEngineFactory = new GroovyScriptEngineFactory();
    scriptEngineManager.registerEngineExtension("groovy", groovyScriptEngineFactory);
    ScriptEngine scriptEngine = scriptEngineManager.getEngineByExtension("groovy");
    assertNotNull(scriptEngine);
    ScriptEngineFactory scriptEngineFactory = scriptEngine.getFactory();
    verifyScriptEngineFactory(scriptEngineFactory);
}
Also used : GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineFactory(javax.script.ScriptEngineFactory) GroovyScriptEngineFactory(org.codehaus.groovy.jsr223.GroovyScriptEngineFactory) ScriptEngineManager(javax.script.ScriptEngineManager) ScriptEngine(javax.script.ScriptEngine) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ScriptEngineFactory (javax.script.ScriptEngineFactory)30 ScriptEngineManager (javax.script.ScriptEngineManager)11 ScriptEngine (javax.script.ScriptEngine)9 Test (org.junit.Test)9 QuickTest (com.hazelcast.test.annotation.QuickTest)8 GroovyScriptEngineFactory (org.codehaus.groovy.jsr223.GroovyScriptEngineFactory)8 ArrayList (java.util.ArrayList)4 URL (java.net.URL)2 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 JSONWriter (org.apache.felix.utils.json.JSONWriter)2 Result (com.buschmais.jqassistant.core.analysis.api.Result)1 RuleExecutorException (com.buschmais.jqassistant.core.rule.api.executor.RuleExecutorException)1 OSQLScriptEngineFactory (com.orientechnologies.orient.core.sql.OSQLScriptEngineFactory)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1