コード例 #1
0
  /**
   * Figure out what kind of static adapter type was specified. By default it's a 10genDEFAULT app
   */
  protected void _setStaticAdapterType() {

    /*
     *  app configuration steps could have set this already.  If so, don't bother doing anything
     */
    if (_staticAdapterType != AdapterType.UNSET) {
      log("Static adapter type has already been directly set to " + _staticAdapterType);
      return;
    }

    /*
     * check to see if overridden in 10gen.properties
     */
    String override = Config.get().getProperty(INIT_ADAPTER_TYPE);

    if (override != null) {
      AdapterType t = getAdapterTypeFromString(override);

      if (t == null) {
        log(
            "Static adapter type specified as override ["
                + override
                + "] unknown - will use _init file specified or default");
      } else {
        log("Static adapter type overridden by 10gen.properties or env. Value : " + override);
        _staticAdapterType = t;
        return;
      }
    }

    /*
     *  if not, use the one from _init file if specified
     */

    _staticAdapterType = AdapterType.DIRECT_10GEN;
    Object o = getFromInitScope(INIT_ADAPTER_TYPE);

    if (o == null) {
      log("Static adapter type not specified in _init file - using default value of DIRECT_10GEN");
      return;
    }

    if (!(o instanceof JSString)) {
      log("Static adapter type from _init file not a string - using default value of DIRECT_10GEN");
      return;
    }

    _staticAdapterType = getAdapterTypeFromString(o.toString());

    if (_staticAdapterType == null) {
      log(
          "Static adapter type from _init file ["
              + o.toString()
              + "] unknown - using default value of DIRECT_10GEN");
      _staticAdapterType = AdapterType.DIRECT_10GEN;
      return;
    }

    log("Static adapter type specified in _init file = " + _staticAdapterType);

    return;
  }