[New] Adding environment, timezone and locale to version
This commit is contained in:
parent
0067bb7074
commit
66121d4f0f
|
@ -15,6 +15,7 @@
|
|||
*/
|
||||
package li.strolch.agent.api;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
@ -25,12 +26,21 @@ import com.google.gson.JsonObject;
|
|||
public class AgentVersion extends StrolchVersion {
|
||||
|
||||
public static final String AGENT_NAME = "agentName";
|
||||
public static final String ENVIRONMENT = "environment";
|
||||
public static final String LOCALE = "locale";
|
||||
public static final String TIMEZONE = "timezone";
|
||||
private final String environment;
|
||||
private final String locale;
|
||||
private final String timezone;
|
||||
|
||||
private String agentName;
|
||||
|
||||
public AgentVersion(String agentName, Properties properties) {
|
||||
public AgentVersion(String agentName, String environment, Locale locale, String timezone, Properties properties) {
|
||||
super(properties);
|
||||
this.agentName = agentName;
|
||||
this.environment = environment;
|
||||
this.locale = locale.toLanguageTag();
|
||||
this.timezone = timezone;
|
||||
}
|
||||
|
||||
public String getAgentName() {
|
||||
|
@ -46,13 +56,17 @@ public class AgentVersion extends StrolchVersion {
|
|||
JsonObject jsonObject = super.toJson();
|
||||
|
||||
jsonObject.addProperty(AGENT_NAME, this.agentName);
|
||||
jsonObject.addProperty(ENVIRONMENT, this.environment);
|
||||
jsonObject.addProperty(LOCALE, this.locale);
|
||||
jsonObject.addProperty(TIMEZONE, this.timezone);
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AgentVersion{agentName='" + this.agentName + "' , groupId='" + getGroupId() + "' , artifactId='"
|
||||
return "AgentVersion{agentName='" + this.agentName + "' , environment='" + this.environment + "' , locale='"
|
||||
+ this.locale + "' , timezone='" + this.timezone + "' , groupId='" + getGroupId() + "' , artifactId='"
|
||||
+ getArtifactId() + "' , artifactVersion='" + getArtifactVersion() + "' , scmRevision='"
|
||||
+ getScmRevision() + "' , scmBranch='" + getScmBranch() + "' , buildTimestamp='" + getBuildTimestamp()
|
||||
+ "' }";
|
||||
|
|
|
@ -295,8 +295,10 @@ public class StrolchAgent {
|
|||
|
||||
try (InputStream stream = getClass().getResourceAsStream(AGENT_VERSION_PROPERTIES)) {
|
||||
properties.load(stream);
|
||||
AgentVersion agentVersion = new AgentVersion(
|
||||
getStrolchConfiguration().getRuntimeConfiguration().getApplicationName(), properties);
|
||||
RuntimeConfiguration runtimeConfiguration = getStrolchConfiguration().getRuntimeConfiguration();
|
||||
AgentVersion agentVersion = new AgentVersion(runtimeConfiguration.getApplicationName(),
|
||||
runtimeConfiguration.getEnvironment(), runtimeConfiguration.getLocale(),
|
||||
runtimeConfiguration.getTimezone(), properties);
|
||||
queryResult.setAgentVersion(agentVersion);
|
||||
} catch (IOException e) {
|
||||
String msg = MessageFormat
|
||||
|
|
|
@ -93,6 +93,10 @@ public class RuntimeConfiguration extends AbstractionConfiguration {
|
|||
return this.locale;
|
||||
}
|
||||
|
||||
public String getTimezone() {
|
||||
return getString(RuntimeConfiguration.PROP_TIMEZONE, System.getProperty("user.timezone"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file in the config directory of the root of the application
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue