List of usage examples for javax.script ScriptEngineFactory getEngineVersion
public String getEngineVersion();
ScriptEngine
. From source file:org.pentaho.platform.plugin.condition.scriptable.ScriptableCondition.java
public void setListAvailableEngines(final boolean value) { this.listAvailableEngines = value; if (value) {/*from w w w . j ava2 s . c o m*/ System.out.println("*** DEBUG - Display Script Engine List ***"); ScriptEngineManager manager = new ScriptEngineManager(); List<ScriptEngineFactory> factories = manager.getEngineFactories(); for (ScriptEngineFactory factory : factories) { System.out.println(String.format("Engine %s, Version %s, Language %s, Registered Names: %s", factory.getEngineName(), factory.getEngineVersion(), factory.getLanguageName(), factory.getNames().toString())); } } }
From source file:ca.hedlund.jiss.preprocessor.LangPreprocessor.java
private void printCurrentLang(JissModel model, StringBuffer cmd) { final List<String> cmds = new ArrayList<String>(); final ScriptEngineFactory factory = model.getScriptEngine().getFactory(); final String engineInfo = factory.getLanguageName() + " " + factory.getLanguageVersion() + ":" + factory.getEngineName() + " " + factory.getEngineVersion(); cmds.add(createPrintCmd(model, engineInfo)); final String prog = StringEscapeUtils.unescapeJava(factory.getProgram(cmds.toArray(new String[0]))); cmd.append(prog);/*from ww w . j av a 2 s .co m*/ }
From source file:org.apache.accumulo.core.util.shell.commands.ScriptCommand.java
private void listJSREngineInfo(ScriptEngineManager mgr, Shell shellState) throws IOException { List<ScriptEngineFactory> factories = mgr.getEngineFactories(); Set<String> lines = new TreeSet<String>(); for (ScriptEngineFactory factory : factories) { lines.add("ScriptEngineFactory Info"); String engName = factory.getEngineName(); String engVersion = factory.getEngineVersion(); String langName = factory.getLanguageName(); String langVersion = factory.getLanguageVersion(); lines.add("\tScript Engine: " + engName + " (" + engVersion + ")"); List<String> engNames = factory.getNames(); for (String name : engNames) { lines.add("\tEngine Alias: " + name); }//from www . j a v a2s . c om lines.add("\tLanguage: " + langName + " (" + langVersion + ")"); } shellState.printLines(lines.iterator(), true); }
From source file:org.apache.felix.webconsole.plugins.scriptconsole.internal.ScriptEngineManager.java
private Collection<?> registerFactory(final EngineManagerState mgr, final ScriptEngineFactory factory, final Map<Object, Object> props) { log.log(LogService.LOG_INFO,//from w w w.java 2 s. co m String.format("Adding ScriptEngine %s, %s for language %s, %s", factory.getEngineName(), factory.getEngineVersion(), factory.getLanguageName(), factory.getLanguageVersion())); mgr.factories.add(factory); mgr.factoryProperties.put(factory, props); for (Object ext : factory.getExtensions()) { mgr.extensionAssociations.put((String) ext, factory); } return factory.getExtensions(); }
From source file:com.aionemu.commons.scripting.AionScriptEngineManager.java
private AionScriptEngineManager() { ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); List<ScriptEngineFactory> factories = scriptEngineManager.getEngineFactories(); if (USE_COMPILED_CACHE) { _cache = loadCompiledScriptCache(); } else {/*from w w w. jav a 2 s . c o m*/ _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); } } }
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 v a 2 s . c o m*/ _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:ca.hedlund.jiss.preprocessor.InfoPreprocessor.java
@Override public boolean preprocessCommand(JissModel jissModel, String orig, StringBuffer cmd) { final String c = cmd.toString(); if (c.equals(INFO_CMD)) { // clear string cmd.setLength(0);// ww w . j av a2 s.co m final ScriptEngine se = jissModel.getScriptEngine(); final ScriptEngineFactory seFactory = se.getFactory(); final boolean incnl = !seFactory.getOutputStatement("").startsWith("println"); final String infoCmd = seFactory.getOutputStatement(INFO_TXT + (incnl ? "\\n" : "")); final String langCmd = seFactory.getOutputStatement("Language:" + seFactory.getLanguageName() + " " + seFactory.getLanguageVersion() + (incnl ? "\\n" : "")); final String engineCmd = seFactory.getOutputStatement("Engine:" + seFactory.getEngineName() + " " + seFactory.getEngineVersion() + (incnl ? "\\n" : "")); final String program = seFactory.getProgram(infoCmd, langCmd, engineCmd); cmd.append(StringEscapeUtils.unescapeJava(program)); } // we want the scripting engine to handle the replaced command return false; }
From source file:org.openadaptor.auxil.processor.script.ScriptProcessor.java
/** * Locates a ScriptEngine for the current language. * <br>/*www. j av a2 s . com*/ * Complicated slightly by differences between implementations * in java 1.5 and earlier versus 1.6 and later. * See Issue [SC52] * <br> * * @return ScriptEngine instance for the current language */ protected ScriptEngine createScriptEngine() { ScriptEngine engine = null; ScriptEngineManager mgr = new ScriptEngineManager(); List factories = getEngineFactories(mgr); Iterator it = factories.iterator(); while (it.hasNext() && (engine == null)) { //More factories to try, and no match yet. ScriptEngineFactory factory = (ScriptEngineFactory) it.next(); if (log.isDebugEnabled()) { //Debug code to identify origins of factories etc. Object origin = ClasspathUtils.getClassOrigin(mgr); if (origin == null) { origin = "<JRE>"; } log.debug("ScriptEngineManager loaded from: " + origin); origin = ClasspathUtils.getClassOrigin(factory); if (origin == null) { origin = "<JRE>"; } String name = factory.getEngineName(); String version = factory.getEngineVersion(); log.debug("ScriptEngineFactory " + name + " (" + version + "): " + origin); } try { List aliases = getFactoryNames(factory); if (aliases != null) { //If null couldn't get any for factory. Iterator aliasIterator = aliases.iterator(); while (aliasIterator.hasNext()) { if (language.equals(aliasIterator.next())) { log.debug("Found matching script engine for " + language); engine = factory.getScriptEngine(); break; } } } else { log.debug("Failed to get names for factory " + factory.getEngineName()); } } catch (AbstractMethodError ame) { log.debug("Failed to interrogate Factory - " + factory.getEngineName()); } } if (engine == null) { log.error("Failed to find engine for language " + language); throw new RuntimeException("Failed to find engine for language " + language); } return engine; }