v2/mongodb-to-googlecloud/src/main/java/com/google/cloud/teleport/v2/mongodb/templates/MongoDbUtils.java [250:268]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private static Invocable newInvocable(Collection<String> scripts) throws ScriptException {
    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("JavaScript");

    if (engine == null) {
      List<String> availableEngines = new ArrayList<>();
      for (ScriptEngineFactory factory : manager.getEngineFactories()) {
        availableEngines.add(factory.getEngineName() + " " + factory.getEngineVersion());
      }
      throw new RuntimeException(
          String.format("JavaScript engine not available. Found engines: %s.", availableEngines));
    }

    for (String script : scripts) {
      engine.eval(script);
    }

    return (Invocable) engine;
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



v2/mongodb-to-googlecloud/src/main/java/com/google/cloud/teleport/v2/transforms/JavascriptDocumentTransformer.java [116:134]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private static Invocable newInvocable(Collection<String> scripts) throws ScriptException {
      ScriptEngineManager manager = new ScriptEngineManager();
      ScriptEngine engine = manager.getEngineByName("JavaScript");

      if (engine == null) {
        List<String> availableEngines = new ArrayList<>();
        for (ScriptEngineFactory factory : manager.getEngineFactories()) {
          availableEngines.add(factory.getEngineName() + " " + factory.getEngineVersion());
        }
        throw new RuntimeException(
            String.format("JavaScript engine not available. Found engines: %s.", availableEngines));
      }

      for (String script : scripts) {
        engine.eval(script);
      }

      return (Invocable) engine;
    }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



