/** * Attempts to compile a script and cache it in the request {@link javax.script.ScriptEngine}. * This is only possible if the {@link javax.script.ScriptEngine} implementation implements {@link * javax.script.Compilable}. In the event that the requested {@link javax.script.ScriptEngine} * does not implement it, the method will return empty. */ public Optional<CompiledScript> compile(final String script, final Optional<String> language) throws ScriptException { final String lang = language.orElse("gremlin-groovy"); try { return Optional.of(scriptEngines.compile(script, lang)); } catch (UnsupportedOperationException uoe) { return Optional.empty(); } }