ScriptEngineManager (Java SE 15 & JDK 15) (original) (raw)


public class ScriptEngineManager extends Object

The ScriptEngineManager implements a discovery and instantiation mechanism for ScriptEngine classes and also maintains a collection of key/value pairs storing state shared by all engines created by the Manager. This class uses the service provider mechanism described in theServiceLoader class to enumerate all the implementations of ScriptEngineFactory.

The ScriptEngineManager provides a method to return a list of all these factories as well as utility methods which look up factories on the basis of language name, file extension and mime type.

The Bindings of key/value pairs, referred to as the "Global Scope" maintained by the manager is available to all instances of ScriptEngine created by the ScriptEngineManager. The values in the Bindings are generally exposed in all scripts.

Since:

1.6

Constructors

Constructor Description
ScriptEngineManager() The effect of calling this constructor is the same as callingScriptEngineManager(Thread.currentThread().getContextClassLoader()).
ScriptEngineManager​(ClassLoader loader) This constructor loads the implementations ofScriptEngineFactory visible to the givenClassLoader using the service provider mechanism. If loader is null, the script engine factories that are bundled with the platform are loaded.
Modifier and Type Method Description
Object get​(String key) Gets the value for the specified key in the Global Scope
Bindings getBindings() getBindings returns the value of the globalScope field.
ScriptEngine getEngineByExtension​(String extension) Look up and create a ScriptEngine for a given extension.
ScriptEngine getEngineByMimeType​(String mimeType) Look up and create a ScriptEngine for a given mime type.
ScriptEngine getEngineByName​(String shortName) Looks up and creates a ScriptEngine for a given name.
List<ScriptEngineFactory> getEngineFactories() Returns a list whose elements are instances of all the ScriptEngineFactory classes found by the discovery mechanism.
void put​(String key,Object value) Sets the specified key/value pair in the Global Scope.
void registerEngineExtension​(String extension,ScriptEngineFactory factory) Registers a ScriptEngineFactory to handle an extension.
void registerEngineMimeType​(String type,ScriptEngineFactory factory) Registers a ScriptEngineFactory to handle a mime type.
void registerEngineName​(String name,ScriptEngineFactory factory) Registers a ScriptEngineFactory to handle a language name.
void setBindings​(Bindings bindings) setBindings stores the specified Bindings in the globalScope field.

Methods declared in class java.lang.Object

[clone](../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../java.base/java/lang/Object.html#wait%28long,int%29)