Class CachedGremlinScriptEngineManager

  • All Implemented Interfaces:
    GremlinScriptEngineManager

    public class CachedGremlinScriptEngineManager
    extends DefaultGremlinScriptEngineManager
    An implementation of the 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.