public interface Environment
| Modifier and Type | Field and Description |
|---|---|
static String |
ACCESS_LOG_FILE_ROTATE_PATTERN
The default suffix for access log files rolling: ".yyyy-MM-dd".
|
static String |
ACCESS_LOG_FILE_SUFFIX
The default access log files extension: "-access.log".
|
static String |
APPLICATION_NAME
Key of the name of the application: "application.name".
|
static String |
AUDIT_LOG_PATTERN
The default value: "%d{ISO8601} %level %msg%n"
|
static String |
ENVIRONMENT_FILE
A Java
Properties file that can be used to define
an Environment instance with system property
"environment.file". |
static String |
ENVIRONMENT_NAME
The name that is given to the environment instance; e.g.
|
static String |
ID
A unique ID that is initialized for an
Environment
the first time the environment is initialized. |
static String |
LOG_FILE_ROTATE_PATTERN_SUFFIX
The pattern suffix to use for Apache Log4j for rolling log
files: ".%d{yyyy-MM-dd}".
|
static String |
LOG_FILE_SUFFIX
The default log files extension: ".log".
|
static String |
LOG_PATTERN
The default log pattern: "[%d] [%level] [%thread] %msg (%logger{1}:%L)%n%throwable".
|
static String |
LOG_ROOT_SUFFIX
The application's root directory for logs suffix: ".logs.root".
|
static String |
ROOT_SUFFIX
The application's root directory suffix: ".root".
|
static String |
SERVER_HOST_SUFFIX |
static String |
SERVER_PORT_SUFFIX |
static String |
SERVER_SHUTDOWN_TOKEN_KEY
The environment or system property key to hold the shutdown
password token for Jetty (HTTP server).
|
| Modifier and Type | Method and Description |
|---|---|
static Environment |
createEnvironment()
Creates an environment populating in order and overriding:
System.getenv()
System.getProperties()
If ENVIRONMENT_FILE points to a readable file
and an instance of Properties can be loaded. |
static Environment |
createEnvironment(Map<String,String> environment)
Create an environment.
|
String |
getAccessLogFileName()
The access log file name.
|
Path |
getApplicationLogsRoot()
The path to application logs root.
|
String |
getApplicationName()
The application name.
|
Path |
getApplicationRoot()
The path to application root.
|
String |
getContextPath()
The context path.
|
default StringBuilder |
getDescription()
The description of the environment.
|
default String |
getEnvironmentName()
The name of the environment.
|
default String |
getId()
The ID of the environment.
|
String |
getLogFileName()
The log file name.
|
String |
getRotatingAccessLogFileName()
The rotating access log file name.
|
String |
getRotatingLogFilePattern()
The rotating log file pattern.
|
String |
getServerHost()
The host name of the server.
|
int |
getServerPort()
The port number of the server.
|
default String |
getServerShutdownToken()
The value of
SERVER_SHUTDOWN_TOKEN_KEY in the
created environment. |
default String |
getValue(String key)
The value of a key.
|
String |
getValue(String key,
Supplier<String> supplier)
The value of a key with a supplier.
|
static final String ID
Environment
the first time the environment is initialized. If multiple
Environment instances are used in the same JVM,
this is not reliable and should not be used.static final String ENVIRONMENT_FILE
Properties file that can be used to define
an Environment instance with system property
"environment.file".static final String ENVIRONMENT_NAME
development, test,
production.static final String APPLICATION_NAME
static final String ROOT_SUFFIX
static final String LOG_ROOT_SUFFIX
static final String LOG_FILE_SUFFIX
static final String ACCESS_LOG_FILE_SUFFIX
static final String LOG_FILE_ROTATE_PATTERN_SUFFIX
static final String ACCESS_LOG_FILE_ROTATE_PATTERN
static final String LOG_PATTERN
static final String AUDIT_LOG_PATTERN
static final String SERVER_HOST_SUFFIX
static final String SERVER_PORT_SUFFIX
static final String SERVER_SHUTDOWN_TOKEN_KEY
default String getId()
default String getEnvironmentName()
developmentRuntimeModeString getApplicationName()
application.name.Path getApplicationRoot()
${application.name}.root. Can be
null.Path getApplicationLogsRoot()
${application.name}.root/logs.null.String getLogFileName()
${application.name}.logString getRotatingLogFilePattern()
String getAccessLogFileName()
getLogFileName()-
access.logString getRotatingAccessLogFileName()
String getContextPath()
/${application.name}.String getServerHost()
int getServerPort()
default String getValue(String key)
key - the environment keynullString getValue(String key, Supplier<String> supplier)
key - the environment keysupplier - a Supplier for the key in case
there is no value availabledefault String getServerShutdownToken()
SERVER_SHUTDOWN_TOKEN_KEY in the
created environment.null if
none is specified.default StringBuilder getDescription()
StringBuilder to describe the
environment instance.static Environment createEnvironment()
System.getenv()
System.getProperties()
ENVIRONMENT_FILE points to a readable file
and an instance of Properties can be loaded. Throw
an IllegalArgumentException if an
IOException occurs.
Environmentstatic Environment createEnvironment(Map<String,String> environment)
environment - the base environment to use. Values will
be over-written first by System.getenv(),
then System.getProperties(), and then
finally if ENVIRONMENT_FILE provides any.Environment instance.Copyright © 2015 SDL Fredhopper. All rights reserved.