Author: jawi
Date: Wed Apr 2 20:06:38 2014
New Revision: 1584150
URL: http://svn.apache.org/r1584150
Log:
Allow system properties to be used to initialize the agent, but
allow custom configuration to override these settings.
Modified:
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
Modified:
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java?rev=1584150&r1=1584149&r2=1584150&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
(original)
+++
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
Wed Apr 2 20:06:38 2014
@@ -18,7 +18,7 @@
*/
package org.apache.ace.agent.impl;
-import static org.apache.ace.agent.AgentConstants.EVENT_AGENT_CONFIG_CHANGED;
+import static org.apache.ace.agent.AgentConstants.*;
import java.io.File;
import java.io.FileInputStream;
@@ -152,6 +152,7 @@ public class ConfigurationHandlerImpl ex
@Override
protected void onInit() throws Exception {
+ loadSystemProps();
loadConfig();
m_timer = new ResettableTimer(getExecutorService(), this, 5,
TimeUnit.SECONDS);
@@ -220,7 +221,7 @@ public class ConfigurationHandlerImpl ex
Properties props = new Properties();
props.load(input);
- m_configProps = new ConcurrentHashMap<Object, Object>(props);
+ m_configProps.putAll(props);
}
finally {
if (input != null) {
@@ -229,6 +230,19 @@ public class ConfigurationHandlerImpl ex
}
}
+ private void loadSystemProps() {
+ Properties sysProps = System.getProperties();
+
+ for (Map.Entry<Object, Object> entry : sysProps.entrySet()) {
+ String key = (String) entry.getKey();
+
+ if (key.startsWith(CONFIG_KEY_NAMESPACE)) {
+ logDebug("Using system-wide property: %s => %s",
entry.getKey(), entry.getValue());
+ m_configProps.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
private void scheduleStore() {
if (!m_timer.schedule()) {
logWarning("Cannot schedule task to store configuration. Executor
is shut down!");