Author: orudyy
Date: Mon Jan  7 10:28:43 2013
New Revision: 1429739

URL: http://svn.apache.org/viewvc?rev=1429739&view=rev
Log:
QPID-4390: Store configuration entry attributes as top level fields inside of 
configuration entry and remove 'attributes' field

Modified:
    
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
    
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/resources/default.json
    
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java

Modified: 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java?rev=1429739&r1=1429738&r2=1429739&view=diff
==============================================================================
--- 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
 (original)
+++ 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStore.java
 Mon Jan  7 10:28:43 2013
@@ -37,7 +37,6 @@ public class JsonConfigurationEntryStore
 {
     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
         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
         {
             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
             }
             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);
             }
         }
 

Modified: 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/resources/default.json
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/resources/default.json?rev=1429739&r1=1429738&r2=1429739&view=diff
==============================================================================
--- 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/resources/default.json
 (original)
+++ 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/resources/default.json
 Mon Jan  7 10:28:43 2013
@@ -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

Modified: 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java?rev=1429739&r1=1429738&r2=1429739&view=diff
==============================================================================
--- 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
 (original)
+++ 
qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/test/java/org/apache/qpid/server/configuration/store/JsonConfigurationEntryStoreTest.java
 Mon Jan  7 10:28:43 2013
@@ -34,7 +34,7 @@ public class JsonConfigurationEntryStore
         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);



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to