List of usage examples for javax.script ScriptEngineFactory getEngineName
public String getEngineName();
ScriptEngine
. From source file:org.omegat.gui.scripting.ScriptingWindow.java
private String listScriptEngines() { StringBuilder sb = new StringBuilder(OStrings.getString("SCW_LIST_ENGINES") + "\n"); for (ScriptEngineFactory engine : ScriptRunner.MANAGER.getEngineFactories()) { sb.append(" - "); sb.append(engine.getEngineName()); sb.append(" "); sb.append(engine.getLanguageName()); sb.append(" v."); sb.append(engine.getLanguageVersion()); sb.append(" (").append(OStrings.getString("SCW_EXTENSIONS")).append(" "); boolean hasMore = false; for (String ext : engine.getExtensions()) { if (hasMore) { sb.append(", "); }//w w w . j ava2 s . com sb.append(ext); hasMore = true; } sb.append(")"); sb.append("\n"); } return sb.toString(); }
From source file:org.openadaptor.auxil.processor.script.ScriptProcessor.java
/** * Locates a ScriptEngine for the current language. * <br>/*from w w w .j a v a 2 s. co m*/ * 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; }