Ejemplo n.º 1
0
  private static void exposeModule(RhinoEngine engine, JavaScriptModule module) {
    for (JavaScriptHostObject hostObject : module.getHostObjects()) {
      engine.defineHostObject(hostObject);
    }

    for (JavaScriptMethod method : module.getMethods()) {
      engine.defineMethod(method);
    }

    for (JavaScriptScript script : module.getScripts()) {
      engine.defineScript(script);
    }
  }
Ejemplo n.º 2
0
  private static void exposeModule(Context cx, ScriptableObject object, JavaScriptModule module)
      throws ScriptException {
    for (JavaScriptHostObject hostObject : module.getHostObjects()) {
      RhinoEngine.defineHostObject(object, hostObject);
    }

    for (JavaScriptMethod method : module.getMethods()) {
      RhinoEngine.defineMethod(object, method);
    }

    for (JavaScriptScript script : module.getScripts()) {
      script.getScript().exec(cx, object);
    }
  }