public class CachedGremlinScriptEngineManager extends DefaultGremlinScriptEngineManager
GremlinScriptEngineManager that caches the instances of the
GremlinScriptEngine instances that are created by it. Note that the cache is relevant to the instance
of the CachedGremlinScriptEngineManager and is not global to the JVM.
The ScriptEngineManager implements a discovery, instantiation and configuration mechanism for
GremlinScriptEngine classes and also maintains a collection of key/value pairs storing state shared by all
engines created by it. This class uses the ServiceProvider mechanism to enumerate all the
implementations of GremlinScriptEngineFactory. 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 @code ScriptEngine} created by the GremlinScriptEngineManager. The values
in the Bindings are generally exposed in all scripts.
This class is based quite heavily on the workings of the ScriptEngineManager supplied in the
javax.script packages, but adds some additional features that are specific to Gremlin and TinkerPop.
Unfortunately, it's not easily possible to extend ScriptEngineManager directly as there certain behaviors
don't appear to be be straightforward to implement and member variables are all private. It is important to note
that this class is designed to provide support for "Gremlin-enabled" ScriptEngine instances (i.e. those
that extend from GremlinScriptEngine) and is not meant to manage just any ScriptEngine instance
that may be on the path.
As this is a "Gremlin" ScriptEngine, certain common imports are automatically applied when a
GremlinScriptEngine is instantiated via the GremlinScriptEngineFactory.. Initial imports from
gremlin-core come from the CoreImports.| Constructor and Description |
|---|
CachedGremlinScriptEngineManager() |
CachedGremlinScriptEngineManager(ClassLoader loader) |
| Modifier and Type | Method and Description |
|---|---|
GremlinScriptEngine |
getEngineByExtension(String extension)
Gets a
GremlinScriptEngine from cache or creates a new one from the GremlinScriptEngineFactory. |
GremlinScriptEngine |
getEngineByMimeType(String mimeType)
Gets a
GremlinScriptEngine from cache or creates a new one from the GremlinScriptEngineFactory. |
GremlinScriptEngine |
getEngineByName(String shortName)
Gets a
GremlinScriptEngine from cache or creates a new one from the GremlinScriptEngineFactory. |
addModule, get, getBindings, getCustomizers, getEngineFactories, put, registerEngineExtension, registerEngineMimeType, registerEngineName, setBindingspublic CachedGremlinScriptEngineManager()
public CachedGremlinScriptEngineManager(ClassLoader loader)
public GremlinScriptEngine getEngineByName(String shortName)
GremlinScriptEngine from cache or creates a new one from the GremlinScriptEngineFactory.
Looks up and creates a GremlinScriptEngine for a given name. The algorithm first searches for a
GremlinScriptEngineFactory that has been registered as a handler for the specified name using the
DefaultGremlinScriptEngineManager.registerEngineExtension(String, GremlinScriptEngineFactory) method. If one is not found, it searches
the set of GremlinScriptEngineFactory 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
GremlinScriptEngine.getEngineByName in interface GremlinScriptEngineManagergetEngineByName in class DefaultGremlinScriptEngineManagershortName - The short name of the GremlinScriptEngine implementation returned by the
ScriptEngineFactory.getNames() method.GremlinScriptEngine created by the factory located in the search. Returns null
if no such factory was found. The global scope of this manager is applied to the newly created
GremlinScriptEnginepublic GremlinScriptEngine getEngineByExtension(String extension)
GremlinScriptEngine from cache or creates a new one from the GremlinScriptEngineFactory.
Look up and create a GremlinScriptEngine for a given extension. The algorithm
used by DefaultGremlinScriptEngineManager.getEngineByName(String) is used except that the search starts by looking for a
GremlinScriptEngineFactory registered to handle the given extension using
DefaultGremlinScriptEngineManager.registerEngineExtension(String, GremlinScriptEngineFactory).getEngineByExtension in interface GremlinScriptEngineManagergetEngineByExtension in class DefaultGremlinScriptEngineManagernull if not found.public GremlinScriptEngine getEngineByMimeType(String mimeType)
GremlinScriptEngine from cache or creates a new one from the GremlinScriptEngineFactory.
Look up and create a GremlinScriptEngine for a given mime type. The algorithm used by
DefaultGremlinScriptEngineManager.getEngineByName(String) is used except that the search starts by looking for a
GremlinScriptEngineFactory registered to handle the given mime type using
DefaultGremlinScriptEngineManager.registerEngineMimeType(String, GremlinScriptEngineFactory).getEngineByMimeType in interface GremlinScriptEngineManagergetEngineByMimeType in class DefaultGremlinScriptEngineManagermimeType - The given mime typenull if not found.Copyright © 2013–2016 Apache Software Foundation. All rights reserved.