// 1. Try to get environment from JVM system property
m_env=System.getProperty("env");
if(!Utils.isBlank(m_env)){
m_env=m_env.trim();
logger.info("Environment is set to [{}] by JVM system property 'env'.",m_env);
return;
}
// 2. Try to get environment from OS environment variable
m_env=System.getenv("ENV");
if(!Utils.isBlank(m_env)){
m_env=m_env.trim();
logger.info("Environment is set to [{}] by OS env variable 'ENV'.",m_env);
return;
}
// 3. Try to get environment from file "server.properties"
m_env=m_serverProperties.getProperty("env");
if(!Utils.isBlank(m_env)){
m_env=m_env.trim();
logger.info("Environment is set to [{}] by property 'env' in server.properties.",m_env);
return;
}
// 4. Set environment to null.
m_env=null;
logger.warn("Environment is set to null. Because it is not available in either (1) JVM system property 'env', (2) OS env variable 'ENV' nor (3) property 'env' from the properties InputStream.");
}
privatevoidinitDataCenter(){
// 1. Try to get environment from JVM system property
m_dc=System.getProperty("idc");
if(!Utils.isBlank(m_dc)){
m_dc=m_dc.trim();
logger.info("Data Center is set to [{}] by JVM system property 'idc'.",m_dc);
return;
}
// 2. Try to get idc from OS environment variable
m_dc=System.getenv("IDC");
if(!Utils.isBlank(m_dc)){
m_dc=m_dc.trim();
logger.info("Data Center is set to [{}] by OS env variable 'IDC'.",m_dc);
return;
}
// 3. Try to get idc from from file "server.properties"
m_dc=m_serverProperties.getProperty("idc");
if(!Utils.isBlank(m_dc)){
m_dc=m_dc.trim();
logger.info("Data Center is set to [{}] by property 'idc' in server.properties.",m_dc);
return;
}
// 4. Set Data Center to null.
m_dc=null;
logger.warn("Data Center is set to null. Because it is not available in either (1) JVM system property 'idc', (2) OS env variable 'IDC' nor (3) property 'idc' from the properties InputStream.");
}
@Override
publicStringtoString(){
return"environment ["+getEnvType()+"] data center ["+getDataCenter()+"] properties: "+m_serverProperties