@Override public Object put(String key, Object value) { return super.put(key, value); }
@Override public Object put(String key, Object value) { return getConfig().put(key, value); } }
@Override public Object put(String key, Object value) { return getConfig().put(key, value); } }
protected void loadDefaultDevelopmentConfiguration(Config config) { Config server = config.config("server"); server.put("debugOutput", true); Config resources = server.config("resources"); Config resourcesCache = resources.config("cache"); resourcesCache.put("enabled", false); Config renderer = server.config("renderer"); renderer.put("viewCacheTtl", 1L); renderer.put("templateCacheTtl", 1L); }
@Override public void setContext(String context) { while (context != null && context.startsWith("/")) context = context.substring(1); if (context != null && context.isEmpty()) context = null; super.setContext(context); config.config("server").put("context", context); }
@Override public void setIoThreadsCount(int ioThreadsCount) { super.setIoThreadsCount(ioThreadsCount); config.config("server").put("ioWorkersCount", ioThreadsCount); }
@Override public void setWorkersCount(int count) { super.setWorkersCount(count); config.config("server").put("workersCount", count); }
protected void putInto(Config config, String key, Object value) { String[] keys = key.split("\\."); Config subConfig = config; int last = keys.length - 1; int i = 0; try { for (; i < last; i++) { subConfig = subConfig.config(keys[i]); } subConfig.put(keys[last], value); } catch (ClassCastException e) { String k = ""; for (int j = 0; j < i; j++) { k += keys[j] + "."; } k += keys[i]; System.out.println("WARNING! cannot overwrite config value " + k + "=" + subConfig.get(keys[i]) + " with new config " + key + "=" + value); } }
@Override public void setPort(int port) { super.setPort(port); config.config("server").put("port", port); }
public WebApplication setDebugOutput(boolean enabled) { super.setDebugOutput(enabled); config.config("server").put("debugOutput", enabled); return this; }
@Override public void setTTL(long milliseconds) { super.setTTL(milliseconds); config.config("server").put("ttl", milliseconds); }
@Override public void setHostname(String hostname) { super.setHostname(hostname); config.config("server").put("hostname", hostname); }
@Override public void setSessionTimeout(int sec) { super.setSessionTimeout(sec); config.config("server").config("session").put("ttl", sec); }
protected Config getConfig() { if (config != null) return config; Config config = createConfig(parent(), name()); main.put(key, this.config = config); return config; }
protected Config getConfig() { if (config != null) return config; Config config = createConfig(parent(), name()); main.put(key, this.config = config); return config; }
@Override protected void configure(Config config) { config.config("server").config("multipart").put("enabled", true); }
@Override public Object get(Object key) { Object value = superGet(key); if (value != null) return value; if (parent() != null && (value = root().superGet(key)) != null) { if (value instanceof Config) { return createProxyConfig(this, (String) key, this, (Config) value); } else { return value; } } put((String) key, value = createConfig(this, (String) key)); return value; }
@Override public Object get(Object key) { Object value = superGet(key); if (value != null) return value; if (parent() != null && (value = root().superGet(key)) != null) { if (value instanceof Config) { return createProxyConfig(this, (String) key, this, (Config) value); } else { return value; } } put((String) key, value = createConfig(this, (String) key)); return value; }
@Test public void test_profiles_4() throws IOException, NoSuchMethodException, NoSuchFieldException, ClassNotFoundException, InterruptedException { server.config.config("environments").config("dev").config("profiles").config("profile_A").put("key", "dev_A"); server.config.config("environments").config("dev").config("profiles").config("profile_B").put("key", "dev_B"); server.config.config("environments").config("prod").config("profiles").config("profile_A").put("key", "prod_A"); server.config.config("environments").config("prod").config("profiles").config("profile_B").put("key", "prod_B"); server.setEnvironment(Environment.DEVELOPMENT); server.addProfile("profile_B"); server.start(); Assert.assertEquals("dev_B", server.getConfig().get("key")); }