diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/api/AgentVersion.java b/li.strolch.agent/src/main/java/li/strolch/agent/api/AgentVersion.java index 48fc2c3e0..b88565c0d 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/api/AgentVersion.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/api/AgentVersion.java @@ -1,12 +1,12 @@ /* * Copyright 2013 Robert von Burg - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -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() + "' }"; diff --git a/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchAgent.java b/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchAgent.java index 4ba4415ef..383fe5c97 100644 --- a/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchAgent.java +++ b/li.strolch.agent/src/main/java/li/strolch/agent/api/StrolchAgent.java @@ -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 diff --git a/li.strolch.agent/src/main/java/li/strolch/runtime/configuration/RuntimeConfiguration.java b/li.strolch.agent/src/main/java/li/strolch/runtime/configuration/RuntimeConfiguration.java index db13714ea..5dbe92882 100644 --- a/li.strolch.agent/src/main/java/li/strolch/runtime/configuration/RuntimeConfiguration.java +++ b/li.strolch.agent/src/main/java/li/strolch/runtime/configuration/RuntimeConfiguration.java @@ -1,12 +1,12 @@ /* * Copyright 2013 Robert von Burg - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -93,16 +93,20 @@ 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 - * + * * @param context - * short name to define who requires this file for error handling + * short name to define who requires this file for error handling * @param fileName - * the relative name of the config file to return + * the relative name of the config file to return * @param checkExists - * if true, then an exception is thrown, using the context as info, if the config file does not exist - * + * if true, then an exception is thrown, using the context as info, if the config file does not exist + * * @return the file in the config directory of the root of the application */ public File getConfigFile(String context, String fileName, boolean checkExists) { @@ -117,14 +121,14 @@ public class RuntimeConfiguration extends AbstractionConfiguration { /** * Returns the file in the data directory of the root of the application - * + * * @param context - * short name to define who requires this file for error handling + * short name to define who requires this file for error handling * @param fileName - * the relative name of the data file to return + * the relative name of the data file to return * @param checkExists - * if true, then an exception is thrown, using the context as info, if the data file does not exist - * + * if true, then an exception is thrown, using the context as info, if the data file does not exist + * * @return the file in the data directory of the root of the application */ public File getDataFile(String context, String fileName, boolean checkExists) { @@ -139,14 +143,14 @@ public class RuntimeConfiguration extends AbstractionConfiguration { /** * Returns the directory in the data directory of the root of the application - * + * * @param context - * short name to define who requires this directory for error handling + * short name to define who requires this directory for error handling * @param dirName - * the relative name of the data directory to return + * the relative name of the data directory to return * @param checkExists - * if true, then an exception is thrown, using the context as info, if the data directory does not exist - * + * if true, then an exception is thrown, using the context as info, if the data directory does not exist + * * @return the directory in the data directory of the root of the application */ public File getDataDir(String context, String dirName, boolean checkExists) {