| |
|
| java.lang.Object javax.script.ScriptEngineManager
ScriptEngineManager | public class ScriptEngineManager (Code) | | 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.
The Discovery feature uses the Service Provider mechanism described in the Jar
File Specification to enumerate all implementations of
ScriptEngineFactory which can be loaded by the thread context
ClassLoader. If the current security policy does not allow access to thread context
ClassLoader, then bootstrap loader is used. The ScriptEngineManager provides
a method to return an array 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.
author: Mike Grogan author: A. Sundararajan since: 1.6 |
Constructor Summary | |
public | ScriptEngineManager() The constructor checks for implementors of
ScriptEngineFactory using the mechanism for
discovering service providers described in the Jar File Specification.
Namely, it looks for resources named
META-INF/services/javax.script.ScriptEngineFactory in the thread context ClassLoader . | public | ScriptEngineManager(ClassLoader loader) The constructor checks for implementors of
ScriptEngineFactory using the mechanism for
discovering service providers described in the Jar File Specification.
Namely, it looks for resources named
META-INF/services/javax.script.ScriptEngineFactory in the given ClassLoader . |
ScriptEngineManager | public ScriptEngineManager()(Code) | | The constructor checks for implementors of
ScriptEngineFactory using the mechanism for
discovering service providers described in the Jar File Specification.
Namely, it looks for resources named
META-INF/services/javax.script.ScriptEngineFactory in the thread context ClassLoader . Each line in such
a resource names a class implementing ScriptEngineFactory .
An instance of each of these classes is created and stored in the engineSpis
HashSet field. Invalid or incorrect entries are ignored. If thread context
loader is not accessible by current security policy, then bootstrap loader will be used.
|
ScriptEngineManager | public ScriptEngineManager(ClassLoader loader)(Code) | | The constructor checks for implementors of
ScriptEngineFactory using the mechanism for
discovering service providers described in the Jar File Specification.
Namely, it looks for resources named
META-INF/services/javax.script.ScriptEngineFactory in the given ClassLoader . Each line in such
a resource names a class implementing ScriptEngineFactory .
An instance of each of these classes is created and stored in the engineSpis
HashSet field. Invalid or incorrect entries are ignored.
Parameters: loader - ClassLoader used to discover factory resources. |
get | public Object get(String key)(Code) | | Gets the value for the specified key in the Global Scope
Parameters: key - The key whose value is to be returned. The value for the specified key. |
getBindings | public Bindings getBindings()(Code) | | getBindings returns the value of the globalScope field.
The globalScope field. |
getEngineByExtension | public ScriptEngine getEngineByExtension(String extension)(Code) | | Look up and create a ScriptEngine for a given extension. The algorithm
used by getEngineByName is used except that the search starts
by looking for a ScriptEngineFactory registered to handle the
given extension using registerEngineExtension .
Parameters: extension - The given extension The engine to handle scripts with this extension. Returns null if not found. |
getEngineByMimeType | public ScriptEngine getEngineByMimeType(String mimeType)(Code) | | Look up and create a ScriptEngine for a given mime type. The algorithm
used by getEngineByName is used except that the search starts
by looking for a ScriptEngineFactory registered to handle the
given mime type using registerEngineMimeType .
Parameters: mimeType - The given mime type The engine to handle scripts with this mime type. Returns null if not found. |
getEngineByName | public ScriptEngine getEngineByName(String shortName)(Code) | | Looks up and creates a ScriptEngine for a given name.
The algorithm first searches for a ScriptEngineFactory that has been
registered as a handler for the specified name using the registerEngineName
method.
If one is not found, it searches the array of ScriptEngineFactory instances
stored by the constructor for one with the specified name. If a ScriptEngineFactory
is found by either method, it is used to create instance of ScriptEngine .
Parameters: shortName - The short name of the ScriptEngine implementation.returned by the getName method of its ScriptEngineFactory . A ScriptEngine created by the factory located in the search. Returns nullif no such factory was found. The ScriptEngineManager sets its own globalScope Bindings as the GLOBAL_SCOPE Bindings of the newlycreated ScriptEngine . |
getEngineFactories | public List<ScriptEngineFactory> getEngineFactories()(Code) | | Returns an array whose elements are instances of all the ScriptEngineFactory classes
found by the discovery mechanism.
List of all discovered ScriptEngineFactory s. |
put | public void put(String key, Object value)(Code) | | Sets the specified key/value pair in the Global Scope.
Parameters: key - Key to set Parameters: value - Value to set. throws: NullPointerException - if key is null |
registerEngineExtension | public void registerEngineExtension(String extension, ScriptEngineFactory factory)(Code) | | Registers a ScriptEngineFactory to handle an extension.
Overrides any such association found using the Discovery mechanism.
Parameters: extension - The extension type to be associated with theScriptEngineFactory . Parameters: factory - The class to associate with the given extension. |
registerEngineMimeType | public void registerEngineMimeType(String type, ScriptEngineFactory factory)(Code) | | Registers a ScriptEngineFactory to handle a mime type.
Overrides any such association found using the Discovery mechanism.
Parameters: type - The mime type to be associated with theScriptEngineFactory . Parameters: factory - The class to associate with the given mime type. |
registerEngineName | public void registerEngineName(String name, ScriptEngineFactory factory)(Code) | | Registers a ScriptEngineFactory to handle a language
name. Overrides any such association found using the Discovery mechanism.
Parameters: name - The name to be associated with the ScriptEngineFactory . Parameters: factory - The class to associate with the given name. |
setBindings | public void setBindings(Bindings bindings)(Code) | | setBindings stores the specified Bindings
in the globalScope field.
Parameters: bindings - The specified Bindings |
|
|
|