qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gmur...@apache.org
Subject [9/9] qpid-dispatch git commit: DISPATCH-437 - Added a agent_handler.h interface and moved all the handler functions there. Added handler functions for handling ssl profile to see how it works
Date Thu, 11 Aug 2016 17:43:02 GMT
DISPATCH-437 - Added a agent_handler.h interface and moved all the handler functions there. Added handler functions for handling ssl profile to see how it works


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/60eb8212
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/60eb8212
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/60eb8212

Branch: refs/heads/DISPATCH-437-1
Commit: 60eb82121d15d2f5cd783e53047bdf340de2491f
Parents: 2e6d01a
Author: Ganesh Murthy <gmurthy@redhat.com>
Authored: Thu Aug 11 13:42:02 2016 -0400
Committer: Ganesh Murthy <gmurthy@redhat.com>
Committed: Thu Aug 11 13:42:02 2016 -0400

----------------------------------------------------------------------
 include/qpid/dispatch/connection_manager.h      |  24 +-
 .../management/agent/agent.py                   |  16 +-
 .../management/schema/qd_schema.py              |  49 ++-
 src/CMakeLists.txt                              |   2 +-
 src/agent.c                                     |  78 ++--
 src/agent.h                                     |  20 +-
 src/agent_handler.h                             |  72 ++++
 src/connection_manager.c                        | 247 ++++++++++-
 src/management_agent.c                          | 418 +++++++++++++++++++
 src/router_core/agent_core.c                    | 150 ++++---
 src/router_core/management_agent.c              | 333 ---------------
 src/router_core/router_core_private.h           |   2 +-
 src/schema_c.py                                 |  30 +-
 tools/qdmanage                                  |   5 +-
 14 files changed, 933 insertions(+), 513 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/include/qpid/dispatch/connection_manager.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/connection_manager.h b/include/qpid/dispatch/connection_manager.h
index 28a944c..baad127 100644
--- a/include/qpid/dispatch/connection_manager.h
+++ b/include/qpid/dispatch/connection_manager.h
@@ -25,6 +25,10 @@
 
 #include <qpid/dispatch/dispatch.h>
 #include <qpid/dispatch/server.h>
+#include <qpid/dispatch/amqp.h>
+#include <qpid/dispatch/iterator.h>
+#include <qpid/dispatch/parse.h>
+#include <qpid/dispatch/compose.h>
 
 typedef struct qd_connection_manager_t qd_connection_manager_t;
 typedef struct qd_config_connector_t qd_config_connector_t;
@@ -75,7 +79,25 @@ void qd_config_connector_free(qd_connection_manager_t *cm, qd_config_connector_t
  */
 void qd_connection_manager_start(qd_dispatch_t *qd);
 
-
+qd_amqp_error_t qd_connection_manager_create_ssl_profile(qd_dispatch_t *qd,
+                                                         qd_field_iterator_t *name,
+                                                         qd_parsed_field_t *in_body,
+                                                         qd_composed_field_t *out_body);
+
+qd_amqp_error_t qd_connection_manager_delete_ssl_profile(qd_dispatch_t *qd,
+                                                         qd_field_iterator_t *name,
+                                                         qd_field_iterator_t *identity);
+
+qd_amqp_error_t qd_connection_manager_read_ssl_profile(qd_dispatch_t *qd,
+                                                       qd_field_iterator_t *name,
+                                                       qd_field_iterator_t *identity,
+                                                       qd_composed_field_t *out_body);
+
+qd_amqp_error_t qd_connection_manager_query_ssl_profile(qd_dispatch_t *qd,
+                                                        int offset,
+                                                        int count,
+                                                        qd_parsed_field_t     *in_body,
+                                                        qd_composed_field_t   *out_body);
 /**
  * Get the connector's name.
  *

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/python/qpid_dispatch_internal/management/agent/agent.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/agent/agent.py b/python/qpid_dispatch_internal/management/agent/agent.py
index 8ac54f2..5430e6e 100644
--- a/python/qpid_dispatch_internal/management/agent/agent.py
+++ b/python/qpid_dispatch_internal/management/agent/agent.py
@@ -769,7 +769,7 @@ class ManagementAgent:
         else:
             self.entities = []
         self.log_adapter = LogAdapter("AGENT")
-
+        self.adapters = []
         self.management = self.create_entity({"type": "management"})
         # self.add_entity(self.management)
         #self.io = IoAdapter(self.receive, address, 'L', '0', TREATMENT_ANYCAST_CLOSEST)
@@ -838,10 +838,9 @@ class ManagementAgent:
     def _create_config_entities(self):
         print 'In _create_config_entities ******************** '
         for adapter in self.adapters:
-            operation_ordinality = 1 # You have to get this from somewhere
             print adapter.attributes
             self.post_request(cid=None, reply_to=None,
-                              operation_ordinality=operation_ordinality,
+                              operation_ordinality=self.all_operation_defs.get('CREATE').ordinality,
                               entity_type_ordinality=adapter.entity_type.ordinality,
                               body=adapter.attributes)
 
@@ -849,7 +848,7 @@ class ManagementAgent:
         return self.config_types
 
     def entity_adapters(self, entities):
-        self.adapters = []
+
         local_entities = list(entities)
 
         for entity in local_entities:
@@ -1041,7 +1040,7 @@ class ManagementAgent:
         reply_to = request.reply_to
         correlation_id = request.correlation_id
         entity_type_ordinality = entity_type.ordinality
-        #operation_ordinality = operation.ordinality
+        operation_ordinality = self.schema.all_operation_defs.get(operation.uppercase())
 
         print 'reply_to, correlation_id, entity_type_ordinality ', reply_to, correlation_id, entity_type_ordinality
 
@@ -1051,8 +1050,11 @@ class ManagementAgent:
 
                 # request.body is already a map with the create parameters
                 # request.properties has the operation, name, type
-                request_handler.qd_post_management_request(operation, entity_type_ordinality, correlation_id, reply_to,
-                                                           request.body)
+                self.post_request(correlation_id,
+                                  reply_to,
+                                  operation_ordinality=operation_ordinality,
+                                  entity_type_ordinality=entity_type_ordinality,
+                                  body=request.body)
 
             request_type = request.properties.get('type')
             if self.schema.is_long_name(request_type):

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/python/qpid_dispatch_internal/management/schema/qd_schema.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/schema/qd_schema.py b/python/qpid_dispatch_internal/management/schema/qd_schema.py
index 565879f..576f83c 100644
--- a/python/qpid_dispatch_internal/management/schema/qd_schema.py
+++ b/python/qpid_dispatch_internal/management/schema/qd_schema.py
@@ -1,21 +1,21 @@
-##
-## Licensed to the Apache Software Foundation (ASF) under one
-## or more contributor license agreements.  See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership.  The ASF licenses this file
-## to you 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.  See the License for the
-## specific language governing permissions and limitations
-## under the License
-##
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.  See the License for the
+# specific language governing permissions and limitations
+# under the License
+#
 
 """
 Schema for AMQP management entity types.
@@ -121,7 +121,6 @@ class EnumType(Type):
         @param tags: A list of string values for the enumerated type.
         """
         assert isinstance(tags, list)
-        print "tags is ", tags
         super(EnumType, self).__init__("enum%s"%([str(t) for t in tags]), int)
         self.tags = tags
 
@@ -303,10 +302,11 @@ class MessageDef(object):
 
 class OperationDef(object):
     """An operation definition"""
-    def __init__(self, name, description=None, request=None, response=None):
+    def __init__(self, name, description=None, request=None, response=None, ordinality=None):
         try:
             self.name = name
             self.description = description
+            self.ordinality = ordinality
             self.request = self.response = None
             if request:
                 self.request = MessageDef(**request)
@@ -509,7 +509,6 @@ class Schema(object):
         @param entity_types: Map of  { entityTypeName: { singleton:, attributes:{...}}}
         @param description: Human readable description.
         """
-        print "In Schema init *******"
         if prefix:
             self.prefix = prefix.strip('.')
             self.prefixdot = self.prefix + '.'
@@ -526,9 +525,16 @@ class Schema(object):
         self.all_attributes = set()
 
         ordinality = 0
+        operation_def_ordinality = 0
+        self.all_operation_defs = OrderedDict()
         for e in self.entity_types.itervalues():
             e.init()
             e.ordinality = ordinality
+            for key in e.operation_defs:
+                op_def = e.operation_defs[key]
+                op_def.ordinality = operation_def_ordinality
+                operation_def_ordinality += 1
+                self.all_operation_defs[key] = op_def
             self.all_attributes.update(e.attributes.keys())
             ordinality += 1
 
@@ -650,7 +656,6 @@ class QdSchema(Schema):
         """Load schema."""
         qd_schema = get_data('qpid_dispatch.management', 'qdrouter.json')
         try:
-            print "In QdSchema init *****"
             super(QdSchema, self).__init__(**json.loads(qd_schema, **JSON_LOAD_KWARGS))
         except Exception,e:
             raise ValueError("Invalid schema qdrouter.json: %s" % e)

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7367e96..814f318 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -60,6 +60,7 @@ set(qpid_dispatch_SOURCES
   message.c
   parse.c
   policy.c
+  management_agent.c
   posix/driver.c
   posix/threading.c
   python_embedded.c
@@ -78,7 +79,6 @@ set(qpid_dispatch_SOURCES
   router_core/router_core.c
   router_core/router_core_thread.c
   router_core/route_tables.c
-  router_core/management_agent.c
   router_core/terminus.c
   router_core/transfer.c
   router_node.c

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/src/agent.c
----------------------------------------------------------------------
diff --git a/src/agent.c b/src/agent.c
index bbd6a22..7dd68bd 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -53,27 +53,8 @@ static PyObject *qd_post_management_request(PyObject *self,
     if (!PyArg_ParseTupleAndKeywords(args, keywds, "OOOOOiiii", kwlist, &cid, &reply_to, &name, &identity, &body, &operation, &entity_type, &count, &offset))
         return 0;
 
-    if (cid == Py_None) {
-            printf("cid is None *********\n");
-    }
-    if (reply_to == Py_None) {
-                printf("reply_to is None *********\n");
-        }
-    if (name == Py_None) {
-                printf("name is None *********\n");
-        }
-    if (identity == Py_None) {
-                printf("identity is None *********\n");
-        }
-
-    printf("operation is %i \n", operation);
-    printf("entity_type is %i \n", entity_type);
-    printf("count is %i \n", count);
-    printf("offset is %i \n", offset);
-
     qd_composed_field_t *field = qd_compose_subfield(0);
 
-    //Insert operation
     qd_py_to_composed(cid, field);
     qd_py_to_composed(reply_to, field);
     qd_py_to_composed(name, field);
@@ -92,7 +73,7 @@ static PyObject *qd_post_management_request(PyObject *self,
     request->operation = operation;
 
     AgentAdapter *adapter = ((AgentAdapter*) self);
-    request->ctx = adapter->agent->handlers[entity_type]->ctx;
+    //request->ctx = adapter->agent->handlers[entity_type]->ctx;
     qd_management_work_item_t *work_item = NEW(qd_management_work_item_t);
     work_item->request = request;
     //
@@ -102,15 +83,12 @@ static PyObject *qd_post_management_request(PyObject *self,
     DEQ_INSERT_TAIL(adapter->agent->work_queue, work_item);
     sys_mutex_unlock(adapter->agent->lock);
 
-    //
-    // Create a work item (qd_management_work_item_t)
-    //
-    work_item->request = request;
+    //create_handler(request);
 
     //
     // TODO - Kick off processing of the work queue
     //
-    qd_timer_schedule(adapter->agent->timer, 0);
+    //qd_timer_schedule(adapter->agent->timer, 0);
 
     return Py_None;
 }
@@ -213,28 +191,16 @@ static PyTypeObject AgentAdapterType = {
 
 qd_agent_t* qd_agent(qd_dispatch_t *qd, char *address, const char *config_path)
 {
-    printf("In qd_agent 1\n");
     //
     // Create a new instance of AgentAdapterType
     //
     AgentAdapterType.tp_new = PyType_GenericNew;
     PyType_Ready(&AgentAdapterType);
 
-    PyObject *module1 = PyImport_ImportModule(MANAGEMENT_MODULE);
     // Load the qpid_dispatch_internal.management Python module
     PyObject *module = PyImport_ImportModule(MANAGEMENT_INTERNAL_MODULE);
 
-    printf("In qd_agent 2\n");
-
-    if (!module1) {
-            printf("In qd_agent 2.1\n");
-        qd_error_py();
-        //qd_log(log_source, QD_LOG_CRITICAL, "Cannot load dispatch extension module '%s'", MANAGEMENT_INTERNAL_MODULE);
-        abort();
-    }
-
     if (!module) {
-            printf("In qd_agent 2.0\n");
         qd_error_py();
         //qd_log(log_source, QD_LOG_CRITICAL, "Cannot load dispatch extension module '%s'", MANAGEMENT_INTERNAL_MODULE);
         abort();
@@ -247,9 +213,7 @@ qd_agent_t* qd_agent(qd_dispatch_t *qd, char *address, const char *config_path)
     //Use the "AgentAdapter" name to add the AgentAdapterType to the management
     PyModule_AddObject(module, "AgentAdapter", (PyObject*) &AgentAdapterType);
     PyObject *adapterType     = PyObject_GetAttrString(module, "AgentAdapter");
-    printf("In qd_agent 3\n");
     PyObject *adapterInstance = PyObject_CallObject(adapterType, 0);
-    printf("In qd_agent 4\n");
 
     //
     //Instantiate the new agent and return it
@@ -263,6 +227,8 @@ qd_agent_t* qd_agent(qd_dispatch_t *qd, char *address, const char *config_path)
     //agent->timer = qd_timer(qd, process_work_queue, agent);
     DEQ_INIT(agent->work_queue);
     agent->lock = sys_mutex();
+    AgentAdapter *adapter = ((AgentAdapter*) adapterInstance);
+    adapter->agent = agent;
 
     //
     // Initialize the handlers to zeros
@@ -276,20 +242,15 @@ qd_agent_t* qd_agent(qd_dispatch_t *qd, char *address, const char *config_path)
     //TODO - This is a test
     qd_agent_start(agent);
 
-    printf ("qd_agent 6\n");
-
     return agent;
 }
 
 
 qd_error_t qd_agent_start(qd_agent_t *agent)
 {
-    printf("In qd_agent_start 0 \n");
     // Load the qpid_dispatch_internal.management Python module
     PyObject *module = PyImport_ImportModule(MANAGEMENT_INTERNAL_MODULE);
 
-    printf("In qd_agent_start 1\n");
-
     char *class = "ManagementAgent";
 
     //
@@ -297,8 +258,6 @@ qd_error_t qd_agent_start(qd_agent_t *agent)
     //
     PyObject* pClass = PyObject_GetAttrString(module, class); QD_ERROR_PY_RET();
 
-    printf("Hello world %i\n", PyClass_Check(pClass));
-
     //
     // Constructor Arguments for ManagementAgent
     //
@@ -315,13 +274,10 @@ qd_error_t qd_agent_start(qd_agent_t *agent)
    PyObject *config_file = PyString_FromString((char *)agent->config_file);
    PyTuple_SetItem(pArgs, 2, config_file);
 
-   printf("Hello world 2\n");
-
    //
    // Instantiate the ManagementAgent class
    //
    PyObject* pyManagementInstance = PyInstance_New(pClass, pArgs, 0); QD_ERROR_PY_RET();
-   printf("Hello world 3\n");
    if (!pyManagementInstance) {
        qd_log(agent->log_source, QD_LOG_CRITICAL, "Cannot create instance of Python class '%s.%s'", MANAGEMENT_INTERNAL_MODULE, class);
    }
@@ -353,6 +309,30 @@ void qd_agent_register_handlers(qd_agent_t *agent,
     agent->handlers[entity_type] = entity_handler;
 }
 
+qd_buffer_list_t *get_request_buffers(qd_agent_request_t *request)
+{
+    return request->buffer_list;
+}
+
+qd_schema_entity_type_t get_request_entity_type(qd_agent_request_t *request)
+{
+    return request->entity_type;
+}
+
+void  *get_request_context(qd_agent_request_t *request)
+{
+    return request->ctx;
+}
+
+int get_request_count(qd_agent_request_t *request)
+{
+    return request->count;
+}
+
+int get_request_offset(qd_agent_request_t *request)
+{
+    return request->offset;
+}
 
 void qd_agent_free(qd_agent_t *agent)
 {

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/src/agent.h
----------------------------------------------------------------------
diff --git a/src/agent.h b/src/agent.h
index 9f50fce..0ab4615 100644
--- a/src/agent.h
+++ b/src/agent.h
@@ -35,9 +35,15 @@ qd_agent_t* qd_agent(qd_dispatch_t *qd, char *address, const char *config_path);
  */
 void qd_agent_free(qd_agent_t *agent);
 
+/**
+ * Start the agent.
+ * Loads the contents of the config file located in config_path
+ * Agent starts listening on the provided address
+ */
+qd_error_t qd_agent_start(qd_agent_t *agent);
 
-typedef void (*qd_agent_handler_t) (void *context,
-                                    qd_agent_request_t *request);
+
+typedef void (*qd_agent_handler_t) (qd_agent_request_t *request);
 
 /**
  * Register CRUDQ handlers for a particular entity type
@@ -52,10 +58,12 @@ void qd_agent_register_handlers(qd_agent_t *agent,
                                 qd_agent_handler_t query_handler);
 
 /**
- * Start the agent.
- * Loads the contents of the config file located in config_path
- * Agent starts listening on the provided address
+ * Functions that return the components of a request (qd_agent_request_t).
  */
-qd_error_t qd_agent_start(qd_agent_t *agent);
+qd_buffer_list_t *get_request_buffers(qd_agent_request_t *request);
+qd_schema_entity_type_t get_request_entity_type(qd_agent_request_t *request);
+int get_request_count(qd_agent_request_t *request);
+int get_request_offset(qd_agent_request_t *request);
+void *get_request_context(qd_agent_request_t *request);
 
 #endif

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/src/agent_handler.h
----------------------------------------------------------------------
diff --git a/src/agent_handler.h b/src/agent_handler.h
new file mode 100644
index 0000000..2b4d03f
--- /dev/null
+++ b/src/agent_handler.h
@@ -0,0 +1,72 @@
+#ifndef __agent_handler_h__
+#define __agent_handler_h__
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "agent.h"
+
+// The qdr_* functions handle CRUDQ calls related the the CORE data structures
+void qd_core_agent_create_handler(qd_agent_request_t *request);
+void qd_core_agent_update_handler(qd_agent_request_t *request);
+void qd_core_agent_delete_handler(qd_agent_request_t *request);
+void qd_core_agent_read_handler(qd_agent_request_t *request);
+void qd_core_agent_query_handler(qd_agent_request_t *request);
+
+// Handle sslProfile requests
+void qd_create_ssl_profile(qd_agent_request_t *request);
+void qd_delete_ssl_profile(qd_agent_request_t *request);
+void qd_read_ssl_profile(qd_agent_request_t *request);
+void qd_query_ssl_profile(qd_agent_request_t *request);
+
+// Handle listener requests
+void qd_create_listener(qd_agent_request_t *request);
+void qd_delete_listener(qd_agent_request_t *request);
+void qd_read_listener(qd_agent_request_t *request);
+void qd_query_listener(qd_agent_request_t *request);
+
+//Handler connector requests
+void qd_create_connector(qd_agent_request_t *request);
+void qd_delete_connector(qd_agent_request_t *request);
+void qd_read_connector(qd_agent_request_t *request);
+void qd_query_connector(qd_agent_request_t *request);
+
+//Handler router requests
+void qd_create_router(qd_agent_request_t *request);
+void qd_delete_router(qd_agent_request_t *request);
+void qd_read_router(qd_agent_request_t *request);
+void qd_query_router(qd_agent_request_t *request);
+
+//Handler connection requests
+void qd_create_connection(qd_agent_request_t *request);
+void qd_delete_connection(qd_agent_request_t *request);
+void qd_read_connection(qd_agent_request_t *request);
+void qd_query_connection(qd_agent_request_t *request);
+
+void send_response(void *ctx,
+                   qd_field_iterator_t *reply_to,
+                   qd_field_iterator_t *correlation_id,
+                   const qd_amqp_error_t *status,
+                   qd_composed_field_t *out_body);
+
+
+//TODO - will add more here
+
+
+#endif

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/src/connection_manager.c
----------------------------------------------------------------------
diff --git a/src/connection_manager.c b/src/connection_manager.c
index 9a2b415..79e6935 100644
--- a/src/connection_manager.c
+++ b/src/connection_manager.c
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
+#include <inttypes.h>
 #include <qpid/dispatch/connection_manager.h>
 #include <qpid/dispatch/ctools.h>
 #include <qpid/dispatch/threading.h>
@@ -36,6 +36,7 @@ struct qd_config_ssl_profile_t {
     uint64_t   identity;
     char      *name;
     char      *ssl_password;
+    char      *ssl_password_file;
     char      *ssl_trusted_certificate_db;
     char      *ssl_trusted_certificates;
     char      *ssl_uid_format;
@@ -78,7 +79,7 @@ struct qd_connection_manager_t {
 };
 
 /**
- * Search the list of config_ssl_profiles for an ssl-profile that matches the passed in name
+ * Search the linked list of config_ssl_profiles for an ssl-profile that matches the passed in name
  */
 static qd_config_ssl_profile_t *qd_find_ssl_profile(qd_connection_manager_t *cm, char *name)
 {
@@ -92,6 +93,39 @@ static qd_config_ssl_profile_t *qd_find_ssl_profile(qd_connection_manager_t *cm,
     return 0;
 }
 
+
+/**
+ * Search the linked list of config_ssl_profiles for an ssl-profile that matches the passed in name
+ */
+static qd_config_ssl_profile_t *qd_find_ssl_profile_by_name_iterator(qd_connection_manager_t *cm, qd_field_iterator_t *name)
+{
+    qd_config_ssl_profile_t *ssl_profile = DEQ_HEAD(cm->config_ssl_profiles);
+    while(ssl_profile) {
+        if (ssl_profile->name && qd_field_iterator_equal(name, (const unsigned char*) ssl_profile->name))
+            return ssl_profile;
+        ssl_profile = DEQ_NEXT(ssl_profile);
+    }
+
+    return 0;
+}
+
+/**
+ * Search the linked list of config_ssl_profiles for an ssl-profile that matches the passed in name
+ */
+static qd_config_ssl_profile_t *qd_find_ssl_profile_by_identity_iterator(qd_connection_manager_t *cm, qd_field_iterator_t *identity)
+{
+    qd_config_ssl_profile_t *ssl_profile = DEQ_HEAD(cm->config_ssl_profiles);
+    while(ssl_profile) {
+        char id[100];
+        snprintf(id, 100, "%"PRId64, ssl_profile->identity);
+        if (ssl_profile->identity && qd_field_iterator_equal(identity, (const unsigned char*) id))
+            return ssl_profile;
+        ssl_profile = DEQ_NEXT(ssl_profile);
+    }
+
+    return 0;
+}
+
 static void qd_server_config_free(qd_server_config_t *cf)
 {
     if (!cf) return;
@@ -237,6 +271,132 @@ static qd_error_t load_server_config(qd_dispatch_t *qd, qd_server_config_t *conf
     return qd_error_code();
 }
 
+static char *qd_get_parsed_field_value(qd_config_ssl_profile_t *ssl_profile, qd_parsed_field_t *in_body, int field_num)
+{
+    char key[10];
+    sprintf(key, "%d", field_num);
+    qd_parsed_field_t *field    = qd_parse_value_by_key(in_body, key);
+    if (field) {
+        qd_field_iterator_t *iter = qd_parse_raw(field);
+        if (iter) {
+            return (char*)qd_field_iterator_copy(iter);
+        }
+    }
+    return 0;
+}
+
+static void qd_ssl_profile_insert_column(qd_config_ssl_profile_t *ssl_profile, int col, qd_composed_field_t *out_body, bool as_map)
+{
+    if (as_map)
+        qd_compose_insert_string(out_body, qd_schema_sslProfile_attributes_names[col]);
+
+    switch(col) {
+        case QD_SCHEMA_SSLPROFILE_ATTRIBUTES_CERTDB:
+            if (ssl_profile->ssl_trusted_certificate_db)
+                qd_compose_insert_string(out_body, ssl_profile->ssl_trusted_certificate_db);
+            else
+                qd_compose_insert_null(out_body);
+            break;
+        case QD_SCHEMA_SSLPROFILE_ATTRIBUTES_CERTFILE:
+            if (ssl_profile->ssl_certificate_file)
+                qd_compose_insert_string(out_body, ssl_profile->ssl_certificate_file);
+            else
+                qd_compose_insert_null(out_body);
+            break;
+        case QD_SCHEMA_SSLPROFILE_ATTRIBUTES_KEYFILE:
+            if (ssl_profile->ssl_private_key_file)
+                qd_compose_insert_string(out_body, ssl_profile->ssl_private_key_file);
+            else
+                qd_compose_insert_null(out_body);
+            break;
+        case QD_SCHEMA_SSLPROFILE_ATTRIBUTES_PASSWORDFILE:
+            if (ssl_profile->ssl_password_file)
+                qd_compose_insert_string(out_body, ssl_profile->ssl_password_file);
+            else
+                qd_compose_insert_null(out_body);
+            break;
+        case QD_SCHEMA_SSLPROFILE_ATTRIBUTES_PASSWORD:
+            if (ssl_profile->ssl_password)
+                qd_compose_insert_string(out_body, ssl_profile->ssl_password);
+            else
+                qd_compose_insert_null(out_body);
+            break;
+        case QD_SCHEMA_SSLPROFILE_ATTRIBUTES_UIDFORMAT:
+            if (ssl_profile->ssl_uid_format)
+                qd_compose_insert_string(out_body, ssl_profile->ssl_uid_format);
+            else
+                qd_compose_insert_null(out_body);
+            break;
+        case QD_SCHEMA_SSLPROFILE_ATTRIBUTES_DISPLAYNAMEFILE:
+            if (ssl_profile->ssl_display_name_file)
+                qd_compose_insert_string(out_body, ssl_profile->ssl_display_name_file);
+            else
+                qd_compose_insert_null(out_body);
+            break;
+        case QD_SCHEMA_SSLPROFILE_ATTRIBUTES_NAME:
+            if (ssl_profile->name)
+                qd_compose_insert_string(out_body, ssl_profile->name);
+            else
+                qd_compose_insert_null(out_body);
+            break;
+        case QD_SCHEMA_SSLPROFILE_ATTRIBUTES_IDENTITY: {
+            char id_str[100];
+            snprintf(id_str, 100, "%"PRId64, ssl_profile->identity);
+            qd_compose_insert_string(out_body, id_str);
+            break;
+        }
+        default: break;
+
+    }
+}
+
+static void qd_write_ssl_profile_map(qd_config_ssl_profile_t  *ssl_profile, qd_composed_field_t *out_body)
+{
+    if (out_body) {
+        qd_compose_start_map(out_body);
+        for (int col = 0; col < QD_SCHEMA_SSLPROFILE_ATTRIBUTES_ENUM_COUNT; col++)
+            qd_ssl_profile_insert_column(ssl_profile, col, out_body, true);
+        qd_compose_end_map(out_body);
+    }
+}
+
+qd_amqp_error_t qd_connection_manager_create_ssl_profile(qd_dispatch_t *qd, qd_field_iterator_t *name, qd_parsed_field_t *in_body, qd_composed_field_t *out_body)
+{
+    qd_connection_manager_t *cm = qd->connection_manager;
+
+    //Check if an ssl profile with this name already exists.
+    qd_config_ssl_profile_t  *profile = qd_find_ssl_profile_by_name_iterator(cm, name);
+
+    if (profile) {
+        //qd_log(cm->log_source, QD_LOG_INFO, "SSL Profile with name %s already exists", profile_name);
+        qd_amqp_error_t          status = QD_AMQP_BAD_REQUEST;
+        status.description = "SSL Profile with name already exists";
+        return status;
+    }
+
+    qd_config_ssl_profile_t *ssl_profile = NEW(qd_config_ssl_profile_t);
+    DEQ_ITEM_INIT(ssl_profile);
+    DEQ_INSERT_TAIL(cm->config_ssl_profiles, ssl_profile);
+
+    ssl_profile->name                        = (char*)qd_field_iterator_copy(name);
+    ssl_profile->ssl_trusted_certificate_db  = qd_get_parsed_field_value(ssl_profile, in_body, QD_SCHEMA_SSLPROFILE_ATTRIBUTES_CERTDB);
+    ssl_profile->ssl_certificate_file        = qd_get_parsed_field_value(ssl_profile, in_body, QD_SCHEMA_SSLPROFILE_ATTRIBUTES_CERTFILE);
+    ssl_profile->ssl_private_key_file        = qd_get_parsed_field_value(ssl_profile, in_body, QD_SCHEMA_SSLPROFILE_ATTRIBUTES_KEYFILE);
+    ssl_profile->ssl_password_file           = qd_get_parsed_field_value(ssl_profile, in_body, QD_SCHEMA_SSLPROFILE_ATTRIBUTES_PASSWORDFILE);
+    ssl_profile->ssl_password                = qd_get_parsed_field_value(ssl_profile, in_body, QD_SCHEMA_SSLPROFILE_ATTRIBUTES_PASSWORD);
+    ssl_profile->ssl_uid_format              = qd_get_parsed_field_value(ssl_profile, in_body, QD_SCHEMA_SSLPROFILE_ATTRIBUTES_UIDFORMAT);
+    ssl_profile->ssl_display_name_file       = qd_get_parsed_field_value(ssl_profile, in_body, QD_SCHEMA_SSLPROFILE_ATTRIBUTES_DISPLAYNAMEFILE);
+
+    sys_mutex_lock(qd->connection_manager->ssl_profile_lock);
+    ssl_profile->ref_count = 0;
+    sys_mutex_unlock(qd->connection_manager->ssl_profile_lock);
+    qd_log(cm->log_source, QD_LOG_INFO, "Created SSL Profile with name %s ", ssl_profile->name);
+
+    qd_write_ssl_profile_map(ssl_profile, out_body);
+
+    return QD_AMQP_OK;
+}
+
 
 qd_config_ssl_profile_t *qd_dispatch_configure_ssl_profile(qd_dispatch_t *qd, qd_entity_t *entity)
 {
@@ -254,6 +414,7 @@ qd_config_ssl_profile_t *qd_dispatch_configure_ssl_profile(qd_dispatch_t *qd, qd
     ssl_profile->ssl_trusted_certificates   = qd_entity_opt_string(entity, "trustedCerts", 0); CHECK();
     ssl_profile->ssl_uid_format             = qd_entity_opt_string(entity, "uidFormat", 0); CHECK();
     ssl_profile->ssl_display_name_file      = qd_entity_opt_string(entity, "displayNameFile", 0); CHECK();
+    ssl_profile->ssl_password_file          = qd_entity_opt_string(entity, "passwordFile", 0); CHECK();
     sys_mutex_lock(qd->connection_manager->ssl_profile_lock);
     ssl_profile->ref_count                  = 0;
     sys_mutex_unlock(qd->connection_manager->ssl_profile_lock);
@@ -481,7 +642,7 @@ void qd_connection_manager_delete_listener(qd_dispatch_t *qd, void *impl)
 /**
  * Only those SSL Profiles that are not being referenced from other listeners/connectors can be deleted
  */
-bool qd_connection_manager_delete_ssl_profile(qd_dispatch_t *qd, void *impl)
+/*bool qd_connection_manager_delete_ssl_profile(qd_dispatch_t *qd, void *impl)
 {
     qd_config_ssl_profile_t *ssl_profile = (qd_config_ssl_profile_t*) impl;
     if(ssl_profile) {
@@ -491,8 +652,88 @@ bool qd_connection_manager_delete_ssl_profile(qd_dispatch_t *qd, void *impl)
         return freed;
     }
     return false;
+}*/
+
+qd_amqp_error_t qd_connection_manager_delete_ssl_profile(qd_dispatch_t *qd,
+                                                         qd_field_iterator_t *name,
+                                                         qd_field_iterator_t *identity)
+{
+    qd_amqp_error_t status = QD_AMQP_OK;
+    while (true) {
+        if (!name && !identity) {
+            status = QD_AMQP_BAD_REQUEST;
+            status.description = "No name or identity provided";
+            break;
+        }
+        qd_config_ssl_profile_t *ssl_profile = 0;
+        if (identity) {
+            ssl_profile = qd_find_ssl_profile_by_identity_iterator(qd->connection_manager, identity);
+        }
+        else {
+            ssl_profile = qd_find_ssl_profile_by_name_iterator(qd->connection_manager, name);
+        }
+
+        if(ssl_profile) {
+            bool freed = qd_config_ssl_profile_free(qd->connection_manager, ssl_profile);
+            if (freed)
+                DEQ_REMOVE(qd->connection_manager->config_ssl_profiles, ssl_profile);
+            else {
+                status = QD_AMQP_BAD_REQUEST;
+                status.description = "SSL Profile is referenced by other listeners/connectors. Delete the associated "
+                            "listeners/connectors before deleting the SSL Profile";
+            }
+        }
+        else {
+            status = QD_AMQP_BAD_REQUEST;
+            status.description = "Cannot find SSL Profile with the given name or identity";
+        }
+        break;
+    }
+
+    return status;
 }
 
+qd_amqp_error_t qd_connection_manager_read_ssl_profile(qd_dispatch_t *qd,
+                                                       qd_field_iterator_t *name,
+                                                       qd_field_iterator_t *identity,
+                                                       qd_composed_field_t *out_body)
+{
+    qd_amqp_error_t status = QD_AMQP_OK;
+
+    while (true) {
+        if (!name && !identity) {
+            status = QD_AMQP_BAD_REQUEST;
+            status.description = "No name or identity provided";
+            break;
+        }
+        qd_config_ssl_profile_t *ssl_profile = 0;
+        if (identity) {
+            ssl_profile = qd_find_ssl_profile_by_identity_iterator(qd->connection_manager, identity);
+        }
+        else {
+            ssl_profile = qd_find_ssl_profile_by_name_iterator(qd->connection_manager, name);
+        }
+
+        if(ssl_profile)
+            qd_write_ssl_profile_map(ssl_profile, out_body);
+        else {
+            status = QD_AMQP_BAD_REQUEST;
+            status.description = "Cannot find SSL Profile with the given name or identity";
+        }
+        break;
+    }
+
+    return status;
+}
+
+qd_amqp_error_t qd_connection_manager_query_ssl_profile(qd_dispatch_t *qd,
+                                                        int offset,
+                                                        int count,
+                                                        qd_parsed_field_t     *in_body,
+                                                        qd_composed_field_t     *out_body)
+{
+    return QD_AMQP_OK;
+}
 
 void qd_connection_manager_delete_connector(qd_dispatch_t *qd, void *impl)
 {

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/src/management_agent.c
----------------------------------------------------------------------
diff --git a/src/management_agent.c b/src/management_agent.c
new file mode 100644
index 0000000..03ac8cc
--- /dev/null
+++ b/src/management_agent.c
@@ -0,0 +1,418 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdio.h>
+#include <qpid/dispatch/parse.h>
+#include <qpid/dispatch/iterator.h>
+#include <qpid/dispatch/router.h>
+#include <qpid/dispatch/router_core.h>
+#include <qpid/dispatch/compose.h>
+#include <qpid/dispatch/dispatch.h>
+#include <qpid/dispatch/connection_manager.h>
+#include "dispatch_private.h"
+#include "agent.h"
+
+const char *ENTITY = "entityType";
+const char *TYPE = "type";
+const char *COUNT = "count";
+const char *OFFSET = "offset";
+const char *NAME = "name";
+const char *IDENTITY = "identity";
+
+
+const char *OPERATION = "operation";
+const char *ATTRIBUTE_NAMES = "attributeNames";
+
+const unsigned char *config_address_entity_type = (unsigned char*) "org.apache.qpid.dispatch.router.config.address";
+const unsigned char *link_route_entity_type     = (unsigned char*) "org.apache.qpid.dispatch.router.config.linkRoute";
+const unsigned char *auto_link_entity_type      = (unsigned char*) "org.apache.qpid.dispatch.router.config.autoLink";
+const unsigned char *address_entity_type        = (unsigned char*) "org.apache.qpid.dispatch.router.address";
+const unsigned char *link_entity_type           = (unsigned char*) "org.apache.qpid.dispatch.router.link";
+const unsigned char *console_entity_type        = (unsigned char*) "org.apache.qpid.dispatch.console";
+
+const char * const status_description = "statusDescription";
+const char * const correlation_id = "correlation-id";
+const char * const results = "results";
+const char * const status_code = "statusCode";
+
+const char * MANAGEMENT_INTERNAL = "_local/$_management_internal";
+
+//TODO - Move these to amqp.h
+const unsigned char *MANAGEMENT_QUERY  = (unsigned char*) "QUERY";
+const unsigned char *MANAGEMENT_CREATE = (unsigned char*) "CREATE";
+const unsigned char *MANAGEMENT_READ   = (unsigned char*) "READ";
+const unsigned char *MANAGEMENT_UPDATE = (unsigned char*) "UPDATE";
+const unsigned char *MANAGEMENT_DELETE = (unsigned char*) "DELETE";
+
+typedef struct qd_management_context_t {
+    qd_message_t                *response;
+    qd_composed_field_t         *out_body;
+    qd_field_iterator_t         *reply_to;
+    qd_field_iterator_t         *correlation_id;
+    qdr_query_t                 *query;
+    qdr_core_t                  *core;
+    int                          count;
+    int                          current_count;
+    qd_schema_entity_operation_t operation_type;
+} qd_management_context_t ;
+
+ALLOC_DECLARE(qd_management_context_t);
+ALLOC_DEFINE(qd_management_context_t);
+
+
+/**
+ * Convenience function to create and initialize context (qd_management_context_t)
+ */
+static qd_management_context_t* qd_management_context(qd_field_iterator_t          *reply_to,
+                                                      qd_field_iterator_t          *correlation_id,
+                                                      qdr_query_t                  *query,
+                                                      qdr_core_t                   *core,
+                                                      qd_schema_entity_operation_t operation_type,
+                                                      int                          count)
+{
+    qd_management_context_t *ctx = new_qd_management_context_t();
+    ctx->response       = qd_message();
+    ctx->out_body       = qd_compose(QD_PERFORMATIVE_BODY_AMQP_VALUE, 0);
+    ctx->reply_to       = reply_to;
+    ctx->correlation_id = correlation_id;
+    ctx->query          = query;
+    ctx->core           = core;
+    ctx->count          = count;
+    ctx->current_count  = 0;
+    ctx->operation_type = operation_type;
+
+    return ctx;
+}
+
+static void qd_parse_agent_request(qd_agent_request_t       *request,
+                                   qd_schema_entity_type_t  *entity_type,
+                                   qd_field_iterator_t      **cid,
+                                   qd_field_iterator_t      **reply_to,
+                                   qd_field_iterator_t      **name_iter,
+                                   qd_field_iterator_t      **identity_iter,
+                                   qd_parsed_field_t        **body)
+{
+    qd_buffer_list_t *buffer_list = get_request_buffers(request);
+    qd_field_iterator_t *iter = qd_address_iterator_buffer(DEQ_HEAD(*buffer_list), 0, qd_buffer_list_length(buffer_list), ITER_VIEW_ALL);
+    *entity_type = get_request_entity_type(request);
+    *cid = qd_parse_raw(qd_parse(iter));
+    *reply_to = qd_parse_raw(qd_parse(iter));
+    *name_iter = qd_parse_raw(qd_parse(iter));
+    *identity_iter = qd_parse_raw(qd_parse(iter));
+    *body = qd_parse(iter);
+}
+
+
+/**
+ * Sets the error status on a new composed field.
+ */
+static void qd_set_response_status(const qd_amqp_error_t *error, qd_composed_field_t **field)
+{
+    //
+    // Insert appropriate success or error
+    //
+    *field = qd_compose(QD_PERFORMATIVE_APPLICATION_PROPERTIES, *field);
+    qd_compose_start_map(*field);
+
+    qd_compose_insert_string(*field, status_description);
+    qd_compose_insert_string(*field, error->description);
+
+    qd_compose_insert_string(*field, status_code);
+    qd_compose_insert_uint(*field, error->status);
+
+    qd_compose_end_map(*field);
+}
+
+
+static void qd_set_properties(qd_field_iterator_t *correlation_id,
+                              qd_field_iterator_t *reply_to,
+                              qd_composed_field_t **fld)
+{
+    // Set the correlation_id and reply_to on fld
+    *fld = qd_compose(QD_PERFORMATIVE_PROPERTIES, 0);
+    qd_compose_start_list(*fld);
+    qd_compose_insert_null(*fld);                           // message-id
+    qd_compose_insert_null(*fld);                           // user-id
+    qd_compose_insert_string_iterator(*fld, reply_to);     // to
+    qd_compose_insert_null(*fld);                           // subject
+    qd_compose_insert_null(*fld);
+    qd_compose_insert_typed_iterator(*fld, correlation_id);
+    qd_compose_end_list(*fld);
+    qd_field_iterator_free(correlation_id);
+}
+
+
+void send_response(void *ctx,
+                   qd_field_iterator_t *reply_to,
+                   qd_field_iterator_t *correlation_id,
+                   const qd_amqp_error_t *status,
+                   qd_composed_field_t *out_body)
+{
+    qd_composed_field_t *fld = 0;
+
+    // Start composing the message.
+    // First set the properties on the message like reply_to, correlation-id etc.
+    qd_set_properties(correlation_id, reply_to, &fld);
+
+    // Second, set the status on the message, QD_AMQP_OK or QD_AMQP_BAD_REQUEST and so on.
+    qd_set_response_status(status, &fld);
+
+    qd_message_t *response = qd_message();
+    qdr_core_t *core = (qdr_core_t*)ctx; // This is not right since this is also used by non-core stuff
+
+    // Finally, compose and send the message.
+    qd_message_compose_3(response, fld, out_body);
+    qdr_send_to1(core, response, reply_to, true, false);
+
+    qd_compose_free(fld);
+
+}
+
+void qd_create_ssl_profile(qd_agent_request_t *request)
+{
+    qd_schema_entity_type_t entity_type;
+    qd_field_iterator_t     *correlation_id;
+    qd_field_iterator_t     *reply_to;
+    qd_field_iterator_t     *name_iter;
+    qd_field_iterator_t     *identity_iter;
+    qd_parsed_field_t       *in_body;
+
+    qd_parse_agent_request(request, &entity_type, &correlation_id, &reply_to, &name_iter, &identity_iter, &in_body);
+
+    qd_dispatch_t *qd = (qd_dispatch_t*)get_request_context(request);
+
+    qd_composed_field_t *out_body = qd_compose(QD_PERFORMATIVE_BODY_AMQP_VALUE, 0);
+
+    qd_amqp_error_t status = qd_connection_manager_create_ssl_profile(qd, name_iter, in_body, out_body);
+
+    send_response(get_request_context(request), reply_to, correlation_id, &status, out_body);
+}
+
+
+void qd_query_ssl_profile(qd_agent_request_t *request)
+{
+    qd_schema_entity_type_t entity_type;
+    qd_field_iterator_t     *correlation_id;
+    qd_field_iterator_t     *reply_to;
+    qd_field_iterator_t     *name_iter;
+    qd_field_iterator_t     *identity_iter;
+    qd_parsed_field_t       *in_body;
+
+    qd_parse_agent_request(request, &entity_type, &correlation_id, &reply_to, &name_iter, &identity_iter, &in_body);
+
+    qd_dispatch_t *qd = (qd_dispatch_t*)get_request_context(request);
+
+    qd_composed_field_t *out_body = qd_compose(QD_PERFORMATIVE_BODY_AMQP_VALUE, 0);
+
+    qd_amqp_error_t status = qd_connection_manager_query_ssl_profile(qd, get_request_offset(request), get_request_count(request), in_body, out_body);
+
+    send_response(get_request_context(request), reply_to, correlation_id, &status, out_body);
+}
+
+
+void qd_delete_ssl_profile(qd_agent_request_t *request)
+{
+    qd_schema_entity_type_t entity_type;
+    qd_field_iterator_t     *correlation_id;
+    qd_field_iterator_t     *reply_to;
+    qd_field_iterator_t     *name_iter;
+    qd_field_iterator_t     *identity_iter;
+    qd_parsed_field_t       *in_body;
+
+    qd_parse_agent_request(request, &entity_type, &correlation_id, &reply_to, &name_iter, &identity_iter, &in_body);
+}
+
+static void qd_manage_response_handler(void *context, const qd_amqp_error_t *status, bool more)
+{
+    qd_management_context_t *mgmt_ctx = (qd_management_context_t*) context;
+
+    if (mgmt_ctx->operation_type == QD_SCHEMA_ENTITY_OPERATION_QUERY) {
+        if (status->status / 100 == 2) { // There is no error, proceed to conditionally call get_next
+            if (more) {
+               mgmt_ctx->current_count++; // Increment how many you have at hand
+               if (mgmt_ctx->count != mgmt_ctx->current_count) {
+                   qdr_query_get_next(mgmt_ctx->query);
+                   return;
+               } else
+                   //
+                   // This is the one case where the core agent won't free the query itself.
+                   //
+                   qdr_query_free(mgmt_ctx->query);
+            }
+        }
+        qd_compose_end_list(mgmt_ctx->out_body);
+        qd_compose_end_map(mgmt_ctx->out_body);
+    }
+    else if (mgmt_ctx->operation_type == QD_SCHEMA_ENTITY_OPERATION_DELETE) {
+        // The body of the delete response message MUST consist of an amqp-value section containing a Map with zero entries.
+        qd_compose_start_map(mgmt_ctx->out_body);
+        qd_compose_end_map(mgmt_ctx->out_body);
+    }
+    else if (mgmt_ctx->operation_type == QD_SCHEMA_ENTITY_OPERATION_READ) {
+        if (status->status / 100 != 2) {
+            qd_compose_start_map(mgmt_ctx->out_body);
+            qd_compose_end_map(mgmt_ctx->out_body);
+        }
+    }
+
+    //Send the response to the caller
+    send_response(mgmt_ctx->core, mgmt_ctx->reply_to, mgmt_ctx->correlation_id, status, mgmt_ctx->out_body);
+
+    qd_message_free(mgmt_ctx->response);
+    qd_compose_free(mgmt_ctx->out_body);
+
+    free_qd_management_context_t(mgmt_ctx);
+}
+
+
+void qd_core_agent_query_handler(qd_agent_request_t *request)
+{
+    qd_schema_entity_type_t  entity_type;
+    qd_field_iterator_t     *correlation_id;
+    qd_field_iterator_t     *reply_to;
+    qd_field_iterator_t     *name_iter;
+    qd_field_iterator_t     *identity_iter;
+    qd_parsed_field_t       *in_body;
+
+    qd_parse_agent_request(request, &entity_type, &correlation_id, &reply_to, &name_iter, &identity_iter, &in_body);
+    int count = get_request_count(request);
+    int offset = get_request_offset(request);
+    qdr_core_t *core = (qdr_core_t*)get_request_context(request);
+
+    // Call local function that creates and returns a local qd_management_context_t object containing the values passed in.
+    qd_management_context_t *mgmt_ctx = qd_management_context(reply_to, correlation_id, 0, core, QD_SCHEMA_ENTITY_OPERATION_QUERY, count);
+
+    //
+    // Add the Body.
+    //
+    qd_composed_field_t *field = mgmt_ctx->out_body;
+
+    // Start a map in the body. Look for the end map in the callback function, qd_manage_response_handler.
+    qd_compose_start_map(field);
+
+    //add a "attributeNames" key
+    qd_compose_insert_string(field, ATTRIBUTE_NAMES);
+
+    // Grab the attribute names from the incoming message body. The attribute names will be used later on in the response.
+    qd_parsed_field_t *attribute_names_parsed_field = 0;
+
+    if (in_body != 0 && qd_parse_is_map(in_body)) {
+        attribute_names_parsed_field = qd_parse_value_by_key(in_body, ATTRIBUTE_NAMES);
+    }
+
+    // Set the callback function.
+    qdr_manage_handler(core, qd_manage_response_handler);
+    mgmt_ctx->query = qdr_manage_query(core, mgmt_ctx, entity_type, attribute_names_parsed_field, field);
+
+    //Add the attribute names
+    qdr_query_add_attribute_names(mgmt_ctx->query); //this adds a list of attribute names like ["attribute1", "attribute2", "attribute3", "attribute4",]
+    qd_compose_insert_string(field, results); //add a "results" key
+    qd_compose_start_list(field); //start the list for results
+
+    qdr_query_get_first(mgmt_ctx->query, offset);
+
+    qd_parse_free(in_body);
+}
+
+void qd_core_agent_create_handler(qd_agent_request_t *request)
+{
+    qd_schema_entity_type_t entity_type;
+    qd_field_iterator_t     *correlation_id;
+    qd_field_iterator_t     *reply_to;
+    qd_field_iterator_t     *name_iter;
+    qd_field_iterator_t     *identity_iter;
+    qd_parsed_field_t       *in_body;
+
+    qd_parse_agent_request(request, &entity_type, &correlation_id, &reply_to, &name_iter, &identity_iter, &in_body);
+
+    qdr_core_t *core = (qdr_core_t*)get_request_context(request);
+    // Set the callback function.
+    qdr_manage_handler(core, qd_manage_response_handler);
+
+    // Call local function that creates and returns a qd_management_context_t containing the values passed in.
+    qd_management_context_t *mgmt_ctx = qd_management_context(reply_to, correlation_id, 0, core, QD_SCHEMA_ENTITY_OPERATION_CREATE, 0);
+
+    qdr_manage_create(core, mgmt_ctx, entity_type, name_iter, in_body, mgmt_ctx->out_body);
+
+}
+
+void qd_core_agent_read_handler(qd_agent_request_t *request)
+{
+    qd_schema_entity_type_t  entity_type;
+    qd_field_iterator_t     *correlation_id;
+    qd_field_iterator_t     *reply_to;
+    qd_field_iterator_t     *name_iter;
+    qd_field_iterator_t     *identity_iter;
+    qd_parsed_field_t       *in_body;
+
+    qd_parse_agent_request(request, &entity_type, &correlation_id, &reply_to, &name_iter, &identity_iter, &in_body);
+
+    qdr_core_t *core = (qdr_core_t*)get_request_context(request);
+
+    // Set the callback function.
+    qdr_manage_handler(core, qd_manage_response_handler);
+
+    // Call local function that creates and returns a qd_management_context_t containing the values passed in.
+    qd_management_context_t *mgmt_ctx = qd_management_context(reply_to, correlation_id, 0, core, QD_SCHEMA_ENTITY_OPERATION_READ, 0);
+
+    //Call the read API function
+    qdr_manage_read(core, mgmt_ctx, entity_type, name_iter, identity_iter, mgmt_ctx->out_body);
+}
+
+
+void qd_core_agent_update_handler(qd_agent_request_t *request)
+{
+    qd_schema_entity_type_t  entity_type;
+    qd_field_iterator_t     *correlation_id;
+    qd_field_iterator_t     *reply_to;
+    qd_field_iterator_t     *name_iter;
+    qd_field_iterator_t     *identity_iter;
+    qd_parsed_field_t       *in_body;
+
+    qd_parse_agent_request(request, &entity_type, &correlation_id, &reply_to, &name_iter, &identity_iter, &in_body);
+
+    qdr_core_t *core = (qdr_core_t*)get_request_context(request);
+
+    qd_management_context_t *mgmt_ctx = qd_management_context(reply_to, correlation_id, 0, core, QD_SCHEMA_ENTITY_OPERATION_UPDATE, 0);
+
+    qdr_manage_update(core, mgmt_ctx, entity_type, name_iter, identity_iter, in_body, mgmt_ctx->out_body);
+}
+
+
+void qd_core_agent_delete_handler(qd_agent_request_t *request)
+{
+    qd_schema_entity_type_t  entity_type;
+    qd_field_iterator_t     *correlation_id;
+    qd_field_iterator_t     *reply_to;
+    qd_field_iterator_t     *name_iter;
+    qd_field_iterator_t     *identity_iter;
+    qd_parsed_field_t       *in_body;
+
+    qd_parse_agent_request(request, &entity_type, &correlation_id, &reply_to, &name_iter, &identity_iter, &in_body);
+
+    qdr_core_t *core = (qdr_core_t*)get_request_context(request);
+
+    // Set the callback function.
+    qdr_manage_handler(core, qd_manage_response_handler);
+
+    // Call local function that creates and returns a qd_management_context_t containing the values passed in.
+    qd_management_context_t *mgmt_ctx = qd_management_context(reply_to, correlation_id, 0, core, QD_SCHEMA_ENTITY_OPERATION_DELETE, 0);
+
+    qdr_manage_delete(core, mgmt_ctx, entity_type, name_iter, identity_iter);
+}

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/src/router_core/agent_core.c
----------------------------------------------------------------------
diff --git a/src/router_core/agent_core.c b/src/router_core/agent_core.c
index 272b75c..fb82fea 100644
--- a/src/router_core/agent_core.c
+++ b/src/router_core/agent_core.c
@@ -182,15 +182,15 @@ qdr_query_t *qdr_manage_query(qdr_core_t              *core,
     qdr_query_t* query = qdr_query(core, context, type, body);
 
     switch (query->entity_type) {
-    case QD_ROUTER_CONFIG_ADDRESS:    qdr_agent_set_columns(query, attribute_names, qdr_config_address_columns, QDR_CONFIG_ADDRESS_COLUMN_COUNT);  break;
-    case QD_ROUTER_CONFIG_LINK_ROUTE: qdr_agent_set_columns(query, attribute_names, qdr_config_link_route_columns, QDR_CONFIG_LINK_ROUTE_COLUMN_COUNT);  break;
-    case QD_ROUTER_CONFIG_AUTO_LINK:  qdr_agent_set_columns(query, attribute_names, qdr_config_auto_link_columns, QDR_CONFIG_AUTO_LINK_COLUMN_COUNT);  break;
-    case QD_ROUTER_CONNECTION:        break;
-    case QD_ROUTER_LINK:              qdr_agent_set_columns(query, attribute_names, qdr_link_columns, QDR_LINK_COLUMN_COUNT);  break;
-    case QD_ROUTER_ADDRESS:           qdr_agent_set_columns(query, attribute_names, qdr_address_columns, QDR_ADDRESS_COLUMN_COUNT); break;
-    case QD_ROUTER_FORBIDDEN:         break;
-    case QD_ROUTER_EXCHANGE:          break;
-    case QD_ROUTER_BINDING:           break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_ADDRESS:   qdr_agent_set_columns(query, attribute_names, qdr_config_address_columns, QDR_CONFIG_ADDRESS_COLUMN_COUNT);  break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_LINKROUTE: qdr_agent_set_columns(query, attribute_names, qdr_config_link_route_columns, QDR_CONFIG_LINK_ROUTE_COLUMN_COUNT);  break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_AUTOLINK:  qdr_agent_set_columns(query, attribute_names, qdr_config_auto_link_columns, QDR_CONFIG_AUTO_LINK_COLUMN_COUNT);  break;
+        case QD_SCHEMA_ENTITY_TYPE_CONNECTION:              break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_LINK:             qdr_agent_set_columns(query, attribute_names, qdr_link_columns, QDR_LINK_COLUMN_COUNT);  break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_ADDRESS:          qdr_agent_set_columns(query, attribute_names, qdr_address_columns, QDR_ADDRESS_COLUMN_COUNT); break;
+        default:
+            break;
+            //case QD_ROUTER_FORBIDDEN:         break;
     }
 
     return query;
@@ -200,15 +200,15 @@ qdr_query_t *qdr_manage_query(qdr_core_t              *core,
 void qdr_query_add_attribute_names(qdr_query_t *query)
 {
     switch (query->entity_type) {
-    case QD_ROUTER_CONFIG_ADDRESS:    qdr_agent_emit_columns(query, qdr_config_address_columns, QDR_CONFIG_ADDRESS_COLUMN_COUNT); break;
-    case QD_ROUTER_CONFIG_LINK_ROUTE: qdr_agent_emit_columns(query, qdr_config_link_route_columns, QDR_CONFIG_LINK_ROUTE_COLUMN_COUNT); break;
-    case QD_ROUTER_CONFIG_AUTO_LINK:  qdr_agent_emit_columns(query, qdr_config_auto_link_columns, QDR_CONFIG_AUTO_LINK_COLUMN_COUNT); break;
-    case QD_ROUTER_CONNECTION:        break;
-    case QD_ROUTER_LINK:              qdr_agent_emit_columns(query, qdr_link_columns, QDR_LINK_COLUMN_COUNT); break;
-    case QD_ROUTER_ADDRESS:           qdr_agent_emit_columns(query, qdr_address_columns, QDR_ADDRESS_COLUMN_COUNT); break;
-    case QD_ROUTER_FORBIDDEN:         qd_compose_empty_list(query->body); break;
-    case QD_ROUTER_EXCHANGE:          break;
-    case QD_ROUTER_BINDING:           break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_ADDRESS:   qdr_agent_emit_columns(query, qdr_config_address_columns, QDR_CONFIG_ADDRESS_COLUMN_COUNT); break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_LINKROUTE: qdr_agent_emit_columns(query, qdr_config_link_route_columns, QDR_CONFIG_LINK_ROUTE_COLUMN_COUNT); break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_AUTOLINK:  qdr_agent_emit_columns(query, qdr_config_auto_link_columns, QDR_CONFIG_AUTO_LINK_COLUMN_COUNT); break;
+        case QD_SCHEMA_ENTITY_TYPE_CONNECTION:              break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_LINK:             qdr_agent_emit_columns(query, qdr_link_columns, QDR_LINK_COLUMN_COUNT); break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_ADDRESS:          qdr_agent_emit_columns(query, qdr_address_columns, QDR_ADDRESS_COLUMN_COUNT); break;
+        default:
+            break;
+        //case QD_ROUTER_FORBIDDEN:         qd_compose_empty_list(query->body); break;
     }
 }
 
@@ -319,13 +319,13 @@ void qdr_agent_setup_CT(qdr_core_t *core)
 }
 
 
-static void qdr_agent_forbidden(qdr_core_t *core, qdr_query_t *query, bool op_query)
+/*static void qdr_agent_forbidden(qdr_core_t *core, qdr_query_t *query, bool op_query)
 {
     query->status = QD_AMQP_FORBIDDEN;
     if (query->body && !op_query)
         qd_compose_insert_null(query->body);
     qdr_agent_enqueue_response_CT(core, query);
-}
+}*/
 
 
 static void qdr_manage_read_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
@@ -335,15 +335,15 @@ static void qdr_manage_read_CT(qdr_core_t *core, qdr_action_t *action, bool disc
     qdr_query_t             *query      = action->args.agent.query;
 
     switch (query->entity_type) {
-    case QD_ROUTER_CONFIG_ADDRESS:    qdra_config_address_get_CT(core, name, identity, query, qdr_config_address_columns); break;
-    case QD_ROUTER_CONFIG_LINK_ROUTE: qdra_config_link_route_get_CT(core, name, identity, query, qdr_config_link_route_columns); break;
-    case QD_ROUTER_CONFIG_AUTO_LINK:  qdra_config_auto_link_get_CT(core, name, identity, query, qdr_config_auto_link_columns); break;
-    case QD_ROUTER_CONNECTION:        break;
-    case QD_ROUTER_LINK:              break;
-    case QD_ROUTER_ADDRESS:           qdra_address_get_CT(core, name, identity, query, qdr_address_columns); break;
-    case QD_ROUTER_FORBIDDEN:         qdr_agent_forbidden(core, query, false); break;
-    case QD_ROUTER_EXCHANGE:          break;
-    case QD_ROUTER_BINDING:           break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_ADDRESS:   qdra_config_address_get_CT(core, name, identity, query, qdr_config_address_columns); break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_LINKROUTE: qdra_config_link_route_get_CT(core, name, identity, query, qdr_config_link_route_columns); break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_AUTOLINK:  qdra_config_auto_link_get_CT(core, name, identity, query, qdr_config_auto_link_columns); break;
+        case QD_SCHEMA_ENTITY_TYPE_CONNECTION:              break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_LINK:             break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_ADDRESS:          qdra_address_get_CT(core, name, identity, query, qdr_address_columns); break;
+        default:
+            break;
+        //case QD_ROUTER_FORBIDDEN:                         qdr_agent_forbidden(core, query, false); break;
    }
 }
 
@@ -355,16 +355,15 @@ static void qdr_manage_create_CT(qdr_core_t *core, qdr_action_t *action, bool di
     qd_parsed_field_t       *in_body    = action->args.agent.in_body;
 
     switch (query->entity_type) {
-    case QD_ROUTER_CONFIG_ADDRESS:    qdra_config_address_create_CT(core, name, query, in_body); break;
-    case QD_ROUTER_CONFIG_LINK_ROUTE: qdra_config_link_route_create_CT(core, name, query, in_body); break;
-    case QD_ROUTER_CONFIG_AUTO_LINK:  qdra_config_auto_link_create_CT(core, name, query, in_body); break;
-    case QD_ROUTER_CONNECTION:        break;
-    case QD_ROUTER_LINK:              break;
-    case QD_ROUTER_ADDRESS:           break;
-    case QD_ROUTER_FORBIDDEN:         qdr_agent_forbidden(core, query, false); break;
-    case QD_ROUTER_EXCHANGE:          break;
-    case QD_ROUTER_BINDING:           break;
-
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_ADDRESS:                      qdra_config_address_create_CT(core, name, query, in_body); break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_LINKROUTE: qdra_config_link_route_create_CT(core, name, query, in_body); break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_AUTOLINK:  qdra_config_auto_link_create_CT(core, name, query, in_body); break;
+        case QD_SCHEMA_ENTITY_TYPE_CONNECTION:              break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_LINK:             break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_ADDRESS:          break;
+        default:
+            break;
+        //case QD_ROUTER_FORBIDDEN:                         qdr_agent_forbidden(core, query, false); break;
    }
 
    qd_parse_free(in_body);
@@ -378,15 +377,15 @@ static void qdr_manage_delete_CT(qdr_core_t *core, qdr_action_t *action, bool di
     qdr_query_t             *query      = action->args.agent.query;
 
     switch (query->entity_type) {
-    case QD_ROUTER_CONFIG_ADDRESS:    qdra_config_address_delete_CT(core, query, name, identity); break;
-    case QD_ROUTER_CONFIG_LINK_ROUTE: qdra_config_link_route_delete_CT(core, query, name, identity); break;
-    case QD_ROUTER_CONFIG_AUTO_LINK:  qdra_config_auto_link_delete_CT(core, query, name, identity); break;
-    case QD_ROUTER_CONNECTION:        break;
-    case QD_ROUTER_LINK:              break;
-    case QD_ROUTER_ADDRESS:           break;
-    case QD_ROUTER_FORBIDDEN:         qdr_agent_forbidden(core, query, false); break;
-    case QD_ROUTER_EXCHANGE:          break;
-    case QD_ROUTER_BINDING:           break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_ADDRESS:                      qdra_config_address_delete_CT(core, query, name, identity); break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_LINKROUTE: qdra_config_link_route_delete_CT(core, query, name, identity); break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_AUTOLINK:  qdra_config_auto_link_delete_CT(core, query, name, identity); break;
+        case QD_SCHEMA_ENTITY_TYPE_CONNECTION:              break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_LINK:             break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_ADDRESS:          break;
+        default:
+            break;
+        //case QD_ROUTER_FORBIDDEN:                         qdr_agent_forbidden(core, query, false); break;
    }
 }
 
@@ -398,23 +397,21 @@ static void qdr_manage_update_CT(qdr_core_t *core, qdr_action_t *action, bool di
     qd_parsed_field_t       *in_body    = action->args.agent.in_body;
 
     switch (query->entity_type) {
-    case QD_ROUTER_CONFIG_ADDRESS:    break;
-    case QD_ROUTER_CONFIG_LINK_ROUTE: break;
-    case QD_ROUTER_CONFIG_AUTO_LINK:  break;
-    case QD_ROUTER_CONNECTION:        break;
-    case QD_ROUTER_LINK:              qdra_link_update_CT(core, name, identity, query, in_body); break;
-    case QD_ROUTER_ADDRESS:           break;
-    case QD_ROUTER_FORBIDDEN:         qdr_agent_forbidden(core, query, false); break;
-    case QD_ROUTER_EXCHANGE:          break;
-    case QD_ROUTER_BINDING:           break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_ADDRESS:                      break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_LINKROUTE: break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_AUTOLINK:  break;
+        case QD_SCHEMA_ENTITY_TYPE_CONNECTION:              break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_LINK:             qdra_link_update_CT(core, name, identity, query, in_body); break;
+        case QD_SCHEMA_ENTITY_TYPE_ROUTER_ADDRESS:          break;
+        default:
+            break;
+        //case QD_ROUTER_FORBIDDEN:                         qdr_agent_forbidden(core, query, false); break;
    }
 
     qd_parse_free(in_body);
 }
 
 
-
-
 static void qdrh_query_get_first_CT(qdr_core_t *core, qdr_action_t *action, bool discard)
 {
     qdr_query_t *query  = action->args.agent.query;
@@ -422,15 +419,15 @@ static void qdrh_query_get_first_CT(qdr_core_t *core, qdr_action_t *action, bool
 
     if (!discard) {
         switch (query->entity_type) {
-        case QD_ROUTER_CONFIG_ADDRESS:    qdra_config_address_get_first_CT(core, query, offset); break;
-        case QD_ROUTER_CONFIG_LINK_ROUTE: qdra_config_link_route_get_first_CT(core, query, offset); break;
-        case QD_ROUTER_CONFIG_AUTO_LINK:  qdra_config_auto_link_get_first_CT(core, query, offset); break;
-        case QD_ROUTER_CONNECTION:        break;
-        case QD_ROUTER_LINK:              qdra_link_get_first_CT(core, query, offset); break;
-        case QD_ROUTER_ADDRESS:           qdra_address_get_first_CT(core, query, offset); break;
-        case QD_ROUTER_FORBIDDEN:         qdr_agent_forbidden(core, query, true); break;
-        case QD_ROUTER_EXCHANGE:          break;
-        case QD_ROUTER_BINDING:           break;
+            case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_ADDRESS:   qdra_config_address_get_first_CT(core, query, offset); break;
+            case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_LINKROUTE: qdra_config_link_route_get_first_CT(core, query, offset); break;
+            case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_AUTOLINK:  qdra_config_auto_link_get_first_CT(core, query, offset); break;
+            case QD_SCHEMA_ENTITY_TYPE_CONNECTION:              break;
+            case QD_SCHEMA_ENTITY_TYPE_ROUTER_LINK:             qdra_link_get_first_CT(core, query, offset); break;
+            case QD_SCHEMA_ENTITY_TYPE_ROUTER_ADDRESS:          qdra_address_get_first_CT(core, query, offset); break;
+            default:
+                break;
+            //case QD_ROUTER_FORBIDDEN:         qdr_agent_forbidden(core, query, true); break;
         }
     }
 }
@@ -442,15 +439,14 @@ static void qdrh_query_get_next_CT(qdr_core_t *core, qdr_action_t *action, bool
 
     if (!discard) {
         switch (query->entity_type) {
-        case QD_ROUTER_CONFIG_ADDRESS:    qdra_config_address_get_next_CT(core, query); break;
-        case QD_ROUTER_CONFIG_LINK_ROUTE: qdra_config_link_route_get_next_CT(core, query); break;
-        case QD_ROUTER_CONFIG_AUTO_LINK:  qdra_config_auto_link_get_next_CT(core, query); break;
-        case QD_ROUTER_CONNECTION:        break;
-        case QD_ROUTER_LINK:              qdra_link_get_next_CT(core, query); break;
-        case QD_ROUTER_ADDRESS:           qdra_address_get_next_CT(core, query); break;
-        case QD_ROUTER_FORBIDDEN:         break;
-        case QD_ROUTER_EXCHANGE:          break;
-        case QD_ROUTER_BINDING:           break;
+            case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_ADDRESS:   qdra_config_address_get_next_CT(core, query); break;
+            case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_LINKROUTE: qdra_config_link_route_get_next_CT(core, query); break;
+            case QD_SCHEMA_ENTITY_TYPE_ROUTER_CONFIG_AUTOLINK:  qdra_config_auto_link_get_next_CT(core, query); break;
+            case QD_SCHEMA_ENTITY_TYPE_CONNECTION:              break;
+            case QD_SCHEMA_ENTITY_TYPE_ROUTER_LINK:             qdra_link_get_next_CT(core, query); break;
+            case QD_SCHEMA_ENTITY_TYPE_ROUTER_ADDRESS:          qdra_address_get_next_CT(core, query); break;
+            default:
+                break;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/src/router_core/management_agent.c
----------------------------------------------------------------------
diff --git a/src/router_core/management_agent.c b/src/router_core/management_agent.c
deleted file mode 100644
index b641676..0000000
--- a/src/router_core/management_agent.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <stdio.h>
-#include <qpid/dispatch/parse.h>
-#include <qpid/dispatch/iterator.h>
-#include <qpid/dispatch/router.h>
-#include <qpid/dispatch/router_core.h>
-#include <qpid/dispatch/compose.h>
-#include <qpid/dispatch/dispatch.h>
-#include "router_core_private.h"
-#include "dispatch_private.h"
-#include "agent_link.h"
-#include "schema_enum.h"
-#include "alloc.h"
-
-const char *ENTITY = "entityType";
-const char *TYPE = "type";
-const char *COUNT = "count";
-const char *OFFSET = "offset";
-const char *NAME = "name";
-const char *IDENTITY = "identity";
-
-
-const char *OPERATION = "operation";
-const char *ATTRIBUTE_NAMES = "attributeNames";
-
-const unsigned char *config_address_entity_type = (unsigned char*) "org.apache.qpid.dispatch.router.config.address";
-const unsigned char *link_route_entity_type     = (unsigned char*) "org.apache.qpid.dispatch.router.config.linkRoute";
-const unsigned char *auto_link_entity_type      = (unsigned char*) "org.apache.qpid.dispatch.router.config.autoLink";
-const unsigned char *address_entity_type        = (unsigned char*) "org.apache.qpid.dispatch.router.address";
-const unsigned char *link_entity_type           = (unsigned char*) "org.apache.qpid.dispatch.router.link";
-const unsigned char *console_entity_type        = (unsigned char*) "org.apache.qpid.dispatch.console";
-
-const char * const status_description = "statusDescription";
-const char * const correlation_id = "correlation-id";
-const char * const results = "results";
-const char * const status_code = "statusCode";
-
-const char * MANAGEMENT_INTERNAL = "_local/$_management_internal";
-
-//TODO - Move these to amqp.h
-const unsigned char *MANAGEMENT_QUERY  = (unsigned char*) "QUERY";
-const unsigned char *MANAGEMENT_CREATE = (unsigned char*) "CREATE";
-const unsigned char *MANAGEMENT_READ   = (unsigned char*) "READ";
-const unsigned char *MANAGEMENT_UPDATE = (unsigned char*) "UPDATE";
-const unsigned char *MANAGEMENT_DELETE = (unsigned char*) "DELETE";
-
-typedef struct qd_management_context_t {
-    qd_message_t                *response;
-    qd_composed_field_t         *out_body;
-    qd_field_iterator_t         *reply_to;
-    qd_field_iterator_t         *correlation_id;
-    qdr_query_t                 *query;
-    qdr_core_t                  *core;
-    int                          count;
-    int                          current_count;
-    qd_schema_entity_operation_t operation_type;
-} qd_management_context_t ;
-
-ALLOC_DECLARE(qd_management_context_t);
-ALLOC_DEFINE(qd_management_context_t);
-
-/**
- * Convenience function to create and initialize context (qd_management_context_t)
- */
-static qd_management_context_t* qd_management_context(qd_field_iterator_t          *reply_to,
-                                                      qd_field_iterator_t          *correlation_id,
-                                                      qdr_query_t                  *query,
-                                                      qdr_core_t                   *core,
-                                                      qd_schema_entity_operation_t operation_type,
-                                                      int                          count)
-{
-    qd_management_context_t *ctx = new_qd_management_context_t();
-    ctx->response       = qd_message();
-    ctx->out_body       = qd_compose(QD_PERFORMATIVE_BODY_AMQP_VALUE, 0);
-    ctx->reply_to       = reply_to;
-    ctx->correlation_id = correlation_id;
-    ctx->query          = query;
-    ctx->core           = core;
-    ctx->count          = count;
-    ctx->current_count  = 0;
-    ctx->operation_type = operation_type;
-
-    return ctx;
-}
-
-
-/**
- * Sets the error status on a new composed field.
- */
-static void qd_set_response_status(const qd_amqp_error_t *error, qd_composed_field_t **field)
-{
-    //
-    // Insert appropriate success or error
-    //
-    *field = qd_compose(QD_PERFORMATIVE_APPLICATION_PROPERTIES, *field);
-    qd_compose_start_map(*field);
-
-    qd_compose_insert_string(*field, status_description);
-    qd_compose_insert_string(*field, error->description);
-
-    qd_compose_insert_string(*field, status_code);
-    qd_compose_insert_uint(*field, error->status);
-
-    qd_compose_end_map(*field);
-}
-
-
-static void qd_set_properties(qd_field_iterator_t *correlation_id,
-                              qd_field_iterator_t *reply_to,
-                              qd_composed_field_t **fld)
-{
-    // Set the correlation_id and reply_to on fld
-    *fld = qd_compose(QD_PERFORMATIVE_PROPERTIES, 0);
-    qd_compose_start_list(*fld);
-    qd_compose_insert_null(*fld);                           // message-id
-    qd_compose_insert_null(*fld);                           // user-id
-    qd_compose_insert_string_iterator(*fld, reply_to);     // to
-    qd_compose_insert_null(*fld);                           // subject
-    qd_compose_insert_null(*fld);
-    qd_compose_insert_typed_iterator(*fld, correlation_id);
-    qd_compose_end_list(*fld);
-    qd_field_iterator_free(correlation_id);
-}
-
-
-static void qd_manage_response_handler(void *context, const qd_amqp_error_t *status, bool more)
-{
-    qd_management_context_t *mgmt_ctx = (qd_management_context_t*) context;
-
-    if (mgmt_ctx->operation_type == QD_SCHEMA_ENTITY_OPERATION_QUERY) {
-        if (status->status / 100 == 2) { // There is no error, proceed to conditionally call get_next
-            if (more) {
-               mgmt_ctx->current_count++; // Increment how many you have at hand
-               if (mgmt_ctx->count != mgmt_ctx->current_count) {
-                   qdr_query_get_next(mgmt_ctx->query);
-                   return;
-               } else
-                   //
-                   // This is the one case where the core agent won't free the query itself.
-                   //
-                   qdr_query_free(mgmt_ctx->query);
-            }
-        }
-        qd_compose_end_list(mgmt_ctx->out_body);
-        qd_compose_end_map(mgmt_ctx->out_body);
-    }
-    else if (mgmt_ctx->operation_type == QD_SCHEMA_ENTITY_OPERATION_DELETE) {
-        // The body of the delete response message MUST consist of an amqp-value section containing a Map with zero entries.
-        qd_compose_start_map(mgmt_ctx->out_body);
-        qd_compose_end_map(mgmt_ctx->out_body);
-    }
-    else if (mgmt_ctx->operation_type == QD_SCHEMA_ENTITY_OPERATION_READ) {
-        if (status->status / 100 != 2) {
-            qd_compose_start_map(mgmt_ctx->out_body);
-            qd_compose_end_map(mgmt_ctx->out_body);
-        }
-    }
-
-    qd_field_iterator_t *reply_to = 0;
-    qd_composed_field_t *fld = 0;
-
-    // Start composing the message.
-    // First set the properties on the message like reply_to, correlation-id etc.
-    qd_set_properties(mgmt_ctx->correlation_id, mgmt_ctx->reply_to, &fld);
-
-    // Second, set the status on the message, QD_AMQP_OK or QD_AMQP_BAD_REQUEST and so on.
-    qd_set_response_status(status, &fld);
-
-    // Finally, compose and send the message.
-    qd_message_compose_3(mgmt_ctx->response, fld, mgmt_ctx->out_body);
-    qdr_send_to1(mgmt_ctx->core, mgmt_ctx->response, reply_to, true, false);
-
-    // We have come to the very end. Free the appropriate memory.
-    // Just go over this with Ted to see if I freed everything.
-
-    qd_field_iterator_free(reply_to);
-    qd_compose_free(fld);
-
-    qd_message_free(mgmt_ctx->response);
-    qd_compose_free(mgmt_ctx->out_body);
-
-    free_qd_management_context_t(mgmt_ctx);
-}
-
-// ----------------------------------------------------------------------------------------
-//----------------------- CORE HANDLERS ---------------------------------------------------
-// ----------------------------------------------------------------------------------------
-
-void qd_core_agent_query_handler(void                       *ctx,
-                                 qd_field_iterator_t        *reply_to,
-                                 qd_field_iterator_t        *correlation_id,
-                                 qd_router_entity_type_t     entity_type,
-                                 qd_schema_entity_operation_t  operation_type,
-                                 int                        *count,
-                                 int                        *offset,
-                                 qd_parsed_field_t          *in_body)
-{
-    qdr_core_t *core = (qdr_core_t*)ctx;
-
-    // Call local function that creates and returns a local qd_management_context_t object containing the values passed in.
-    qd_management_context_t *mgmt_ctx = qd_management_context(reply_to, correlation_id, 0, core, operation_type, (*count));
-
-    //
-    // Add the Body.
-    //
-    qd_composed_field_t *field = mgmt_ctx->out_body;
-
-    // Start a map in the body. Look for the end map in the callback function, qd_manage_response_handler.
-    qd_compose_start_map(field);
-
-    //add a "attributeNames" key
-    qd_compose_insert_string(field, ATTRIBUTE_NAMES);
-
-    // Grab the attribute names from the incoming message body. The attribute names will be used later on in the response.
-    qd_parsed_field_t *attribute_names_parsed_field = 0;
-
-    if (in_body != 0 && qd_parse_is_map(in_body)) {
-        attribute_names_parsed_field = qd_parse_value_by_key(in_body, ATTRIBUTE_NAMES);
-    }
-
-    // Set the callback function.
-    qdr_manage_handler(core, qd_manage_response_handler);
-    mgmt_ctx->query = qdr_manage_query(core, mgmt_ctx, entity_type, attribute_names_parsed_field, field);
-
-    //Add the attribute names
-    qdr_query_add_attribute_names(mgmt_ctx->query); //this adds a list of attribute names like ["attribute1", "attribute2", "attribute3", "attribute4",]
-    qd_compose_insert_string(field, results); //add a "results" key
-    qd_compose_start_list(field); //start the list for results
-
-    qdr_query_get_first(mgmt_ctx->query, (*offset));
-
-    qd_parse_free(in_body);
-}
-
-
-void qd_core_agent_read_handler(void                       *ctx,
-                                qd_field_iterator_t        *reply_to,
-                                qd_field_iterator_t        *correlation_id,
-                                qd_router_entity_type_t     entity_type,
-                                qd_schema_entity_operation_t  operation_type,
-                                qd_field_iterator_t        *identity_iter,
-                                qd_field_iterator_t        *name_iter)
-{
-    qdr_core_t *core = (qdr_core_t*)ctx;
-
-    // Set the callback function.
-    qdr_manage_handler(core, qd_manage_response_handler);
-
-    // Call local function that creates and returns a qd_management_context_t containing the values passed in.
-    qd_management_context_t *mgmt_ctx = qd_management_context(reply_to, correlation_id, 0, core, operation_type, 0);
-
-    //Call the read API function
-    qdr_manage_read(core, mgmt_ctx, entity_type, name_iter, identity_iter, mgmt_ctx->out_body);
-}
-
-
-void qd_core_agent_create_handler(void                       *ctx,
-                                  qd_field_iterator_t        *reply_to,
-                                  qd_field_iterator_t        *correlation_id,
-                                  qd_router_entity_type_t     entity_type,
-                                  qd_schema_entity_operation_t  operation_type,
-                                  qd_field_iterator_t        *name_iter,
-                                  qd_parsed_field_t          *in_body)
-{
-    qdr_core_t *core = (qdr_core_t*)ctx;
-    // Set the callback function.
-    qdr_manage_handler(core, qd_manage_response_handler);
-
-    // Call local function that creates and returns a qd_management_context_t containing the values passed in.
-    qd_management_context_t *mgmt_ctx = qd_management_context(reply_to, correlation_id, 0, core, operation_type, 0);
-
-    qdr_manage_create(core, mgmt_ctx, entity_type, name_iter, in_body, mgmt_ctx->out_body);
-
-}
-
-
-void qd_core_agent_update_handler(void                         *ctx,
-                                  qd_field_iterator_t          *reply_to,
-                                  qd_field_iterator_t          *correlation_id,
-                                  qd_router_entity_type_t       entity_type,
-                                  qd_schema_entity_operation_t  operation_type,
-                                  qd_field_iterator_t         *identity_iter,
-                                  qd_field_iterator_t         *name_iter,
-                                  qd_parsed_field_t           *in_body)
-{
-    qdr_core_t *core = (qdr_core_t*)ctx;
-
-    // Set the callback function.
-    qdr_manage_handler(core, qd_manage_response_handler);
-
-    qd_management_context_t *mgmt_ctx = qd_management_context(reply_to, correlation_id, 0, core, operation_type, 0);
-
-    qdr_manage_update(core, mgmt_ctx, entity_type, name_iter, identity_iter, in_body, mgmt_ctx->out_body);
-}
-
-
-void qd_core_agent_delete_handler(void                         *ctx,
-                                  qd_field_iterator_t          *reply_to,
-                                  qd_field_iterator_t          *correlation_id,
-                                  qd_message_t                 *msg,
-                                  qd_router_entity_type_t       entity_type,
-                                  qd_schema_entity_operation_t  operation_type,
-                                  qd_field_iterator_t          *identity_iter,
-                                  qd_field_iterator_t          *name_iter)
-{
-    qdr_core_t *core = (qdr_core_t*)ctx;
-
-    // Set the callback function.
-    qdr_manage_handler(core, qd_manage_response_handler);
-
-    // Call local function that creates and returns a qd_management_context_t containing the values passed in.
-    qd_management_context_t *mgmt_ctx = qd_management_context(reply_to, correlation_id, 0, core, operation_type, 0);
-
-    qdr_manage_delete(core, mgmt_ctx, entity_type, name_iter, identity_iter);
-}

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/60eb8212/src/router_core/router_core_private.h
----------------------------------------------------------------------
diff --git a/src/router_core/router_core_private.h b/src/router_core/router_core_private.h
index a59abb5..e14fade 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -154,7 +154,7 @@ DEQ_DECLARE(qdr_action_t, qdr_action_list_t);
 struct qdr_query_t {
     DEQ_LINKS(qdr_query_t);
     qdr_core_t              *core;
-    qd_router_entity_type_t  entity_type;
+    qd_schema_entity_type_t  entity_type;
     void                    *context;
     int                      columns[QDR_AGENT_MAX_COLUMNS];
     qd_composed_field_t     *body;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message