Пример #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);
    }
  }
Пример #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));
  }
Пример #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);
  }
Пример #4
0
  /** @unexpose */
  static Object _loop(final Scope s, final JSFunction f, final int start, final int end) {
    Object blah = s.getParent().getThis();
    s.setThis(blah);

    Boolean old = f.setUsePassedInScopeTL(true);

    for (int i = start; i < end; i++) f.call(s, i);

    f.setUsePassedInScopeTL(old);

    s.clearThisNormal(null);

    return null;
  }
Пример #5
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);
  }
Пример #6
0
  protected void onDisconnect() {
    JSFunction onDisconnect = (JSFunction) _things.get("onDisconnect");
    if (onDisconnect == null) return;

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