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();
}
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");
}
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;
}
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;
}
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);
}
Aggregations