Пример #1
0
  /**
   * Validates a given environment contiained in a JSOBjectBase
   *
   * <p>Requires that the env defined a defaultVersion, and contains at least the default version in
   * it's version list
   *
   * @param env app environment to validate
   * @return fulled AE object
   * @throws Exception if anything amiss
   */
  protected AE createEnv(JSObjectBase env) throws Exception {

    AE ae = new AE();

    ae._defaultVersion = env.getAsString(DEFAULT_VERSION);

    JSArray versions = (JSArray) env.get(VERSIONS);
    assert (versions != null);

    for (String key : versions.keySet()) {

      JSObjectBase verobj = (JSObjectBase) versions.get(key);

      Env ver = createEnvVersion(verobj);
      ae._versions.put(ver._version, ver);
    }

    return ae;
  }
Пример #2
0
  /**
   * Creates an evn object from specific env-version information
   *
   * @param verobj object w/ version env info
   * @return Env object containing version specific environment info
   */
  protected Env createEnvVersion(JSObjectBase verobj) {
    Env ver = new Env();

    ver._version = verobj.getAsString(VERSION);
    assert (ver._version != null);

    ver._adapterType = verobj.getAsString(ADAPTER_TYPE);
    assert (ver._adapterType != null);

    ver._initFile = verobj.getAsString(INIT_FILE);

    JSArray initDeps = (JSArray) verobj.get(INIT_DEPENDENCIES);
    if (initDeps != null) {
      for (int i = 0; i < initDeps.size(); i++) {
        ver._initDependencies.add(((JSString) initDeps.get(i)).toString());
      }
    }

    JSArray arr = (JSArray) verobj.get(PACKAGES);

    if (arr != null) {
      int i = 0;
      while (i < arr.size()) {
        JSObjectBase pkg = (JSObjectBase) arr.get(i);
        Package p = new Package();
        ver._packages.add(p);

        p._module = pkg.getAsString(MODULE);
        p._name = pkg.getAsString(NAME);
        p._version = pkg.getAsString(VERSION);
        p._path = pkg.getAsString(PATH);
        i++;
      }
    }

    return ver;
  }
Пример #3
0
  private void _setupScope() {
    if (_inScopeSetup) return;

    final Scope saveTLPref = _scope.getTLPreferred();
    _scope.setTLPreferred(null);

    final Scope saveTL = Scope.getThreadLocal();
    _scope.makeThreadLocal();

    _inScopeSetup = true;

    try {
      Object fo = getConfigObject("framework");

      if (fo != null) {

        Framework f = null;

        if (fo instanceof JSString) {
          f = Framework.byName(fo.toString(), null); // we allow people to just specify name
          _logger.info("Setting framework by name [" + fo.toString() + "]");
        } else if (fo instanceof JSObjectBase) {

          JSObjectBase obj = (JSObjectBase) fo;

          if (obj.containsKey("name")) {

            String s = obj.getAsString("version");

            f = Framework.byName(obj.getAsString("name"), s);
            _logger.info("Setting framework by name [" + obj.getAsString("name") + "]");
          } else if (obj.containsKey("custom")) {

            Object o = obj.get("custom");

            if (o instanceof JSObjectBase) {
              f = Framework.byCustom((JSObjectBase) o);
              _logger.info("Setting framework by custom [" + o + "]");
            } else {
              throw new RuntimeException("Error - custom framework wasn't an object [" + o + "]");
            }
          } else if (obj.containsKey("classname")) {
            f = Framework.byClass(obj.getAsString("classname"));
            _logger.info("Setting framework by class [" + obj.getAsString("classname") + "]");
          }
        }

        if (f == null) {
          throw new RuntimeException("Error : can't find framework [" + fo + "]");
        }

        f.install(this);
      }

      _runInitFiles(INIT_FILES);

      if (_adminContext != null) {
        _adminContext._scope.set("siteScope", _scope);
        _adminContext._setLocalObject(_localObject);
      }

      _lastScopeInitTime = _getScopeTime();
    } catch (RuntimeException re) {
      _scopeInited = false;
      throw re;
    } catch (Exception e) {
      _scopeInited = false;
      throw new RuntimeException(e);
    } finally {
      _inScopeSetup = false;
      _scope.setTLPreferred(saveTLPref);

      if (saveTL != null) saveTL.makeThreadLocal();

      this.approxSize(_rootContextReachable);
    }
  }
Пример #4
0
 public String getDocFormat() {
   return _doc.getAsString(DOC_FORMAT);
 }