Ejemplo n.º 1
0
  private void _loadConfig() {
    try {

      _configScope.set("__instance__", this);

      _loadConfigFromCloudObject(getSiteObject());
      _loadConfigFromCloudObject(getEnvironmentObject());

      File f;
      if (!_admin) {
        f = getFileSafe("_config.js");
        if (f == null || !f.exists()) f = getFileSafe("_config");
      } else
        f =
            new File(
                Module.getModule("core-modules/admin").getRootFile(getVersionForLibrary("admin")),
                "_config.js");

      _libraryLogger.info("config file [" + f + "] exists:" + f.exists());

      if (f == null || !f.exists()) return;

      Convert c = new Convert(f);
      JSFunction func = c.get();
      func.setUsePassedInScope(true);
      func.call(_configScope);

      _logger.debug("config things " + _configScope.keySet());
    } catch (Exception e) {
      throw new RuntimeException("couldn't load config", e);
    }
  }
Ejemplo n.º 2
0
  private void _runInitFiles(String[] files) throws IOException {

    if (files == null) return;

    for (JSFunction func : _initRefreshHooks) {
      func.call(_initScope, null);
    }

    for (int i = 0; i < files.length; i++) runInitFile(files[i].replaceAll("PREFIX", _codePrefix));
  }
Ejemplo n.º 3
0
  private void _runInitFile(File f) throws IOException {
    if (f == null) return;

    if (!f.exists()) return;

    _initFlies.add(f);
    JxpSource s = getSource(f);
    JSFunction func = s.getFunction();
    func.setUsePassedInScope(true);
    func.call(_initScope);
  }
Ejemplo n.º 4
0
  public void onMessage(
      String channel, String sender, String login, String hostname, String message) {

    JSFunction onMessage = (JSFunction) _things.get("onMessage");
    if (onMessage == null) return;

    JSObjectBase o = new JSObjectBase();
    o.set("channel", channel);
    o.set("sender", sender);
    o.set("login", login);
    o.set("hostname", hostname);
    o.set("message", message);

    onMessage.call(onMessage.getScope(), o);
  }
Ejemplo n.º 5
0
  protected void onDisconnect() {
    JSFunction onDisconnect = (JSFunction) _things.get("onDisconnect");
    if (onDisconnect == null) return;

    onDisconnect.call(onDisconnect.getScope());
  }