Save This Page
Home » openjdk-7 » javax » script » [javadoc | source]
javax.script
public class: ScriptEngineManager [javadoc | source]
java.lang.Object
   javax.script.ScriptEngineManager
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 to enumerate all the implementations of ScriptEngineFactory.

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.

Constructor:
 public ScriptEngineManager() 
 public ScriptEngineManager(ClassLoader loader) 
    This constructor loads the implementations of ScriptEngineFactory visible to the given ClassLoader using the service provider mechanism.

    If loader is null, the script engine factories that are bundled with the platform and that are in the usual extension directories (installed extensions) are loaded.

    Parameters:
    loader - ClassLoader used to discover script engine factories.
Method from javax.script.ScriptEngineManager Summary:
get,   getBindings,   getEngineByExtension,   getEngineByMimeType,   getEngineByName,   getEngineFactories,   put,   registerEngineExtension,   registerEngineMimeType,   registerEngineName,   setBindings
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.script.ScriptEngineManager Detail:
 public Object get(String key) 
    Gets the value for the specified key in the Global Scope
 public Bindings getBindings() 
    getBindings returns the value of the globalScope field. ScriptEngineManager sets this Bindings as global bindings for ScriptEngine objects created by it.
 public ScriptEngine getEngineByExtension(String extension) 
    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.
 public ScriptEngine getEngineByMimeType(String mimeType) 
    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.
 public ScriptEngine getEngineByName(String shortName) 
    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.
 public List getEngineFactories() 
    Returns an array whose elements are instances of all the ScriptEngineFactory classes found by the discovery mechanism.
 public  void put(String key,
    Object value) 
    Sets the specified key/value pair in the Global Scope.
 public  void registerEngineExtension(String extension,
    ScriptEngineFactory factory) 
    Registers a ScriptEngineFactory to handle an extension. Overrides any such association found using the Discovery mechanism.
 public  void registerEngineMimeType(String type,
    ScriptEngineFactory factory) 
    Registers a ScriptEngineFactory to handle a mime type. Overrides any such association found using the Discovery mechanism.
 public  void registerEngineName(String name,
    ScriptEngineFactory factory) 
    Registers a ScriptEngineFactory to handle a language name. Overrides any such association found using the Discovery mechanism.
 public  void setBindings(Bindings bindings) 
    setBindings stores the specified Bindings in the globalScope field. ScriptEngineManager sets this Bindings as global bindings for ScriptEngine objects created by it.