Author: jawi
Date: Thu Apr 10 17:22:14 2014
New Revision: 1586379
URL: http://svn.apache.org/r1586379
Log:
Fixed failing unit test:
- copying and regarding the agent system properties as local configuration
properties is not a good idea, as it would cause all kinds of weird
semantics like: if we start the agent with a property set to 'a', this
property will be stored and considered local. Now if we restart the agent
with the same property set to 'b', it still will use the value 'a' as
this is what the local configuration said;
- the actual problem for wanting the system properties to be available was
that the event listeners could get a map with all agent-related config-
properties. This is something we could provide when sending the config-
updated event without having to incorporate the system properties in our
local configuration.
Modified:
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/ConfigurationHandlerImpl.java
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/LoggingHandlerImpl.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=1586379&r1=1586378&r2=1586379&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
Thu Apr 10 17:22:14 2014
@@ -152,7 +152,6 @@ public class ConfigurationHandlerImpl ex
@Override
protected void onInit() throws Exception {
- loadSystemProps();
loadConfig();
m_timer = new ResettableTimer(getExecutorService(), this, 5,
TimeUnit.SECONDS);
@@ -195,13 +194,26 @@ public class ConfigurationHandlerImpl ex
}
/**
- * @return a new map instance with a snapshot of the current
configuration, never <code>null</code>.
+ * @return a new map instance with a snapshot of the current
configuration, including the current (agent-specific)
+ * system properties, never <code>null</code>.
*/
private Map<String, String> getConfigurationSnapshot() {
Map<String, String> props = new HashMap<String, String>();
+
+ // First copy all agent-related system properties, as they can be
overridden by local configuration options...
+ Properties sysProps = System.getProperties();
+ for (Map.Entry<Object, Object> entry : sysProps.entrySet()) {
+ String key = (String) entry.getKey();
+
+ if (key.startsWith(CONFIG_KEY_NAMESPACE)) {
+ props.put(key, (String) entry.getValue());
+ }
+ }
+
for (Map.Entry<Object, Object> entry : m_configProps.entrySet()) {
props.put((String) entry.getKey(), (String) entry.getValue());
}
+
return props;
}
@@ -230,19 +242,6 @@ 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!");
Modified:
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/LoggingHandlerImpl.java
URL:
http://svn.apache.org/viewvc/ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/LoggingHandlerImpl.java?rev=1586379&r1=1586378&r2=1586379&view=diff
==============================================================================
---
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/LoggingHandlerImpl.java
(original)
+++
ace/trunk/org.apache.ace.agent/src/org/apache/ace/agent/impl/LoggingHandlerImpl.java
Thu Apr 10 17:22:14 2014
@@ -42,6 +42,8 @@ public class LoggingHandlerImpl extends
private volatile Levels m_logLevel;
public LoggingHandlerImpl(BundleContext context) {
+ // Obtain the system/framework setting as early as possible to ensure
that we start logging
+ // at the right level from the start (avoiding missing log
statements)...
this(context, fromName(context.getProperty(CONFIG_LOGGING_LEVEL),
DEFAULT_LEVEL));
}