public class Environment extends Object
Extension
modules might configure application
services differently depending on the environment too. For example: turn on/off caches,
reload files, etc.
The application.env
property controls the active environment names.Constructor and Description |
---|
Environment(com.typesafe.config.Config conf,
List<String> actives)
Creates a new environment.
|
Environment(com.typesafe.config.Config conf,
String... actives)
Creates a new environment.
|
Modifier and Type | Method and Description |
---|---|
static com.typesafe.config.Config |
defaults()
Creates a default configuration properties with some common values like: application.tmpdir,
application.charset and pid (process ID).
|
List<String> |
getActiveNames()
Active environment names.
|
com.typesafe.config.Config |
getConfig()
Application configuration.
|
boolean |
isActive(String name,
String... names)
Test is the given environment names are active.
|
static Environment |
loadEnvironment(EnvironmentOptions options)
This method search for an application.conf file in three location
(first-listed are higher priority):
${user.dir}/conf: This is a file system location, useful is you want to externalize
configuration (outside of jar file).
${user.dir}: This is a file system location, useful is you want to externalize
configuration (outside of jar file)
classpath:// (root of classpath).
|
static String |
pid()
Find JVM process ID.
|
static com.typesafe.config.Config |
systemEnv()
Creates a
Config object from System.getenv() . |
static com.typesafe.config.Config |
systemProperties()
Creates a
Config object from System.getProperties() . |
String |
toString() |
public Environment(@Nonnull com.typesafe.config.Config conf, @Nonnull String... actives)
conf
- Application configuration.actives
- Active environment names.@Nonnull public com.typesafe.config.Config getConfig()
@Nonnull public List<String> getActiveNames()
public boolean isActive(String name, String... names)
name
- Environment name.names
- Optional environment names.@Nonnull public static com.typesafe.config.Config systemProperties()
Config
object from System.getProperties()
.@Nonnull public static com.typesafe.config.Config systemEnv()
Config
object from System.getenv()
.@Nonnull public static Environment loadEnvironment(@Nonnull EnvironmentOptions options)
options
- Options like basedir, filename, etc.@Nonnull public static com.typesafe.config.Config defaults()
Copyright © 2019. All rights reserved.