public class BundleScriptEngineManager extends ScriptEngineManager
ScriptEngineManager that properly deals with ScriptEngineFactory
implementations provided in OSGi modules. In particular, bundles that provide a javax.script.ScriptEngineFactory file in their META-INF/services directory (Java Service Provider
infrastructure) will be handled by this ScriptEngineManager, wrapping the provided ScriptEngineFactory implementation
in a BundleScriptEngineFactory so that the appropriate class loader will be used to resolve views and
associated resources. Additionally, provided script extensions will now be listened to and installed bundles will be
scanned so that any installed module that provides views that can be handled by the newly installed
ScriptEngineFactory will be now able to answer to view requests.
Additionally, if the provided ScriptEngineFactory implementations also implement Configurable, this
BundleScriptEngineManager will call its methods so that additional set up / clean up can be performed when the bundle
is started or stopped.
public static BundleScriptEngineManager getInstance()
public Object get(String key)
get in class ScriptEngineManagerpublic Bindings getBindings()
getBindings in class ScriptEngineManagerpublic void put(String key, Object value)
put in class ScriptEngineManagerpublic void setBindings(Bindings bindings)
setBindings in class ScriptEngineManagerpublic ScriptEngine getEngineByExtension(String extension)
getEngineByExtension in class ScriptEngineManagerpublic ScriptEngine getEngineByMimeType(String mimeType)
getEngineByMimeType in class ScriptEngineManagerpublic ScriptEngine getEngineByName(String shortName)
getEngineByName in class ScriptEngineManagerpublic List<ScriptEngineFactory> getEngineFactories()
getEngineFactories in class ScriptEngineManagerpublic void registerEngineExtension(String extension, ScriptEngineFactory factory)
registerEngineExtension in class ScriptEngineManagerpublic void registerEngineMimeType(String type, ScriptEngineFactory factory)
registerEngineMimeType in class ScriptEngineManagerpublic void registerEngineName(String name, ScriptEngineFactory factory)
registerEngineName in class ScriptEngineManagerpublic void removeScriptEngineFactoriesIfNeeded(org.osgi.framework.Bundle bundle)
ScriptEngineFactory instances associated with the specified Bundle when it is
stopped, making sure that the associated views are also made unavailable by calling BundleScriptResolver.remove(ScriptEngineFactory, Bundle).bundle - the stopping bundle for which we want to deactivate ScriptEngineFactories if neededpublic void addScriptEngineFactoriesIfNeeded(org.osgi.framework.Bundle bundle)
ScriptEngineFactory instances defined in the context of the specified Bundle.
Any ScriptEngineFactory implementation that is declared in the
META-INF/services/javax.script.ScriptEngineFactory file of the Bundle is instantiated and configured.
Additionally, the OSGi headers are examined to look for any Jahia-Scripting-Extensions-Priorities
header value to configure ordering of scripting languages. If the declared ScriptEngineFactory implements
Configurable, its method will be called when appropriate automatically. Finally,
BundleScriptResolver.register(ScriptEngineFactory, Bundle) is called for each such configured
ScriptEngineFactory in order to be notify it that new scripting languages are available and activate
associated views if needed.bundle - the starting bundle for which we want to activate ScriptEngineFactories if neededpublic ScriptEngineFactory getFactoryForExtension(String extension)
Copyright © 2004–2020 Jahia Solutions Group SA. All rights reserved.