javax.script

Class ScriptEngineManager


  • 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 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
    • Constructor Detail

      • ScriptEngineManager

        public ScriptEngineManager()
        If the thread context ClassLoader can be accessed by the caller, then the effect of calling this constructor is the same as calling ScriptEngineManager(Thread.currentThread().getContextClassLoader()). Otherwise, the effect is the same as calling ScriptEngineManager(null).
        See Also:
        Thread.getContextClassLoader()
      • 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 Detail

      • setBindings

        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.
        Parameters:
        bindings - The specified Bindings
        Throws:
        IllegalArgumentException - if bindings is null.
      • getBindings

        public Bindings getBindings()
        getBindings returns the value of the globalScope field. ScriptEngineManager sets this Bindings as global bindings for ScriptEngine objects created by it.
        Returns:
        The globalScope field.
      • get

        public Object get(String key)
        Gets the value for the specified key in the Global Scope
        Parameters:
        key - The key whose value is to be returned.
        Returns:
        The value for the specified key.
      • getEngineByName

        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 set 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 getNames method of its ScriptEngineFactory.
        Returns:
        A ScriptEngine created by the factory located in the search. Returns null if no such factory was found. The ScriptEngineManager sets its own globalScope Bindings as the GLOBAL_SCOPE Bindings of the newly created ScriptEngine.
        Throws:
        NullPointerException - if shortName is null.
      • getEngineByExtension

        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.
        Parameters:
        extension - The given extension
        Returns:
        The engine to handle scripts with this extension. Returns null if not found.
        Throws:
        NullPointerException - if extension is null.
      • getEngineByMimeType

        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.
        Parameters:
        mimeType - The given mime type
        Returns:
        The engine to handle scripts with this mime type. Returns null if not found.
        Throws:
        NullPointerException - if mimeType is null.
      • getEngineFactories

        public List<ScriptEngineFactory> getEngineFactories()
        Returns a list whose elements are instances of all the ScriptEngineFactory classes found by the discovery mechanism.
        Returns:
        List of all discovered ScriptEngineFactorys.
      • registerEngineName

        public void registerEngineName(String name,
                              ScriptEngineFactory factory)
        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.
        factory - The class to associate with the given name.
        Throws:
        NullPointerException - if any of the parameters is null.
      • registerEngineMimeType

        public void registerEngineMimeType(String type,
                                  ScriptEngineFactory factory)
        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 the ScriptEngineFactory.
        factory - The class to associate with the given mime type.
        Throws:
        NullPointerException - if any of the parameters is null.
      • registerEngineExtension

        public void registerEngineExtension(String extension,
                                   ScriptEngineFactory factory)
        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 the ScriptEngineFactory.
        factory - The class to associate with the given extension.
        Throws:
        NullPointerException - if any of the parameters is null.

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/script/scriptenginemanager.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut