List of usage examples for javax.script ScriptEngineFactory getNames
public List<String> getNames();
ScriptEngine
, which may be used to identify the ScriptEngine
by the ScriptEngineManager
. From source file:com.l2jfree.gameserver.scripting.L2ScriptEngineManager.java
private L2ScriptEngineManager() { ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); List<ScriptEngineFactory> factories = scriptEngineManager.getEngineFactories(); if (USE_COMPILED_CACHE) { _cache = loadCompiledScriptCache(); } else {// ww w. j a va 2 s .c om _cache = null; } _log.info("Initializing Script Engine Manager"); for (ScriptEngineFactory factory : factories) { try { _log.info("Script Engine: " + factory.getEngineName() + " " + factory.getEngineVersion() + " - Language: " + factory.getLanguageName() + " " + factory.getLanguageVersion()); ScriptEngine engine = factory.getScriptEngine(); for (String name : factory.getNames()) { if (_nameEngines.containsKey(name)) throw new IllegalStateException("Multiple script engines for the same name!"); _nameEngines.put(name, engine); } for (String ext : factory.getExtensions()) { if (_extEngines.containsKey(ext)) throw new IllegalStateException("Multiple script engines for the same extension!"); _extEngines.put(ext, engine); } } catch (Exception e) { _log.warn("Failed initializing factory.", e); } } preConfigure(); }
From source file:org.pentaho.reporting.ui.datasources.jdbc.ui.JdbcDataSourceDialog.java
protected void setScriptingLanguage(final String lang, final JComboBox languageField) { if (lang == null) { languageField.setSelectedItem(null); return;//from w w w .j a v a 2 s.c o m } final ListModel model = languageField.getModel(); for (int i = 0; i < model.getSize(); i++) { final ScriptEngineFactory elementAt = (ScriptEngineFactory) model.getElementAt(i); if (elementAt == null) { continue; } if (elementAt.getNames().contains(lang)) { languageField.setSelectedItem(elementAt); return; } } }