summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Rudyy <orudyy@apache.org>2013-01-07 10:28:43 +0000
committerAlex Rudyy <orudyy@apache.org>2013-01-07 10:28:43 +0000
commitf812c1b1f952c4aedeb4b773b13367055ef489c7 (patch)
tree9085646f2ec7bfa52053f9cf17eeade2dcaf65a0
parentd915a67a3aee449b48073d7739fa1cfa95fd7748 (diff)
downloadqpid-python-f812c1b1f952c4aedeb4b773b13367055ef489c7.tar.gz
QPID-4390: Store configuration entry attributes as top level fields inside of configuration entry and remove 'attributes' field
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/java-broker-config-qpid-4390@1429739 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java50
-rw-r--r--qpid/java/broker/src/main/resources/default.json130
-rw-r--r--qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java2
3 files changed, 90 insertions, 92 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
index 06b35558ae..19f8652972 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
@@ -37,7 +37,6 @@ public class JsonConfigurationEntryStore implements ConfigurationEntryStore
{
private static final String DEFAULT_BROKER_TYPE = Broker.class.getSimpleName();
private static final String DEFAULT_BROKER_NAME = "Broker";
- static final String ATTRIBUTES = "attributes";
private static final String ID = "id";
private static final String TYPE = "type";
@@ -259,7 +258,7 @@ public class JsonConfigurationEntryStore implements ConfigurationEntryStore
Map<String, Object> attributes = entry.getAttributes();
if (attributes != null)
{
- tree.put(ATTRIBUTES, attributes);
+ tree.putAll( attributes);
}
tree.put(ID, entry.getId());
tree.put(TYPE, entry.getType());
@@ -317,18 +316,7 @@ public class JsonConfigurationEntryStore implements ConfigurationEntryStore
{
String fieldName = fieldNames.next();
JsonNode fieldNode = parent.get(fieldName);
- if (fieldName.equals(ATTRIBUTES))
- {
- if (fieldNode != null)
- {
- if (!fieldNode.isObject())
- {
- throw new IllegalConfigurationException("Object attributes are set incorrectly for " + parent);
- }
- attributes = toMap(fieldNode);
- }
- }
- else if (fieldName.equals(ID))
+ if (fieldName.equals(ID))
{
idAsString = fieldNode.asText();
}
@@ -338,17 +326,45 @@ public class JsonConfigurationEntryStore implements ConfigurationEntryStore
}
else if (fieldNode.isArray())
{
+ // array containing either broker children or attribute values
Iterator<JsonNode> elements = fieldNode.getElements();
+ List<Object> fieldValues = null;
while (elements.hasNext())
{
JsonNode element = elements.next();
- ConfigurationEntry entry = toEntry(element, false, entries);
- childrenIds.add(entry.getId());
+ if (element.isObject())
+ {
+ // assuming it is a child node
+ ConfigurationEntry entry = toEntry(element, false, entries);
+ childrenIds.add(entry.getId());
+ }
+ else
+ {
+ if (fieldValues == null)
+ {
+ fieldValues = new ArrayList<Object>();
+ }
+ fieldValues.add(toObject(element));
+ }
+ }
+ if (fieldValues != null)
+ {
+ attributes.put(fieldName, fieldValues);
}
}
+ else if (fieldNode.isObject())
+ {
+ // ignore, in-line objects are not supported yet
+ }
else
{
- throw new IllegalConfigurationException("Cannot parse configuration for node " + fieldName + "=" + fieldNode);
+ // primitive attribute
+ Object value = toObject(fieldNode);
+ if (attributes == null)
+ {
+ attributes = new HashMap<String, Object>();
+ }
+ attributes.put(fieldName, value);
}
}
diff --git a/qpid/java/broker/src/main/resources/default.json b/qpid/java/broker/src/main/resources/default.json
index 19ded28463..12ea68b5cb 100644
--- a/qpid/java/broker/src/main/resources/default.json
+++ b/qpid/java/broker/src/main/resources/default.json
@@ -20,96 +20,78 @@
*/
{
"type" : "Broker",
- "attributes" : {
- "name": "Broker",
- "defaultAuthenticationProvider" : "defaultAuthenticationProvider",
- "defaultVirtualHost" : "default",
- "aclFile" : null,
- "alertThresholdQueueDepth" : 0,
- "alertThresholdMessageCount" : 0,
- "alertThresholdMessageSize" : 0,
- "alertThresholdMessageAge" : 0,
- "alertRepeatGap" : 30000,
- "heartBeatDelay" : 0,
- "sessionCountLimit" : 256,
- "deadLetterQueueEnabled" : false,
- "maximumDeliveryAttempts" : 0,
- "housekeepingCheckPeriod" : 30000,
- "queueFlowControlSizeBytes" : 0,
- "queueFlowResumeSizeBytes" : 0,
- "statisticsReportingPeriod" : 0,
- "statisticsReportingResetEnabled" : false
- },
+ "name": "Broker",
+ "defaultAuthenticationProvider" : "defaultAuthenticationProvider",
+ "defaultVirtualHost" : "default",
+ "aclFile" : null,
+ "alertThresholdQueueDepth" : 0,
+ "alertThresholdMessageCount" : 0,
+ "alertThresholdMessageSize" : 0,
+ "alertThresholdMessageAge" : 0,
+ "alertRepeatGap" : 30000,
+ "heartBeatDelay" : 0,
+ "sessionCountLimit" : 256,
+ "deadLetterQueueEnabled" : false,
+ "maximumDeliveryAttempts" : 0,
+ "housekeepingCheckPeriod" : 30000,
+ "queueFlowControlSizeBytes" : 0,
+ "queueFlowResumeSizeBytes" : 0,
+ "statisticsReportingPeriod" : 0,
+ "statisticsReportingResetEnabled" : false,
"authenticationproviders" : [ {
"type" : "AuthenticationProvider",
- "attributes" : {
- "name" : "defaultAuthenticationProvider",
- "authenticationProviderType" : "PlainPasswordFileAuthenticationProvider",
- "path" : "${QPID_HOME}/etc/passwd"
- }
+ "name" : "defaultAuthenticationProvider",
+ "authenticationProviderType" : "PlainPasswordFileAuthenticationProvider",
+ "path" : "${QPID_HOME}/etc/passwd"
} ],
"ports" : [ {
"type" : "Port",
- "attributes" : {
- "name" : "defaultHttpPort",
- "port" : 8080,
- "transports" : [ "TCP" ],
- "protocols" : [ "HTTP" ]
- }
+ "name" : "defaultHttpPort",
+ "port" : 8080,
+ "transports" : [ "TCP" ],
+ "protocols" : [ "HTTP" ]
}, {
"type" : "Port",
- "attributes" : {
- "name" : "defaultAmqpPort",
- "port" : 5672,
- "tcpNoDelay" : true,
- "transports" : [ "TCP" ],
- "protocols" : [ "AMQP_0_8", "AMQP_0_9", "AMQP_0_9_1", "AMQP_0_10", "AMQP_1_0" ],
- "wantClientAuth" : false,
- "needClientAuth" : false,
- "receiveBufferSize" : 262144,
- "sendBufferSize" : 262144
- }
+ "name" : "defaultAmqpPort",
+ "port" : 5672,
+ "tcpNoDelay" : true,
+ "transports" : [ "TCP" ],
+ "protocols" : [ "AMQP_0_8", "AMQP_0_9", "AMQP_0_9_1", "AMQP_0_10", "AMQP_1_0" ],
+ "wantClientAuth" : false,
+ "needClientAuth" : false,
+ "receiveBufferSize" : 262144,
+ "sendBufferSize" : 262144
}, {
"type" : "Port",
- "attributes" : {
- "name" : "defaultJmxRmiPort",
- "port" : 9099,
- "transports" : [ "TCP" ],
- "protocols" : [ "JMX_RMI" ]
- }
+ "name" : "defaultJmxRmiPort",
+ "port" : 9099,
+ "transports" : [ "TCP" ],
+ "protocols" : [ "JMX_RMI" ]
}, {
"type" : "Port",
- "attributes" : {
- "name" : "defaultRmiPort",
- "port" : 8999,
- "transports" : [ "TCP" ],
- "protocols" : [ "RMI" ]
- }
+ "name" : "defaultRmiPort",
+ "port" : 8999,
+ "transports" : [ "TCP" ],
+ "protocols" : [ "RMI" ]
} ],
"virtualhosts" : [ {
"type" : "VirtualHost",
- "attributes" : {
- "name" : "default",
- "configuration" : "${QPID_HOME}/etc/virtualhosts.xml"
- }
+ "name" : "default",
+ "configuration" : "${QPID_HOME}/etc/virtualhosts.xml"
} ],
"plugins" : [ {
- "type" : "Plugin",
- "attributes" : {
- "pluginType" : "MANAGEMENT-HTTP",
- "name" : "httpManagement",
- "httpSaslAuthenticationEnabled" : true,
- "httpsSaslAuthenticationEnabled" : false,
- "httpBasicAuthenticationEnabled" : false,
- "httpsBasicAuthenticationEnabled" : false
- }
+ "type" : "Plugin",
+ "pluginType" : "MANAGEMENT-HTTP",
+ "name" : "httpManagement",
+ "httpSaslAuthenticationEnabled" : true,
+ "httpsSaslAuthenticationEnabled" : false,
+ "httpBasicAuthenticationEnabled" : false,
+ "httpsBasicAuthenticationEnabled" : false
}, {
- "type" : "Plugin",
- "attributes" : {
- "pluginType" : "MANAGEMENT-JMX",
- "name" : "jmxManagement",
- "usePlatformMBeanServer" : true,
- "managementRightsInferAllAccess" : true
- }
+ "type" : "Plugin",
+ "pluginType" : "MANAGEMENT-JMX",
+ "name" : "jmxManagement",
+ "usePlatformMBeanServer" : true,
+ "managementRightsInferAllAccess" : true
} ]
} \ No newline at end of file
diff --git a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
index 78b6e5fde9..eb3b390d80 100644
--- a/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
+++ b/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
@@ -34,7 +34,7 @@ public class JsonConfigurationEntryStoreTest extends ConfigurationEntryStoreTest
Map<String, Object> brokerObjectMap = new HashMap<String, Object>();
brokerObjectMap.put(Broker.ID, brokerId);
brokerObjectMap.put("type", Broker.class.getSimpleName());
- brokerObjectMap.put(JsonConfigurationEntryStore.ATTRIBUTES, brokerAttributes);
+ brokerObjectMap.putAll(brokerAttributes);
StringWriter sw = new StringWriter();
_objectMapper.writeValue(sw, brokerObjectMap);