Package com.typesafe.config

Examples of com.typesafe.config.ConfigObject


   */
  @Override
  protected void configure(HttpSecurity http) throws Exception {
    String[] defRoles = {"USER", "MOD", "ADMIN"};
    Map<String, String> confMap = Config.getConfigMap();
    ConfigObject c = Config.getConfig().getObject("security.protected");
    ConfigValue apiSec = Config.getConfig().getValue("security.api");
    boolean enableRestFilter = apiSec != null && "enabled".equals(apiSec.unwrapped());

    for (String key : c.keySet()) {
      ConfigValue cv = c.get(key);
      ArrayList<String> patterns = new ArrayList<String>();
      ArrayList<String> roles = new ArrayList<String>();

      // if API security is disabled don't add any API related patterns
      // to the list of protected resources
View Full Code Here


    }

    // this is the heuristic includer
    @Override
    public ConfigObject include(final ConfigIncludeContext context, String name) {
        ConfigObject obj = includeWithoutFallback(context, name);

        // now use the fallback includer if any and merge
        // its result.
        if (fallback != null) {
            return obj.withFallback(fallback.include(context, name));
        } else {
            return obj;
        }
    }
View Full Code Here

        }
    }

    @Override
    public ConfigObject includeURL(ConfigIncludeContext context, URL url) {
        ConfigObject obj = includeURLWithoutFallback(context, url);

        // now use the fallback includer if any and merge
        // its result.
        if (fallback != null && fallback instanceof ConfigIncluderURL) {
            return obj.withFallback(((ConfigIncluderURL) fallback).includeURL(context, url));
        } else {
            return obj;
        }
    }
View Full Code Here

        return ConfigFactory.parseURL(url, context.parseOptions()).root();
    }

    @Override
    public ConfigObject includeFile(ConfigIncludeContext context, File file) {
        ConfigObject obj = includeFileWithoutFallback(context, file);

        // now use the fallback includer if any and merge
        // its result.
        if (fallback != null && fallback instanceof ConfigIncluderFile) {
            return obj.withFallback(((ConfigIncluderFile) fallback).includeFile(context, file));
        } else {
            return obj;
        }
    }
View Full Code Here

        return ConfigFactory.parseFileAnySyntax(file, context.parseOptions()).root();
    }

    @Override
    public ConfigObject includeResources(ConfigIncludeContext context, String resource) {
        ConfigObject obj = includeResourceWithoutFallback(context, resource);

        // now use the fallback includer if any and merge
        // its result.
        if (fallback != null && fallback instanceof ConfigIncluderClasspath) {
            return obj.withFallback(((ConfigIncluderClasspath) fallback).includeResources(context,
                    resource));
        } else {
            return obj;
        }
    }
View Full Code Here

    // this function is a little tricky because there are three places we're
    // trying to use it; for 'include "basename"' in a .conf file, for
    // loading app.{conf,json,properties} from classpath, and for
    // loading app.{conf,json,properties} from the filesystem.
    static ConfigObject fromBasename(NameSource source, String name, ConfigParseOptions options) {
        ConfigObject obj;
        if (name.endsWith(".conf") || name.endsWith(".json") || name.endsWith(".properties")) {
            ConfigParseable p = source.nameToParseable(name, options);

            obj = p.parse(p.options().setAllowMissing(options.getAllowMissing()));
        } else {
            ConfigParseable confHandle = source.nameToParseable(name + ".conf", options);
            ConfigParseable jsonHandle = source.nameToParseable(name + ".json", options);
            ConfigParseable propsHandle = source.nameToParseable(name + ".properties", options);
            boolean gotSomething = false;
            List<ConfigException.IO> fails = new ArrayList<ConfigException.IO>();

            ConfigSyntax syntax = options.getSyntax();

            obj = SimpleConfigObject.empty(SimpleConfigOrigin.newSimple(name));
            if (syntax == null || syntax == ConfigSyntax.CONF) {
                try {
                    obj = confHandle.parse(confHandle.options().setAllowMissing(false)
                            .setSyntax(ConfigSyntax.CONF));
                    gotSomething = true;
                } catch (ConfigException.IO e) {
                    fails.add(e);
                }
            }

            if (syntax == null || syntax == ConfigSyntax.JSON) {
                try {
                    ConfigObject parsed = jsonHandle.parse(jsonHandle.options()
                            .setAllowMissing(false).setSyntax(ConfigSyntax.JSON));
                    obj = obj.withFallback(parsed);
                    gotSomething = true;
                } catch (ConfigException.IO e) {
                    fails.add(e);
                }
            }

            if (syntax == null || syntax == ConfigSyntax.PROPERTIES) {
                try {
                    ConfigObject parsed = propsHandle.parse(propsHandle.options()
                            .setAllowMissing(false).setSyntax(ConfigSyntax.PROPERTIES));
                    obj = obj.withFallback(parsed);
                    gotSomething = true;
                } catch (ConfigException.IO e) {
                    fails.add(e);
View Full Code Here

  public void testFromMap() { // test access based on key
    final Map<String, String> map = Maps.newHashMap();
    map.put(TIKA_CONFIG_LOCATION, "src/test/resources/tika-config.xml");
    String key = "collection1.testcoll.solr.home";
    map.put(key, "target/test-classes/solr/collection1");
    ConfigObject config = ConfigValueFactory.fromMap(map);
    String filePath = config.get(TIKA_CONFIG_LOCATION).unwrapped().toString();
    assertEquals(map.get(TIKA_CONFIG_LOCATION), filePath);
    assertEquals(map.get(key), config.get(key).unwrapped().toString());
  }
View Full Code Here

  public void testFromMap() { // test access based on key
    final Map<String, String> map = new HashMap();
    map.put(TIKA_CONFIG_LOCATION, "src/test/resources/tika-config.xml");
    String key = "collection1.testcoll.solr.home";
    map.put(key, "target/test-classes/solr/collection1");
    ConfigObject config = ConfigValueFactory.fromMap(map);
    String filePath = config.get(TIKA_CONFIG_LOCATION).unwrapped().toString();
    assertEquals(map.get(TIKA_CONFIG_LOCATION), filePath);
    assertEquals(map.get(key), config.get(key).unwrapped().toString());
  }
View Full Code Here

   */
  @Override
  protected void configure(HttpSecurity http) throws Exception {
    String[] defroles = {"USER", "MOD", "ADMIN"};
    Map<String, String> confMap = Config.getConfigMap();
    ConfigObject c = Config.getConfig().getObject("security.protected");

    for (ConfigValue cv : c.values()) {
      ArrayList<String> patterns = new ArrayList<String>();
      ArrayList<String> roles = new ArrayList<String>();

      for (ConfigValue configValue : (ConfigList) cv) {
        if (configValue instanceof List) {
View Full Code Here

                /* if config value is a list see if the base class has an _array alias */
                if (configValue.valueType() == ConfigValueType.LIST) {
                    Class<T> arrayType = (Class<T>) pluginMap.arraySugar();
                    if (arrayType != null) {
                        Config aliasDefaults = pluginMap.aliasDefaults("_array").toConfig();
                        ConfigObject fieldsValues = configValue.atPath(aliasDefaults.getString("_primary")).root()
                                                               .withFallback(aliasDefaults);
                        CodableClassInfo arrayInfo = getOrCreateClassInfo(arrayType);
                        return createAndPopulate(arrayInfo, arrayType, fieldsValues);
                    } // else just let the error get thrown below
                }
View Full Code Here

TOP

Related Classes of com.typesafe.config.ConfigObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.