/** * Creates a new configuration from a Typesafe Config object. */ public Configuration(Config conf) { this(new play.api.Configuration(conf)); }
/** * Returns the underlying Typesafe config object. * * @return The config */ public Config underlying() { return conf.underlying(); }
private static Config config() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Properties properties = System.getProperties(); scala.collection.immutable.Map<String, Object> directSettings = scala.collection.immutable.Map$.MODULE$.empty(); // We are allowing missing application conf because it can handle both cases. boolean allowMissingApplicationConf = true; // Using play.api.Configuration.load because it is more consistent with how the // actual configuration is loaded for the application. return play.api.Configuration.load(classLoader, properties, directSettings, allowMissingApplicationConf).underlying(); }
/** * Load a new configuration from an environment. */ public static Configuration load(Environment env) { return new Configuration(play.api.Configuration.load(env.underlying())); }
/** * Retrieves a sub-configuration, which is a configuration instance containing all keys that start with the given prefix. * * @param key The root prefix for this sub configuration. * @return Maybe a new configuration */ public Configuration getConfig(String key) { scala.Option<play.api.Configuration> nConf = conf.getConfig(key); if(nConf.isDefined()) { return new Configuration(nConf.get()); } return null; }
/** * Retrieves a configuration value as a <code>Boolean</code>. * * @param key configuration key (relative to configuration root key) * @return a configuration value or <code>null</code> */ public Boolean getBoolean(String key) { return (Boolean)Scala.orNull(conf.getBoolean(key)); }
/** * The context for loading an application. * * @param environment the application environment * @param initialSettings the initial settings. These settings are merged with the settings from the loaded * configuration files, and together form the initialConfiguration provided by the context. It * is intended for use in dev mode, to allow the build system to pass additional configuration * into the application. */ public Context(Environment environment, Map<String,Object> initialSettings) { this.underlying = new play.api.ApplicationLoader.Context( environment.underlying(), scala.Option.empty(), new play.core.DefaultWebCommands(), play.api.Configuration.load(environment.underlying(), play.libs.Scala.asScala(initialSettings))); }
@Override public Option<Configuration> microserviceMetricsConfig(Application app) { return app.configuration().getConfig(confBase); }
/** * Retrieves a configuration value as a <code>Boolean</code>. * * @param key configuration key (relative to configuration root key) * @param defaultBoolean default value if configuration key doesn't exist * @return a configuration value or the defaultBoolean */ public Boolean getBoolean(String key, Boolean defaultBoolean) { return (Boolean)Scala.orElse(conf.getBoolean(key), defaultBoolean); }
default Configuration configuration() { return new Configuration(config()); } }
/** * Returns the config as a set of full paths to config values. This is * different to {@link asMap()} in that it returns {@link com.typesafe.config.ConfigValue} * objects, and keys are recursively expanded to be pull path keys. * * @return The config as an entry set */ public Set<Map.Entry<String, ConfigValue>> entrySet() { return conf.underlying().entrySet(); }
private static Config config() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Properties properties = System.getProperties(); scala.collection.immutable.Map<String, Object> directSettings = scala.collection.immutable.Map$.MODULE$.empty(); // We are allowing missing application conf because it can handle both cases. boolean allowMissingApplicationConf = true; // Using play.api.Configuration.load because it is more consistent with how the // actual configuration is loaded for the application. return play.api.Configuration.load(classLoader, properties, directSettings, allowMissingApplicationConf).underlying(); }
/** * The context for loading an application. * * @param environment the application environment * @param initialSettings the initial settings. These settings are merged with the settings from the loaded * configuration files, and together form the initialConfiguration provided by the context. It * is intended for use in dev mode, to allow the build system to pass additional configuration * into the application. */ public Context(Environment environment, Map<String, Object> initialSettings) { this.underlying = new play.api.ApplicationLoader.Context( environment.asScala(), play.api.Configuration.load(environment.asScala(), play.libs.Scala.asScala(initialSettings)), new DefaultApplicationLifecycle(), scala.Option.empty()); }
default Configuration configuration() { return new Configuration(config()); } }
/** * Create an application that wraps a Scala application. * * @param application the application to wrap * @param injector the new application's injector */ public DefaultApplication(play.api.Application application, Injector injector) { this(application, application.configuration().underlying(), injector); }
private static Config config() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); Properties properties = System.getProperties(); scala.collection.immutable.Map<String, Object> directSettings = scala.collection.immutable.Map$.MODULE$.empty(); // We are allowing missing application conf because it can handle both cases. boolean allowMissingApplicationConf = true; // Using play.api.Configuration.load because it is more consistent with how the // actual configuration is loaded for the application. return play.api.Configuration.load(classLoader, properties, directSettings, allowMissingApplicationConf).underlying(); }
/** * The context for loading an application. * * @param environment the application environment * @param initialSettings the initial settings. These settings are merged with the settings from the loaded * configuration files, and together form the initialConfiguration provided by the context. It * is intended for use in dev mode, to allow the build system to pass additional configuration * into the application. */ public Context(Environment environment, Map<String, Object> initialSettings) { this.underlying = new play.api.ApplicationLoader.Context( environment.asScala(), play.api.Configuration.load(environment.asScala(), play.libs.Scala.asScala(initialSettings)), new DefaultApplicationLifecycle(), scala.Option.empty()); }
default Configuration configuration() { return new Configuration(config()); } }
/** * Get the configuration from the context. This configuration is not necessarily the same * configuration used by the application, as the ApplicationLoader may, through it's own * mechanisms, modify it or completely ignore it. * * @return the initial configuration */ public Config initialConfig() { return underlying.initialConfiguration().underlying(); }
/** * The context for loading an application. * * @param environment the application environment * @param initialSettings the initial settings. These settings are merged with the settings from the loaded * configuration files, and together form the initialConfiguration provided by the context. It * is intended for use in dev mode, to allow the build system to pass additional configuration * into the application. */ public Context(Environment environment, Map<String, Object> initialSettings) { this.underlying = new play.api.ApplicationLoader.Context( environment.asScala(), play.api.Configuration.load(environment.asScala(), play.libs.Scala.asScala(initialSettings)), new DefaultApplicationLifecycle(), scala.Option.empty()); }