qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gmur...@apache.org
Subject [1/9] qpid-dispatch git commit: DISPATCH-437 - Work in progress - Moved some of the code over from config.py to a new class called ManagementAgent
Date Thu, 11 Aug 2016 17:42:54 GMT
Repository: qpid-dispatch
Updated Branches:
  refs/heads/DISPATCH-437-1 2bcb2f766 -> 60eb82121


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/python/qpid_dispatch_internal/management/schema/schema.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/schema/schema.py b/python/qpid_dispatch_internal/management/schema/schema.py
new file mode 100644
index 0000000..6f68f29
--- /dev/null
+++ b/python/qpid_dispatch_internal/management/schema/schema.py
@@ -0,0 +1,700 @@
+##
+## 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.
+
+Schema validation will validate and transform values, add default values and
+check for uniqueness of enties/attributes that are specified to be unique.
+
+A Schema can be loaded/dumped to a json file.
+"""
+
+import sys
+from qpid_dispatch.management.entity import EntityBase
+from qpid_dispatch.management.error import NotImplementedStatus
+from ...compat import OrderedDict, JSON_LOAD_KWARGS
+import json
+from pkgutil import get_data
+
+from python.qpid_dispatch_internal.management.schema import schema
+
+
+class ValidationError(Exception):
+    """Error raised if schema validation fails"""
+    pass
+
+def quotestr(value, quote="'"):
+    """Quote value if it is a string type, str() it if not """
+    if isinstance(value, basestring): return "'%s'" % value
+    else: return str(value)
+
+
+class Type(object):
+    """Base class for schema types.
+
+    @ivar name: The type name.
+    @ivar pytype: The python type for this schema type.
+    """
+    def __init__(self, name, pytype):
+        """
+        @param name: The type name.
+        @param pytype: The python type for this schema type.
+        """
+        self.name, self.pytype = name, pytype
+
+    def validate(self, value, **kwargs): # pylint: disable=unused-argument
+        """
+        Convert value to the correct python type.
+
+        @param kwargs: See L{Schema.validate_all}
+        """
+        return self.pytype(value)
+
+    def dump(self):
+        """
+        @return: Representation of the type to dump to json. Normally the type name,
+            EnumType.dump is the exception.
+        """
+        return self.name
+
+    def __str__(self):
+        """String name of type."""
+        return str(self.dump())
+
+
+class BooleanType(Type):
+    """A boolean schema type"""
+
+    def __init__(self):
+        super(BooleanType, self).__init__("boolean", bool)
+
+    VALUES = {"yes":1, "true":1, "on":1, "no":0, "false":0, "off":0}
+
+    def validate(self, value, **kwargs):
+        """
+        @param value: A string such as "yes", "false" etc. is converted appropriately.
+            Any other type is converted using python's bool()
+        @param kwargs: See L{Schema.validate_all}
+        @return A python bool.
+        """
+        try:
+            if isinstance(value, basestring):
+                return self.VALUES[value.lower()]
+            return bool(value)
+        except:
+            raise ValidationError("Invalid Boolean value '%r'"%value)
+
+
+class EnumValue(str):
+    """A string that convets to an integer value via int()"""
+
+    def __new__(cls, name, value):
+        s = super(EnumValue, cls).__new__(cls, name)
+        setattr(s, 'value', value)
+        return s
+
+    def __int__(self): return self.value
+    def __eq__(self, x): return str(self) == x or int(self) == x
+    def __ne__(self, x): return not self == x
+    def __repr__(self): return "EnumValue('%s', %s)"%(str(self), int(self))
+
+
+class EnumType(Type):
+    """An enumerated type"""
+
+    def __init__(self, tags):
+        """
+        @param tags: A list of string values for the enumerated type.
+        """
+        assert isinstance(tags, list)
+        super(EnumType, self).__init__("enum%s"%([str(t) for t in tags]), int)
+        self.tags = tags
+
+    def validate(self, value, **kwargs):
+        """
+        @param value: May be a string from the set of enum tag strings or anything
+            that can convert to an int - in which case it must be in the enum range.
+        @param kwargs: See L{Schema.validate_all}
+        @return: An EnumValue.
+        """
+        if value in self.tags:
+            return EnumValue(value, self.tags.index(value))
+        else:
+            try:
+                i = int(value)
+                return EnumValue(self.tags[i], i)
+            except (ValueError, IndexError):
+                pass
+        raise ValidationError("Invalid value for %s: %r"%(self.name, value))
+
+    def dump(self):
+        """
+        @return: A list of the enum tags.
+        """
+        return self.tags
+
+    def __str__(self):
+        """String description of enum type."""
+        return "One of [%s]" % ', '.join([quotestr(tag) for tag in self.tags])
+
+BUILTIN_TYPES = OrderedDict(
+    (t.name, t) for t in [Type("string", str),
+                          Type("path", str),
+                          Type("entityId", str),
+                          Type("integer", int),
+                          Type("list", list),
+                          Type("map", dict),
+                          Type("dict", dict),
+                          BooleanType()])
+
+def get_type(rep):
+    """
+    Get a schema type.
+    @param rep: json representation of the type.
+    """
+    if isinstance(rep, list):
+        return EnumType(rep)
+    if rep in BUILTIN_TYPES:
+        return BUILTIN_TYPES[rep]
+    raise ValidationError("No such schema type: %s" % rep)
+
+def _dump_dict(items):
+    """
+    Remove all items with None value from a mapping.
+    @return: Map of non-None items.
+    """
+    return OrderedDict((k, v) for k, v in items if v)
+
+def _is_unique(found, item):
+    """
+    Return true if found is None or item is not in found (adds item to found.)
+    Return false if item is in found.
+    """
+    if found is None or found is False:
+        return True
+    if item not in found:
+        found.add(item)
+        return True
+    return False
+
+class AttributeType(object):
+    """
+    Definition of an attribute.
+
+    @ivar name: Attribute name.
+    @ivar atype: Attribute L{Type}
+    @ivar required: True if the attribute is required.
+    @ivar default: Default value for the attribute or None if no default. Can be a reference.
+    @ivar value: Fixed value for the attribute. Can be a reference.
+    @ivar unique: True if the attribute value is unique.
+    @ivar description: Description of the attribute type.
+    @ivar defined_in: EntityType in which this attribute is defined.
+    @ivar create: If true the attribute can be set by CREATE.
+    @ivar update: If true the attribute can be modified by UPDATE.
+    @ivar graph: If true the attribute could be graphed by a console.
+    """
+
+    def __init__(self, name, type=None, defined_in=None, default=None,
+                 required=False, unique=False, hidden=False, deprecated=False,
+                 value=None, description="", create=False, update=False, graph=False, ordinality=0):
+        """
+        See L{AttributeType} instance variables.
+        """
+        try:
+            self.name = name
+            self.type = type
+            self.defined_in = defined_in
+            self.atype = get_type(self.type)
+            self.required = required
+            self.hidden = hidden
+            self.deprecated = deprecated
+            self.default = default
+            self.value = value
+            self.unique = unique
+            self.description = description
+            self.ordinality = ordinality
+            if self.value is not None and self.default is not None:
+                raise ValidationError("Attribute '%s' has default value and fixed value" %
+                                      self.name)
+            self.create=create
+            self.update=update
+            self.graph=graph
+        except:
+            ex, msg, trace = sys.exc_info()
+            raise ValidationError, "Attribute '%s': %s" % (name, msg), trace
+
+    def missing_value(self, check_required=True, add_default=True, **kwargs):
+        """
+        Fill in missing default and fixed values.
+        @keyword check_required: Raise an exception if required attributes are misssing.
+        @keyword add_default:  Add a default value for missing attributes.
+        @param kwargs: See L{Schema.validate_all}
+        """
+        if self.value is not None: # Fixed value attribute
+            return self.value
+        if add_default and self.default is not None:
+            return self.default
+        if check_required and self.required:
+            raise ValidationError("Missing required attribute '%s'" % (self.name))
+
+    def validate(self, value, check_unique=None, **kwargs):
+        """
+        Validate value for this attribute definition.
+        @param value: The value to validate.
+        @keyword check_unique: set of (name, value) to check for attribute uniqueness.
+            None means don't check for uniqueness.
+        @param create: if true, check that the attribute allows create
+        @param update: if true, check that the attribute allows update
+        @param kwargs: See L{Schema.validate_all}
+        @return: value converted to the correct python type. Rais exception if any check fails.
+        """
+        if self.unique and not _is_unique(check_unique, (self.name, value)):
+            raise ValidationError("Duplicate value '%s' for unique attribute '%s'"%(value, self.name))
+        if self.value and value != self.value:
+            raise ValidationError("Attribute '%s' has fixed value '%s' but given '%s'"%(
+                self.name, self.value, value))
+        try:
+            return self.atype.validate(value, **kwargs)
+        except (TypeError, ValueError), e:
+            raise ValidationError, str(e), sys.exc_info()[2]
+
+    def dump(self):
+        """
+        @return: Json-friendly representation of an attribute type
+        """
+        return _dump_dict([
+            ('type', self.atype.dump()),
+            ('default', self.default),
+            ('required', self.required),
+            ('unique', self.unique),
+            ('deprecated', self.deprecated),
+            ('description', self.description),
+            ('graph', self.graph)
+        ])
+
+    def __str__(self):
+        return self.name
+
+
+class MessageDef(object):
+    """A request or response message"""
+    def __init__(self, body=None, properties=None):
+        self.body = None
+        if body: self.body = AttributeType("body", **body)
+        self.properties = dict((name, AttributeType(name, **value))
+                               for name, value in (properties or {}).iteritems())
+
+
+class OperationDef(object):
+    """An operation definition"""
+    def __init__(self, name, description=None, request=None, response=None):
+        try:
+            self.name = name
+            self.description = description
+            self.request = self.response = None
+            if request: self.request = MessageDef(**request)
+            if response: self.response = MessageDef(**response)
+        except:
+            ex, msg, trace = sys.exc_info()
+            raise ValidationError, "Operation '%s': %s" % (name, msg), trace
+
+
+class EntityType(object):
+    """
+    An entity type defines a set of attributes for an entity.
+
+    @ivar name: Fully qualified entity type name.
+    @ivar short_name: Un-prefixed short name.
+    @ivar attributes: Map of L{AttributeType} for entity.
+    @ivar singleton: If true only one entity of this type is allowed.
+    @ivar referential: True if an entity can be referred to by name from another entity.
+    """
+    def __init__(self, name, schema, attributes=None, operations=None, operationDefs=None, description="",
+                 fullName=True, singleton=False, deprecated=False, extends=None, referential=False, ordinality=0, **kwargs):
+        """
+        @param name: name of the entity type.
+        @param schema: schema for this type.
+        @param singleton: True if entity type is a singleton.
+        @param attributes: Map of attributes {name: {type:, default:, required:, unique:}}
+        @param description: Human readable description.
+        @param operations: Allowed operations, list of operation names.
+        """
+        try:
+            self.schema = schema
+            self.description = description
+            if fullName:
+                self.name = schema.long_name(name)
+                self.short_name = schema.short_name(name)
+
+                if self.short_name.startswith("router.config."):
+                    self.short_name = self.short_name.replace("router.config.", "")
+            else:
+                self.name = self.short_name = name
+
+            self.attributes = OrderedDict((k, AttributeType(k, defined_in=self, **v))
+                                          for k, v in (attributes or {}).iteritems())
+            self.operations = operations or []
+            # Bases are resolved in self.init()
+            self.base = extends
+            self.all_bases = []
+
+            self.references = []
+            self.singleton = singleton
+            self.deprecated = deprecated
+            self.referential = referential
+            self.ordinality = ordinality
+            self._init = False      # Have not yet initialized from base and attributes.
+            # Operation definitions
+            self.operation_defs = dict((name, OperationDef(name, **op))
+                                  for name, op in (operationDefs or {}).iteritems())
+        except:
+            ex, msg, trace = sys.exc_info()
+            raise ValidationError, "%s '%s': %s" % (type(self).__name__, name, msg), trace
+
+    def init(self):
+        """Find bases after all types are loaded."""
+        if self._init: return
+        self._init = True
+        if self.base:
+            self.base = self.schema.entity_type(self.base)
+            self.base.init()
+            self.all_bases = [self.base] + self.base.all_bases
+            self._extend(self.base, 'extend')
+
+    def _extend(self, other, how):
+        """Add attributes and operations from other"""
+        def check(a, b, what):
+            overlap = set(a) & set(b)
+            if overlap:
+                raise ValidationError("'%s' cannot %s '%s', re-defines %s: %s"
+                                      % (self.name, how, other.short_name, what, ",".join(overlap)))
+        check(self.operations, other.operations, "operations")
+        self.operations += other.operations
+        check(self.attributes.iterkeys(), other.attributes.itervalues(), "attributes")
+        self.attributes.update(other.attributes)
+
+        if other.name == 'entity':
+            # Fill in entity "type" attribute automatically.
+            self.attributes["type"]["value"] = self.name
+
+        ordinality = 0
+        for attrib in self.attributes.values():
+            attrib.ordinality = ordinality
+            ordinality += 1
+
+    def extends(self, base):
+        return base in self.all_bases
+
+    def is_a(self, type):
+        return type == self or self.extends(type)
+
+    def attribute(self, name):
+        """Get the AttributeType for name"""
+        if not name in self.attributes:
+            raise ValidationError("Unknown attribute '%s' for '%s'" % (name, self))
+        return self.attributes[name]
+
+    @property
+    def my_attributes(self):
+        """Return only attribute types defined in this entity type"""
+        return [a for a in self.attributes.itervalues() if a.defined_in == self]
+
+    def validate(self, attributes, check_singleton=None, **kwargs):
+        """
+        Validate attributes for entity type.
+        @param attributes: Map attributes name:value or Entity with attributes property.
+            Modifies attributes: adds defaults, converts values.
+        @param check_singleton: set of entity-type name to enable singleton checking.
+            None to disable.
+        @param kwargs: See L{Schema.validate_all}
+        """
+
+        if isinstance(attributes, SchemaEntity): attributes = attributes.attributes
+
+        if self.singleton and not _is_unique(check_singleton, self.name):
+            raise ValidationError("Multiple instances of singleton '%s'"%self.name)
+        try:
+            # Add missing values
+            for attr in self.attributes.itervalues():
+                if attributes.get(attr.name) is None:
+                    value = attr.missing_value(**kwargs)
+                    if value is not None: attributes[attr.name] = value
+                    if value is None and attr.name in attributes:
+                        del attributes[attr.name]
+
+            # Validate attributes.
+            for name, value in attributes.iteritems():
+                if name == 'type':
+                    value = self.schema.long_name(value)
+                attributes[name] = self.attribute(name).validate(value, **kwargs)
+        except ValidationError, e:
+            raise  ValidationError, "%s: %s"%(self, e), sys.exc_info()[2]
+
+        return attributes
+
+    def allowed(self, op):
+        """Raise exception if op is not a valid operation on entity."""
+        op = op.upper()
+        if not op in self.operations:
+            raise NotImplementedStatus("Operation '%s' not implemented for '%s' %s" % (
+                op, self.name, self.operations))
+
+    def create_check(self, attributes):
+        for a in attributes:
+            if not self.attribute(a).create:
+                raise ValidationError("Cannot set attribute '%s' in CREATE" % a)
+
+    def update_check(self, new_attributes, old_attributes):
+        for a, v in new_attributes.iteritems():
+            # Its not an error to include an attribute in UPDATE if the value is not changed.
+            if not self.attribute(a).update and \
+               not (a in old_attributes and old_attributes[a] == v):
+                raise ValidationError("Cannot update attribute '%s' in UPDATE" % a)
+
+    def dump(self):
+        """Json friendly representation"""
+        return _dump_dict([
+            ('attributes', OrderedDict(
+                (k, v.dump()) for k, v in self.attributes.iteritems()
+                if k != 'type')), # Don't dump 'type' attribute, dumped separately.
+            ('operations', self.operations),
+            ('description', self.description or None),
+            ('fullyQualifiedType', self.name or None),
+            ('references', self.references),
+            ('deprecated', self.deprecated),
+            ('singleton', self.singleton)
+        ])
+
+    def __repr__(self):
+        return "%s(%s)" % (type(self).__name__, self.name)
+
+    def __str__(self):
+        return self.name
+
+    def name_is(self, name):
+        return self.name == self.schema.long_name(name)
+
+
+
+class Schema(object):
+    """
+    Schema defining entity types.
+    Note: keyword arguments come from schema so use camelCase
+
+    @ivar prefix: Prefix to prepend to short entity type names.
+    @ivar entityTypes: Map of L{EntityType} by name.
+    @ivar description: Text description of schema.
+    """
+    def __init__(self, prefix="", entityTypes=None, description=""):
+        """
+        @param prefix: Prefix for entity names.
+        @param entity_types: Map of  { entityTypeName: { singleton:, attributes:{...}}}
+        @param description: Human readable description.
+        """
+        if prefix:
+            self.prefix = prefix.strip('.')
+            self.prefixdot = self.prefix + '.'
+        else:
+            self.prefix = self.prefixdot = ""
+        self.description = description
+
+        def parsedefs(cls, defs):
+            return OrderedDict((self.long_name(k), cls(k, self, **v))
+                               for k, v in (defs or {}).iteritems())
+
+        self.entity_types = parsedefs(EntityType, entityTypes)
+
+        self.all_attributes = set()
+
+        ordinality = 0
+        for e in self.entity_types.itervalues():
+            e.init()
+            e.ordinality = ordinality
+            self.all_attributes.update(e.attributes.keys())
+            ordinality += 1
+
+    def short_name(self, name):
+        """Remove prefix from name if present"""
+        if not name:
+            return name
+        if name.startswith(self.prefixdot):
+            name = name[len(self.prefixdot):]
+        return name
+
+    def long_name(self, name):
+        """Add prefix to unqualified name"""
+        if not name:
+            return name
+        if not name.startswith(self.prefixdot):
+            name = self.prefixdot + name
+        return name
+
+    def is_long_name(self, name):
+        if not name:
+            return False
+        if self.prefixdot in name:
+            return True
+        return False
+
+    def dump(self):
+        """Return json-friendly representation"""
+        return OrderedDict([
+            ('prefix', self.prefix),
+            ('entityTypes',
+             OrderedDict((e.short_name, e.dump()) for e in self.entity_types.itervalues()))
+        ])
+
+    def _lookup(self, map, name, message, error):
+        found = map.get(name) or map.get(self.long_name(name))
+        if not found and error:
+            raise ValidationError(message % name)
+        return found
+
+    def entity_type(self, name, error=True):
+        return self._lookup(self.entity_types, name, "No such entity type '%s'", error)
+
+    def validate_entity(self, attributes, check_required=True, add_default=True,
+                        check_unique=None, check_singleton=None):
+        """
+        Validate a single entity.
+
+        @param attributes: Map of attribute name: value
+        @keyword check_required: Raise exception if required attributes are missing.
+        @keyword add_default: Add defaults for missing attributes.
+        @keyword check_unique: Used by L{validate_all}
+        @keyword check_singleton: Used by L{validate_all}
+        """
+        attributes['type'] = self.long_name(attributes['type'])
+        entity_type = self.entity_type(attributes['type'])
+        entity_type.validate(
+            attributes,
+            check_required=check_required,
+            add_default=add_default,
+            check_unique=check_unique,
+            check_singleton=check_singleton)
+
+    def validate_all(self, attribute_maps, check_required=True, add_default=True,
+                     check_unique=True, check_singleton=True):
+        """
+        Validate a list of attribute maps representing entity attributes.
+        Verify singleton entities and unique attributes are unique.
+        Modifies attribute_maps, adds default values, converts values.
+
+        @param attribute_maps: List of attribute name:value maps.
+        @keyword check_required: Raise exception if required attributes are missing.
+        @keyword add_default: Add defaults for missing attributes.
+        @keyword check_unique: Raise exception if unique attributes are duplicated.
+        @keyword check_singleton: Raise exception if singleton entities are duplicated
+        """
+        if check_singleton: check_singleton = set()
+        if check_unique: check_unique = set()
+
+        for e in attribute_maps:
+            self.validate_entity(e,
+                                 check_required=check_required,
+                                 add_default=add_default,
+                                 check_unique=check_unique,
+                                 check_singleton=check_singleton)
+
+    def entity(self, attributes):
+        """Convert an attribute map into an L{SchemaEntity}"""
+        attributes = dict((k, v) for k, v in attributes.iteritems() if v is not None)
+        return SchemaEntity(self.entity_type(attributes['type']), attributes)
+
+    def entities(self, attribute_maps):
+        """Convert a list of attribute maps into a list of L{SchemaEntity}"""
+        return [self.entity(m) for m in attribute_maps]
+
+    def filter(self, predicate):
+        """Return an iterator over entity types that satisfy predicate."""
+        if predicate is None: return self.entity_types.itervalues()
+        return (t for t in self.entity_types.itervalues() if predicate(t))
+
+    def by_type(self, type):
+        """Return an iterator over entity types that extend or are type.
+        If type is None return all entities."""
+        if not type:
+            return self.entity_types.itervalues()
+        else:
+            return self.filter(lambda t: t.is_a(type))
+
+
+class QdSchema(Schema):
+    """
+    Qpid Dispatch Router management schema.
+    """
+
+    CONFIGURATION_ENTITY = u"configurationEntity"
+    OPERATIONAL_ENTITY = u"operationalEntity"
+
+    def __init__(self):
+        """Load schema."""
+        qd_schema = get_data('qpid_dispatch.management', 'qdrouter.json')
+        try:
+            super(QdSchema, self).__init__(**json.loads(qd_schema, **JSON_LOAD_KWARGS))
+        except Exception,e:
+            raise ValueError("Invalid schema qdrouter.json: %s" % e)
+        self.configuration_entity = self.entity_type(self.CONFIGURATION_ENTITY)
+        self.operational_entity = self.entity_type(self.OPERATIONAL_ENTITY)
+
+    def validate_full(self, entities, **kwargs):
+        """
+        In addition to L{schema.Schema.validate}, check the following:
+
+        listeners and connectors can only have role=inter-router if the
+        router has mode=interior.
+
+
+        @param entities: List of attribute name:value maps.
+        @param kwargs: See L{schema.Schema.validate}
+        """
+        entities = list(entities) # Need to traverse twice
+        super(QdSchema, self).validate_all(entities, **kwargs)
+        inter_router = not_interior = None
+        for e in entities:
+            if self.short_name(e.type) == "router" and e.mode != "interior":
+                not_interior = e.mode
+            if self.short_name(e.type) in ["listener", "connector"] and e.role == "inter-router":
+                inter_router = e
+            if not_interior and inter_router:
+                raise schema.ValidationError(
+                    "role='inter-router' only allowed with router mode='interior' for %s." % inter_router)
+
+    def is_configuration(self, entity_type):
+        return entity_type and self.configuration_entity in entity_type.all_bases
+
+    def is_operational(self, entity_type):
+        return entity_type and self.operational_entity in entity_type.all_bases
+
+
+class SchemaEntity(EntityBase):
+    """A map of attributes associated with an L{EntityType}"""
+    def __init__(self, entity_type, attributes=None, validate=True, **kwattrs):
+        super(SchemaEntity, self).__init__(attributes, **kwattrs)
+        self.__dict__['entity_type'] = entity_type
+        self.attributes.setdefault('type', entity_type.name)
+        if validate: self.validate()
+
+    def _set(self, name, value):
+        super(SchemaEntity, self)._set(name, value)
+        self.validate()
+
+    def validate(self, **kwargs):
+        self.entity_type.validate(self.attributes, **kwargs)

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/python/qpid_dispatch_internal/management/schema/schema_doc.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/schema/schema_doc.py b/python/qpid_dispatch_internal/management/schema/schema_doc.py
new file mode 100644
index 0000000..b65392a
--- /dev/null
+++ b/python/qpid_dispatch_internal/management/schema/schema_doc.py
@@ -0,0 +1,121 @@
+#
+# 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
+#
+
+"""Library for generating asciidoc documentation from a L{schema.Schema}"""
+
+from collections import namedtuple
+import sys
+
+from python.qpid_dispatch_internal.management.schema.schema import quotestr
+
+
+class SchemaWriter(object):
+    """Write the schema as an asciidoc document"""
+
+    def __init__(self, output, schema, quiet=True):
+        self.output, self.schema, self.quiet = output, schema, quiet
+        self._heading = 0
+        # Options affecting how output is written
+
+    def warn(self, message):
+        if not self.quiet: print >>sys.stderr, message
+
+    def write(self, text): self.output.write(text)
+
+    def writeln(self, text=""): self.output.write(text+"\n")
+
+    def para(self, text): self.write(text+"\n\n")
+
+    def heading(self, text=None, sub=0):
+        self._heading += sub
+        if text: self.para("\n=%s %s" % ("="*self._heading, text))
+
+    class Section(namedtuple("Section", ["writer", "heading"])):
+        def __enter__(self): self.writer.heading(self.heading, sub=+1)
+        def __exit__(self, ex, value, trace): self.writer.heading(sub=-1)
+
+    def section(self, heading): return self.Section(self, heading)
+
+    def attribute_qualifiers(self, attr, show_create=True, show_update=True):
+        default = attr.default
+        if isinstance(default, basestring) and default.startswith('$'):
+            default = None  # Don't show defaults that are references, confusing.
+        return ' (%s)' % (', '.join(
+            filter(None, [str(attr.atype),
+                          default and "default=%s" % quotestr(default),
+                          attr.required and "required",
+                          attr.unique and "unique",
+                          show_create and attr.create and "`CREATE`",
+                          show_update and attr.update and "`UPDATE`"
+                      ])))
+
+    def attribute_type(self, attr, holder=None, show_create=True, show_update=True):
+        self.writeln("'%s'%s::" % (
+            attr.name, self.attribute_qualifiers(attr, show_create, show_update)))
+        if attr.description:
+            self.writeln("  %s" % attr.description)
+        else:
+            self.warn("Warning: No description for %s in %s" % (attr, attr.defined_in.short_name))
+        self.writeln()
+
+    def attribute_types(self, holder):
+        for attr in holder.my_attributes:
+            self.attribute_type(attr, holder)
+
+    def operation_def(self, op, holder):
+
+        def request_response(what):
+            message = getattr(op, what)
+            if message:
+                if message.body:
+                    self.para(".%s body%s\n\n%s" % (
+                        what.capitalize(), self.attribute_qualifiers(message.body),
+                        message.body.description))
+                if message.properties:
+                    self.para(".%s properties" % (what.capitalize()))
+                    for prop in message.properties.itervalues():
+                        self.attribute_type(prop)
+
+        with self.section("Operation %s" % op.name):
+            if op.description: self.para(op.description)
+            request_response("request")
+            request_response("response")
+
+    def operation_defs(self, entity_type):
+        for op in entity_type.operation_defs.itervalues():
+            self.operation_def(op, entity_type)
+
+    def entity_type(self, entity_type, operation_defs=True):
+        with self.section(entity_type.short_name):
+            if entity_type.description:
+                self.para('%s' % entity_type.description)
+            else:
+                self.warn("Warning no description for %s" % entity_type)
+            if entity_type.operations:
+                self.para("Operations allowed: `%s`\n\n" % "`, `".join(entity_type.operations))
+
+            self.attribute_types(entity_type)
+            if entity_type.operation_defs:
+                self.operation_defs(entity_type)
+
+    def entity_types_extending(self, base_name):
+        base = self.schema.entity_type(base_name)
+        for entity_type in self.schema.filter(lambda t: t.extends(base)):
+            self.entity_type(entity_type)
+

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/python/qpid_dispatch_internal/management/schema_doc.py
----------------------------------------------------------------------
diff --git a/python/qpid_dispatch_internal/management/schema_doc.py b/python/qpid_dispatch_internal/management/schema_doc.py
deleted file mode 100644
index ecf2825..0000000
--- a/python/qpid_dispatch_internal/management/schema_doc.py
+++ /dev/null
@@ -1,120 +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
-#
-
-"""Library for generating asciidoc documentation from a L{schema.Schema}"""
-
-from collections import namedtuple
-import sys
-from .schema import quotestr
-
-
-class SchemaWriter(object):
-    """Write the schema as an asciidoc document"""
-
-    def __init__(self, output, schema, quiet=True):
-        self.output, self.schema, self.quiet = output, schema, quiet
-        self._heading = 0
-        # Options affecting how output is written
-
-    def warn(self, message):
-        if not self.quiet: print >>sys.stderr, message
-
-    def write(self, text): self.output.write(text)
-
-    def writeln(self, text=""): self.output.write(text+"\n")
-
-    def para(self, text): self.write(text+"\n\n")
-
-    def heading(self, text=None, sub=0):
-        self._heading += sub
-        if text: self.para("\n=%s %s" % ("="*self._heading, text))
-
-    class Section(namedtuple("Section", ["writer", "heading"])):
-        def __enter__(self): self.writer.heading(self.heading, sub=+1)
-        def __exit__(self, ex, value, trace): self.writer.heading(sub=-1)
-
-    def section(self, heading): return self.Section(self, heading)
-
-    def attribute_qualifiers(self, attr, show_create=True, show_update=True):
-        default = attr.default
-        if isinstance(default, basestring) and default.startswith('$'):
-            default = None  # Don't show defaults that are references, confusing.
-        return ' (%s)' % (', '.join(
-            filter(None, [str(attr.atype),
-                          default and "default=%s" % quotestr(default),
-                          attr.required and "required",
-                          attr.unique and "unique",
-                          show_create and attr.create and "`CREATE`",
-                          show_update and attr.update and "`UPDATE`"
-                      ])))
-
-    def attribute_type(self, attr, holder=None, show_create=True, show_update=True):
-        self.writeln("'%s'%s::" % (
-            attr.name, self.attribute_qualifiers(attr, show_create, show_update)))
-        if attr.description:
-            self.writeln("  %s" % attr.description)
-        else:
-            self.warn("Warning: No description for %s in %s" % (attr, attr.defined_in.short_name))
-        self.writeln()
-
-    def attribute_types(self, holder):
-        for attr in holder.my_attributes:
-            self.attribute_type(attr, holder)
-
-    def operation_def(self, op, holder):
-
-        def request_response(what):
-            message = getattr(op, what)
-            if message:
-                if message.body:
-                    self.para(".%s body%s\n\n%s" % (
-                        what.capitalize(), self.attribute_qualifiers(message.body),
-                        message.body.description))
-                if message.properties:
-                    self.para(".%s properties" % (what.capitalize()))
-                    for prop in message.properties.itervalues():
-                        self.attribute_type(prop)
-
-        with self.section("Operation %s" % op.name):
-            if op.description: self.para(op.description)
-            request_response("request")
-            request_response("response")
-
-    def operation_defs(self, entity_type):
-        for op in entity_type.operation_defs.itervalues():
-            self.operation_def(op, entity_type)
-
-    def entity_type(self, entity_type, operation_defs=True):
-        with self.section(entity_type.short_name):
-            if entity_type.description:
-                self.para('%s' % entity_type.description)
-            else:
-                self.warn("Warning no description for %s" % entity_type)
-            if entity_type.operations:
-                self.para("Operations allowed: `%s`\n\n" % "`, `".join(entity_type.operations))
-
-            self.attribute_types(entity_type)
-            if entity_type.operation_defs:
-                self.operation_defs(entity_type)
-
-    def entity_types_extending(self, base_name):
-        base = self.schema.entity_type(base_name)
-        for entity_type in self.schema.filter(lambda t: t.extends(base)):
-            self.entity_type(entity_type)
-

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7367e96..310ebc9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -31,10 +31,10 @@ set(GENERATOR_DEPENDS ${GENERATOR_DEPENDS} ${GENERATOR_SRC})
 file (GLOB GENERATOR_SRC ${CMAKE_SOURCE_DIR}/python/qpid_dispatch/management/*.py)
 set(GENERATOR_DEPENDS ${GENERATOR_DEPENDS} ${GENERATOR_SRC})
 
-add_custom_command (
-  OUTPUT ${GENERATED_SOURCES}
-  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/run.py -s ${CMAKE_CURRENT_SOURCE_DIR}/schema_c.py
-  DEPENDS ${GENERATOR_DEPENDS})
+#add_custom_command (
+#  OUTPUT ${GENERATED_SOURCES}
+#  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_BINARY_DIR}/tests/run.py -s ${CMAKE_CURRENT_SOURCE_DIR}/schema_c.py
+#  DEPENDS ${GENERATOR_DEPENDS})
 
 include_directories(
   ${CMAKE_CURRENT_SOURCE_DIR}

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/src/agent.c
----------------------------------------------------------------------
diff --git a/src/agent.c b/src/agent.c
index d4788f6..c050479 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -17,39 +17,105 @@
  * under the License.
  */
 
-#include <qpid/dispatch/python_embedded.h>
+#include <Python.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#include <qpid/dispatch/python_embedded.h>
+//#include <qpid/dispatch/compose.h>
 
 #include "agent.h"
 #include "agent_private.h"
 #include "schema_enum.h"
+#include "compose_private.h"
 
 #define MANAGEMENT_MODULE "qpid_dispatch_internal.management"
 
-typedef struct {
-    PyObject_HEAD
-    qd_agent_t *agent;
+//static PyObject *qd_post_management_request(PyObject *self,
+//                                            PyObject *args,
+//                                            PyObject *keywds)
+static PyObject *qd_post_management_request(PyObject *self,
+                                            PyObject *args)
+
+{
+    int operation;    //Is this a CREATE, READ, UPDATE, DELETE or QUERY
+    int entity_type;  // Is this a listener or connector or address.... etc.
+    int count = 0;        // used for queries only
+    int offset = 0;       //used for queries only
+    PyObject *cid      = 0;
+    PyObject *reply_to = 0;
+    PyObject *name     = 0;
+    PyObject *identity = 0;
+    PyObject *body     = 0;
+
+    //static char *kwlist[] = {"operation", "entity_type", "count", "offset", "cid", "reply_to", "name", "identity", "body"};
+
+    //if (!PyArg_ParseTupleAndKeywords(args, keywds, "iiiiooooo", kwlist, &operation, &entity_type, &count, &offset, cid, reply_to, name, identity, body))
+    //    return 0;
+    if (!PyArg_ParseTuple(args, "iiiiooooo", &operation, &entity_type, &count, &offset, cid, reply_to, name, identity, body))
+        return 0;
+
+    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);
+    qd_py_to_composed(identity, field);
+    qd_py_to_composed(body, field);
 
-} AgentRequestAdapter;
+    qd_buffer_list_t *buffers = qd_compose_buffers(field);
+
+    //
+    // Create a request and add it to the work_queue
+    //
+    qd_agent_request_t *request = NEW(qd_agent_request_t);
+    request->buffer_list = buffers;
+    request->count = count;
+    request->entity_type = entity_type;
+    request->operation = operation;
+
+    AgentAdapter *adapter = ((AgentAdapter*) self);
+    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;
+    //
+    // Add work item to the work item list after locking the work item list
+    //
+    sys_mutex_lock(adapter->agent->lock);
+    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;
+
+    //
+    // TODO - Kick off processing of the work queue
+    //
+    qd_timer_schedule(adapter->agent->timer, 0);
+
+    return Py_None;
+}
 
 /**
- * Declare all the methods in the AgentRequestAdapter.
+ * Declare all the methods in the AgentAdapter.
  * post_management_request is the name of the method that the python side would call and qd_post_management_request is the C implementation
  * of the function.
  */
-static PyMethodDef AgentRequestAdapter_functions[] = {
+static PyMethodDef AgentAdapter_functions[] = {
+    //{"post_management_request", (PyCFunction)qd_post_management_request, METH_VARARGS|METH_KEYWORDS, "Posts a management request to a work queue"},
     {"post_management_request", qd_post_management_request, METH_VARARGS, "Posts a management request to a work queue"},
     {0, 0, 0, 0} // <-- Not sure why we need this
 };
 
-static PyTypeObject AgentRequestAdapterType = {
+static PyTypeObject AgentAdapterType = {
     PyObject_HEAD_INIT(0)
     0,                              /* ob_size*/
-    MANAGEMENT_MODULE ".AgentRequestAdapter",  /* tp_name*/
-    sizeof(AgentRequestAdapter),    /* tp_basicsize*/
+    MANAGEMENT_MODULE ".AgentAdapter",  /* tp_name*/
+    sizeof(AgentAdapter),    /* tp_basicsize*/
     0,                              /* tp_itemsize*/
     0,                              /* tp_dealloc*/
     0,                              /* tp_print*/
@@ -74,7 +140,7 @@ static PyTypeObject AgentRequestAdapterType = {
     0,                              /* tp_weaklistoffset */
     0,                              /* tp_iter */
     0,                              /* tp_iternext */
-    AgentRequestAdapter_functions,  /* tp_methods */
+    AgentAdapter_functions,  /* tp_methods */
     0,                              /* tp_members */
     0,                              /* tp_getset */
     0,                              /* tp_base */
@@ -96,280 +162,166 @@ static PyTypeObject AgentRequestAdapterType = {
     0                               /* tp_version_tag */
 };
 
-PyObject* qd_agent_init(char *agentClass, char *address, PyObject *pythonManagementModule, const char *config_path)
+
+/*static void process_work_queue(void *context)
+{
+    qd_agent_t *agent = (qd_agent_t *)context;
+    qd_management_work_item_t *work_item = DEQ_HEAD(agent->work_queue);
+
+    //TODO - The following works well with core but no corresponding functions for non-core
+    while(work_item) {
+            qd_agent_request_t *request = work_item->request;
+            qd_entity_type_handler_t *handler = agent->handlers[request->entity_type];
+            switch (request->operation) {
+                case QD_SCHEMA_ENTITY_OPERATION_READ:
+                    handler->read_handler(request->ctx,request);
+                    break;
+                case QD_SCHEMA_ENTITY_OPERATION_DELETE:
+                    handler->delete_handler(request->ctx, request);
+                    break;
+                case QD_SCHEMA_ENTITY_OPERATION_CREATE:
+                    handler->create_handler(request->ctx, request);
+                    break;
+                case QD_SCHEMA_ENTITY_OPERATION_UPDATE:
+                    handler->update_handler(request->ctx, request);
+                    break;
+                case QD_SCHEMA_ENTITY_OPERATION_QUERY:
+                    handler->query_handler(request->ctx, request);
+                    break;
+                case QD_SCHEMA_ENTITY_OPERATION_ENUM_COUNT:
+                    break;
+            }
+
+            work_item = DEQ_NEXT(work_item);
+    }
+}*/
+
+qd_agent_t* qd_agent(qd_dispatch_t *qd, char *address, const char *config_path)
 {
-    // Create a new instance of AgentRequestAdapterType
-    AgentRequestAdapterType.tp_new = PyType_GenericNew;
-    PyType_Ready(&AgentRequestAdapterType);
+    //
+    // Create a new instance of AgentAdapterType
+    //
+    AgentAdapterType.tp_new = PyType_GenericNew;
+    PyType_Ready(&AgentAdapterType);
 
     // Load the qpid_dispatch_internal.management Python module
+    PyObject *module = PyImport_ImportModule(MANAGEMENT_MODULE);
 
-    if (!pythonManagementModule) {
+    if (!module) {
         qd_error_py();
-        qd_log(log_source, QD_LOG_CRITICAL, "Cannot load dispatch extension module '%s'", MANAGEMENT_MODULE);
+        //qd_log(log_source, QD_LOG_CRITICAL, "Cannot load dispatch extension module '%s'", MANAGEMENT_MODULE);
         abort();
     }
 
-    PyTypeObject *agentRequestAdapterType = &AgentRequestAdapterType;
-    Py_INCREF(agentRequestAdapterType);
-
-    //Use the "AgentRequestAdapter" name to add the AgentRequestAdapterType to the management
-    PyModule_AddObject(pythonManagementModule, "AgentRequestAdapter", (PyObject*) &AgentRequestAdapterType);
-    // Now we have added AgentRequestAdapter to the qpid_dispatch_internal.management python module
+    PyTypeObject *agentAdapterType = &AgentAdapterType;
+    Py_INCREF(agentAdapterType);
 
-    PyObject *adapterType     = PyObject_GetAttrString(pythonManagementModule, "AgentRequestAdapter");
-    PyObject * adapterInstance = PyObject_CallObject(adapterType, 0);
-    adapter = ((AgentRequestAdapter*) adapterInstance);
-    ((AgentRequestAdapter*) adapterInstance)->log_source = qd_log_source("AGENT");
-    qd_management_work_list_t  work_queue = 0;
-    DEQ_INIT(work_queue);
-    ((AgentRequestAdapter*) adapterInstance)->work_queue = work_queue;
-    ((AgentRequestAdapter*) adapterInstance)->lock = sys_mutex();
-    initialize_handlers(((AgentRequestAdapter*) adapterInstance)->handlers);
+    //Use the "AgentAdapter" name to add the AgentAdapterType to the management
+    PyModule_AddObject(module, "AgentAdapter", (PyObject*) &AgentAdapterType);
+    PyObject *adapterType     = PyObject_GetAttrString(module, "AgentAdapter");
+    PyObject *adapterInstance = PyObject_CallObject(adapterType, 0);
 
-    //Instantiate the ManagementAgent class found in qpid_dispatch_internal/management/agent.py
-    PyObject* pClass = PyObject_GetAttrString(pythonManagementModule, agentClass);
+    //
+    //Instantiate the new agent and return it
+    //
+    qd_agent_t *agent = NEW(qd_agent_t);
+    agent->adapter = ((AgentAdapter*) adapterInstance);
+    agent->qd = qd;
+    agent->address = address;
+    agent->config_file = config_path;
+    agent->log_source = qd_log_source("AGENT");
+    //agent->timer = qd_timer(qd, process_work_queue, agent);
+    DEQ_INIT(agent->work_queue);
+    agent->lock = sys_mutex();
 
     //
-    // Constructor Arguments for ManagementAgent
+    // Initialize the handlers to zeros
     //
-    PyObject* pArgs = PyTuple_New(3);
+    for (int i=0; i < QD_SCHEMA_ENTITY_TYPE_ENUM_COUNT; i++)
+        agent->handlers[i] = 0;
 
-   // arg 0: management address $management
-   PyObject *address = PyString_FromString(address);
-   PyTuple_SetItem(pArgs, 0, address);
+    Py_DECREF(agentAdapterType);
+    Py_DECREF(module);
 
-   // arg 1: adapter instance
-   PyTuple_SetItem(pArgs, 1, adapterInstance);
+    //TODO - This is a test
+    qd_agent_start(agent);
 
-   // arg 2: config file location
-   PyObject *config_file = PyString_FromString(config_path);
-   PyTuple_SetItem(pArgs, 2, config_file);
+    printf ("qd_agent 6\n");
 
-   //
-   // Instantiate the ManagementAgent class
-   //
-   PyObject* pyManagementInstance = PyInstance_New(pClass, pArgs, 0);
-   if (pyManagementInstance) {}
-   Py_DECREF(pArgs);
-   Py_DECREF(adapterType);
-   Py_DECREF(pythonManagementModule);
-
-   //TODO - should I return an adapter or an instance of the entire management agent object?
-   return adapterInstance;
+    return agent;
 }
 
-/***
- * Adds a management
- */
-static PyObject *qd_post_management_request(PyObject *self, //TODO - Do we need so many arguments or can I just pass a list with everything in it?
-                                            PyObject *arg1, // Operation(CRUDQ) to be performed.
-                                            PyObject *arg2, // Entity type
-                                            PyObject *arg3, // count
-                                            PyObject *arg4, // offset
-                                            PyObject *arg5, // Correlation-id
-                                            PyObject *arg6, // Reply to
-                                            PyObject *arg7, // Name
-                                            PyObject *arg8, // identity
-                                            PyObject *arg9) // Request body
+
+qd_error_t qd_agent_start(qd_agent_t *agent)
 {
-    int operation;    //Is this a CREATE, READ, UPDATE, DELETE or QUERY
-    int entity_type;  // Is this a listener or connector or address.... etc.
-    int count = 0;        // used for queries only
-    int offset = 0;       //used for queries only
-    PyObject *cid      = 0;
-    PyObject *reply_to = 0;
-    PyObject *name     = 0;
-    PyObject *identity = 0;
-    PyObject *body     = 0;
+    // Load the qpid_dispatch_internal.management Python module
+    PyObject *module = PyImport_ImportModule(MANAGEMENT_MODULE);
 
-    if (!PyArg_ParseTuple(arg1, "i", &operation))
-        return 0;
-    if (!PyArg_ParseTuple(arg2, "i", &entity_type))
-        return 0;
-    if (!PyArg_ParseTuple(arg3, "i", &count))
-        return 0;
-    if (!PyArg_ParseTuple(arg4, "i", &offset))
-        return 0;
-    if (!PyArg_ParseTuple(arg3, "o", &cid))
-        return 0;
-    if (!PyArg_ParseTuple(arg4, "o", &reply_to))
-        return 0;
-    if (!PyArg_ParseTuple(arg5, "o", &name))
-        return 0;
-    if (!PyArg_ParseTuple(arg6, "o", &identity))
-        return 0;
-    if (!PyArg_ParseTuple(arg7, "o", &body))
-        return 0;
+    char *class = "ManagementAgent";
 
     //
-    // correlation id
+    //Instantiate the ManagementAgent class found in qpid_dispatch_internal/management/agent.py
     //
-    qd_composed_field_t *cid_field = qd_compose_subfield(0);
-    qd_py_to_composed(body, cid_field);
-    qd_buffer_list_t cid_buffers = qd_compose_buffers(cid_field);
-    // TODO - this is not correct. what if the buffer length is more than 512?
-    qd_buffer_t buffer = DEQ_HEAD(cid_buffers);
-    qd_field_iterator_t cid_iter = qd_address_iterator_buffer(buffer, 0, qd_buffer_list_length(cid_buffers), ITER_VIEW_ALL);
-
+    PyObject* pClass = PyObject_GetAttrString(module, class); QD_ERROR_PY_RET();
 
-    qd_composed_field_t *reply_to_field = qd_compose_subfield(0);
-    qd_py_to_composed(body, reply_to_field);
-    qd_buffer_list_t reply_to_buffers = qd_compose_buffers(reply_to_field);
-    // TODO - this is not correct. what if the buffer length is more than 512?
-    qd_field_iterator_t reply_to_iter = qd_address_iterator_buffer(DEQ_HEAD(reply_to_buffers), 0, qd_buffer_list_length(reply_to_buffers), ITER_VIEW_ALL);
+    printf("Hello world %i\n", PyClass_Check(pClass));
 
-    qd_composed_field_t *identity_field = qd_compose_subfield(0);
-    qd_py_to_composed(body, identity_field);
-    qd_buffer_list_t identity_buffers = qd_compose_buffers(identity_field);
-    // TODO - this is not correct. what if the buffer length is more than 512?
-    qd_field_iterator_t identity_iter = qd_address_iterator_buffer(DEQ_HEAD(identity_buffers), 0, qd_buffer_list_length(identity_buffers), ITER_VIEW_ALL);
-
-    qd_composed_field_t *name_field = qd_compose_subfield(0);
-    qd_py_to_composed(body, name_field);
-    qd_buffer_list_t name_buffers = qd_compose_buffers(name_field);
-    // TODO - this is not correct. what if the buffer length is more than 512?
-    qd_field_iterator_t name_iter = qd_address_iterator_buffer(DEQ_HEAD(name_buffers), 0, qd_buffer_list_length(name_buffers), ITER_VIEW_ALL);
-
-
-    qd_composed_field_t *body_field = qd_compose_subfield(0);
-    qd_py_to_composed(body, body_field);
-    qd_buffer_list_t body_buffers = qd_compose_buffers(body_field);
-    // TODO - this is not correct. what if the buffer length is more than 512?
-    qd_field_iterator_t body_iter = qd_address_iterator_buffer(DEQ_HEAD(body_buffers), 0, qd_buffer_list_length(body_buffers), ITER_VIEW_ALL);
+    //
+    // Constructor Arguments for ManagementAgent
+    //
+    PyObject* pArgs = PyTuple_New(3);
 
+   // arg 0: management address $management
+   PyObject *address = PyString_FromString(agent->address);
+   PyTuple_SetItem(pArgs, 0, address);
 
-    qd_entity_type_handler_t handler = qd_agent_handler_for_type(entity_type);
+   // arg 1: adapter instance
+   PyTuple_SetItem(pArgs, 1, (PyObject*)agent->adapter);
 
-    //
-    // Create a work item (qd_management_work_item_t)
-    //
-    qd_management_work_item_t work_item = NEW(qd_management_work_item_t);
-    work_item->count          = count;
-    work_item->offset         = offset;
-    work_item->operation      = operation;
-    work_item->entity_type    = entity_type;
-    work_item->ctx            = handler->ctx;
-    work_item->reply_to       = reply_to_iter;
-    work_item->correlation_id = cid_iter;
-    work_item->identity_iter  = identity_iter;
-    work_item->name_iter      = name_iter;
-    work_item->in_body        = body_iter;
+   // arg 2: config file location
+   PyObject *config_file = PyString_FromString((char *)agent->config_file);
+   PyTuple_SetItem(pArgs, 2, config_file);
 
-    //
-    // Add work item to the work item list after locking the work item list
-    //
-    sys_mutex_lock(adapter->lock);
-    DEQ_INSERT_TAIL(adapter->work_queue, work_item);
-    sys_mutex_unlock(adapter->lock);
+   printf("Hello world 2\n");
 
-    //
-    // TODO - Kick off processing of the work queue
-    //
-    return Py_None;
+   //
+   // 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_MODULE, class);
+   }
+   Py_DECREF(pArgs);
+   Py_DECREF(pClass);
+   return qd_error_code();
 }
 
 
-void qd_register_handlers(void *ctx,
-                          PyObject *pyAdapter,
-                          qd_schema_entity_type_t entity_type,
-                          qd_agent_handler_t create_handler,
-                          qd_agent_handler_t read_handler,
-                          qd_agent_handler_t update_handler,
-                          qd_agent_handler_t delete_handler,
-                          qd_agent_handler_t query_handler)
+void qd_agent_register_handlers(qd_agent_t *agent,
+                                void *ctx,
+                                qd_schema_entity_type_t entity_type,
+                                qd_agent_handler_t create_handler,
+                                qd_agent_handler_t read_handler,
+                                qd_agent_handler_t update_handler,
+                                qd_agent_handler_t delete_handler,
+                                qd_agent_handler_t query_handler)
 {
-    AgentRequestAdapter* adapter = ((AgentRequestAdapter*) pyAdapter);
-    qd_entity_type_handler_t entity_handler = NEW(qd_entity_type_handler_t);
+    qd_entity_type_handler_t *entity_handler = NEW(qd_entity_type_handler_t);
+    entity_handler->ctx            = ctx;
+    entity_handler->entity_type    = entity_type;
     entity_handler->delete_handler = delete_handler;
     entity_handler->update_handler = update_handler;
     entity_handler->query_handler  = query_handler;
     entity_handler->create_handler = create_handler;
     entity_handler->read_handler   = read_handler;
 
-    //Store the entity_handler in the appropriate cell of the handler array index by the enum qd_schema_entity_type_t
-    adapter->handlers[entity_type] = entity_handler;
-
-}
-
-static qd_entity_type_handler_t *qd_agent_handler_for_type(qd_schema_entity_type_t entity_type, AgentRequestAdapter* adapter)
-{
-    return adapter->handlers[entity_type];
-}
-
-static void initialize_handlers(AgentRequestAdapter* adapter)
-{
-    for (int i=0; i < QD_SCHEMA_ENTITY_TYPE_ENUM_COUNT; i++)
-    {
-            adapter->handlers[i] = 0;
-    }
-}
-
-
-static process_work_queue(qd_management_work_list_t  work_queue, AgentRequestAdapter* adapter)
-{
-    qd_management_work_item_t work_item = DEQ_HEAD(work_queue);
-
-    qd_entity_type_handler_t handler = qd_agent_handler_for_type(work_item->entity_type, adapter);
-
-    //TODO - The following works well with core but no corresponding functions for non-core
-    while(work_item) {
-            switch (work_item->operation) {
-                case QD_SCHEMA_ENTITY_OPERATION_READ:
-                    handler->read_handler(work_item->ctx,
-                                          work_item->reply_to,
-                                          work_item->correlation_id,
-                                          work_item->entity_type,
-                                          work_item->operation,
-                                          work_item->identity_iter,
-                                          work_item->name_iter);
-                    break;
-                case QD_SCHEMA_ENTITY_OPERATION_DELETE:
-                    handler->delete_handler(work_item->ctx,
-                                            work_item->reply_to,
-                                            work_item->correlation_id,
-                                            work_item->entity_type,
-                                            work_item->operation,
-                                            work_item->identity_iter,
-                                            work_item->name_iter);
-                    break;
-                case QD_SCHEMA_ENTITY_OPERATION_CREATE:
-                    handler->create_handler(work_item->ctx,
-                                            work_item->reply_to,
-                                            work_item->correlation_id,
-                                            work_item->entity_type,
-                                            work_item->operation,
-                                            work_item->name_iter,
-                                            work_item->in_body);
-                    break;
-                case QD_SCHEMA_ENTITY_OPERATION_UPDATE:
-                    handler->update_handler(work_item->ctx,
-                                            work_item->reply_to,
-                                            work_item->correlation_id,
-                                            work_item->entity_type,
-                                            work_item->operation,
-                                            work_item->identity_iter,
-                                            work_item->name_iter,
-                                            work_item->in_body);
-                    break;
-                case QD_SCHEMA_ENTITY_OPERATION_QUERY:
-                    handler->query_handler(work_item->ctx,
-                                            work_item->reply_to,
-                                            work_item->correlation_id,
-                                            work_item->entity_type,
-                                            work_item->operation,
-                                            work_item->count,
-                                            work_item->offset,
-                                            work_item->in_body);
-                    break;
-            }
-
-            work_item = DEQ_NEXT(work_item);
-    }
+    //Store the entity_handler in the appropriate cell of the handler array indexed by the enum qd_schema_entity_type_t
+    agent->handlers[entity_type] = entity_handler;
 }
 
 
-PyObject* qd_agent_adapter_finalize(PyObject *adapter)
+void qd_agent_free(qd_agent_t *agent)
 {
 
 }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/src/agent.h
----------------------------------------------------------------------
diff --git a/src/agent.h b/src/agent.h
index 83a82d3..9f50fce 100644
--- a/src/agent.h
+++ b/src/agent.h
@@ -1,5 +1,5 @@
-#ifndef __agent_adapter_h__
-#define __agent_adapter_h__
+#ifndef __agent_h__
+#define __agent_h__
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,7 +20,6 @@
  * under the License.
  */
 #include "schema_enum.h"
-#include "agent_private.h"
 
 typedef struct qd_agent_t qd_agent_t;
 typedef struct qd_agent_request_t qd_agent_request_t;
@@ -29,7 +28,7 @@ typedef struct qd_agent_request_t qd_agent_request_t;
  * Creates a new agent with the passed in address and whose configuration is located at config path.
  * @see qd_agent_start to start the agent
  */
-qd_agent_t* qd_agent(char *address, const char *config_path);
+qd_agent_t* qd_agent(qd_dispatch_t *qd, char *address, const char *config_path);
 
 /**
  * Free the agent and its components
@@ -57,6 +56,6 @@ void qd_agent_register_handlers(qd_agent_t *agent,
  * Loads the contents of the config file located in config_path
  * Agent starts listening on the provided address
  */
-void qd_agent_start(qd_agent_t *agent);
+qd_error_t qd_agent_start(qd_agent_t *agent);
 
 #endif

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/src/agent_private.h
----------------------------------------------------------------------
diff --git a/src/agent_private.h b/src/agent_private.h
index 96f0e26..7b51e40 100644
--- a/src/agent_private.h
+++ b/src/agent_private.h
@@ -1,21 +1,17 @@
 #ifndef __agent_private_h__
 #define __agent_private_h__
 
+#include <Python.h>
+#include <qpid/dispatch/ctools.h>
+#include <qpid/dispatch/timer.h>
+#include <qpid/dispatch/threading.h>
+#include <qpid/dispatch/log.h>
+#include "agent.h"
 #include "schema_enum.h"
-#include "ctools.h"
 
 typedef struct qd_management_work_item_t {
     DEQ_LINKS(struct qd_management_work_item_t);
-    int                  operation;      //Is this a CREATE, READ, UPDATE, DELETE or QUERY
-    int                  entity_type;    // Is this a listener or connector or address.... etc.
-    int                  count;
-    int                  offset;
-    void                *ctx;
-    qd_field_iterator_t *reply_to;
-    qd_field_iterator_t *correlation_id;
-    qd_field_iterator_t *identity_iter;
-    qd_field_iterator_t *name_iter;
-    qd_parsed_field_t   *in_body;
+    qd_agent_request_t *request;
 } qd_management_work_item_t;
 
 DEQ_DECLARE(qd_management_work_item_t, qd_management_work_list_t);
@@ -30,7 +26,17 @@ typedef struct qd_entity_type_handler_t {
     qd_agent_handler_t       query_handler;
 } qd_entity_type_handler_t;
 
+typedef struct {
+    PyObject_HEAD
+    qd_agent_t *agent;
+} AgentAdapter;
+
 struct qd_agent_t {
+    qd_dispatch_t             *qd;
+    qd_timer_t                *timer;
+    AgentAdapter              *adapter;
+    char                      *address;
+    const char                *config_file;
     qd_management_work_list_t  work_queue;
     sys_mutex_t               *lock;
     qd_log_source_t           *log_source;
@@ -38,16 +44,14 @@ struct qd_agent_t {
 };
 
 struct qd_agent_request_t {
-    qd_buffer_list_t        *list; // A buffer chain holding all the relevant information for the CRUDQ operations.
-    void                    *ctx;
-    int                      count;
-    int                      offset;
-    qd_field_iterator_t     *identity_iter;
-    qd_field_iterator_t     *name_iter;
-    qd_field_iterator_t     *reply_to;
-    qd_field_iterator_t     *correlation_id;
-    qd_router_entity_type_t  entity_type;
-    qd_parsed_field_t       *in_body;
+    qd_buffer_list_t            *buffer_list; // A buffer chain holding all the relevant information for the CRUDQ operations.
+    void                        *ctx;
+    int                          count;
+    int                          offset;
+    qd_schema_entity_type_t      entity_type;
+    qd_schema_entity_operation_t operation;
 };
 
+
+
 #endif

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/src/dispatch.c
----------------------------------------------------------------------
diff --git a/src/dispatch.c b/src/dispatch.c
index cb5c34e..232b34d 100644
--- a/src/dispatch.c
+++ b/src/dispatch.c
@@ -84,13 +84,18 @@ qd_error_t qd_dispatch_load_config(qd_dispatch_t *qd, const char *config_path)
         return qd_error(QD_ERROR_RUNTIME, "Cannot locate library %s", QPID_DISPATCH_LIB);
 
     qd_python_lock_state_t lock_state = qd_python_lock();
-    PyObject *module = PyImport_ImportModule("qpid_dispatch_internal.management.config");
+
+    qd_agent_t *agent = qd_agent(qd, "$management", config_path);
+    qd->agent = agent;
+
+
+    /*PyObject *module = PyImport_ImportModule("qpid_dispatch_internal.management.config");
     PyObject *configure_dispatch = module ? PyObject_GetAttrString(module, "configure_dispatch") : NULL;
     Py_XDECREF(module);
     PyObject *result = configure_dispatch ? PyObject_CallFunction(configure_dispatch, "(lls)", (long)qd, qd->dl_handle, config_path) : NULL;
     Py_XDECREF(configure_dispatch);
     if (!result) qd_error_py();
-    Py_XDECREF(result);
+    Py_XDECREF(result);*/
     qd_python_unlock(lock_state);
     return qd_error_code();
 }

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/src/dispatch_private.h
----------------------------------------------------------------------
diff --git a/src/dispatch_private.h b/src/dispatch_private.h
index 27a454f..09bc28b 100644
--- a/src/dispatch_private.h
+++ b/src/dispatch_private.h
@@ -41,6 +41,7 @@ typedef struct qd_config_address_t   qd_config_address_t;
 #include <qpid/dispatch/router.h>
 #include <qpid/dispatch/connection_manager.h>
 #include "policy.h"
+#include "agent.h"
 #include "server_private.h"
 #include "router_private.h"
 
@@ -48,10 +49,11 @@ struct qd_dispatch_t {
     qd_server_t             *server;
     qd_container_t          *container;
     qd_router_t             *router;
-    void                    *agent;
+    //void                    *agent;
     qd_connection_manager_t *connection_manager;
     qd_policy_t             *policy;
     void                    *dl_handle;
+    qd_agent_t              *agent;
 
     int    thread_count;
     char  *sasl_config_path;
@@ -80,7 +82,7 @@ qd_error_t qd_dispatch_configure_router(qd_dispatch_t *qd, qd_entity_t *entity);
 
 /**
  * Prepare Dispatch for operation.  This must be called prior to
- * calling qd_server_run or qd_server_start.
+ * calling qd_server_run.
  *
  * @param qd The dispatch handle returned by qd_dispatch
  */

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/src/router_core/management_agent.c
----------------------------------------------------------------------
diff --git a/src/router_core/management_agent.c b/src/router_core/management_agent.c
index e1cf1cb..b641676 100644
--- a/src/router_core/management_agent.c
+++ b/src/router_core/management_agent.c
@@ -62,16 +62,6 @@ 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 enum {
-    QD_ROUTER_OPERATION_QUERY,
-    QD_ROUTER_OPERATION_CREATE,
-    QD_ROUTER_OPERATION_READ,
-    QD_ROUTER_OPERATION_UPDATE,
-    QD_ROUTER_OPERATION_DELETE
-} qd_router_operation_type_t;
-
-
 typedef struct qd_management_context_t {
     qd_message_t                *response;
     qd_composed_field_t         *out_body;
@@ -210,12 +200,15 @@ static void qd_manage_response_handler(void *context, const qd_amqp_error_t *sta
     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_router_operation_type_t  operation_type,
+                                 qd_schema_entity_operation_t  operation_type,
                                  int                        *count,
                                  int                        *offset,
                                  qd_parsed_field_t          *in_body)
@@ -262,7 +255,7 @@ 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_router_operation_type_t  operation_type,
+                                qd_schema_entity_operation_t  operation_type,
                                 qd_field_iterator_t        *identity_iter,
                                 qd_field_iterator_t        *name_iter)
 {
@@ -283,7 +276,7 @@ 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_router_operation_type_t  operation_type,
+                                  qd_schema_entity_operation_t  operation_type,
                                   qd_field_iterator_t        *name_iter,
                                   qd_parsed_field_t          *in_body)
 {
@@ -299,14 +292,14 @@ void qd_core_agent_create_handler(void                       *ctx,
 }
 
 
-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_router_operation_type_t  operation_type,
-                                  qd_field_iterator_t        *identity_iter,
-                                  qd_field_iterator_t        *name_iter,
-                                  qd_parsed_field_t          *in_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;
 
@@ -319,14 +312,14 @@ void qd_core_agent_update_handler(void                       *ctx,
 }
 
 
-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_router_operation_type_t  operation_type,
-                                  qd_field_iterator_t        *identity_iter,
-                                  qd_field_iterator_t        *name_iter)
+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;
 
@@ -338,96 +331,3 @@ void qd_core_agent_delete_handler(void                       *ctx,
 
     qdr_manage_delete(core, mgmt_ctx, entity_type, name_iter, identity_iter);
 }
-
-
-/**
- * Checks the content of the message to see if this can be handled by the C-management agent. If this agent cannot handle it, it will be
- * forwarded to the Python agent.
- */
-bool qd_can_handle_request(qd_parsed_field_t           *properties_fld,
-                                  qd_router_entity_type_t     *entity_type,
-                                  qd_router_operation_type_t  *operation_type,
-                                  qd_field_iterator_t        **identity_iter,
-                                  qd_field_iterator_t        **name_iter,
-                                  int                         *count,
-                                  int                         *offset)
-{
-    // The must be a property field and that property field should be a AMQP map. This is true for QUERY but I need
-    // to check if it true for CREATE, UPDATE and DELETE
-    if (properties_fld == 0 || !qd_parse_is_map(properties_fld))
-        return false;
-
-    //
-    // Only certain entity types can be handled by this agent.
-    // 'entityType': 'org.apache.qpid.dispatch.router.address
-    // 'entityType': 'org.apache.qpid.dispatch.router.link'
-    // TODO - Add more entity types here. The above is not a complete list.
-
-    qd_parsed_field_t *parsed_field = qd_parse_value_by_key(properties_fld, IDENTITY);
-    if (parsed_field!=0) {
-        *identity_iter = qd_parse_raw(parsed_field);
-    }
-    parsed_field = qd_parse_value_by_key(properties_fld, NAME);
-    if (parsed_field!=0) {
-        *name_iter = qd_parse_raw(parsed_field);
-    }
-
-    parsed_field = qd_parse_value_by_key(properties_fld, ENTITY);
-
-    if (parsed_field == 0) { // Sometimes there is no 'entityType' but 'type' might be available.
-        parsed_field = qd_parse_value_by_key(properties_fld, TYPE);
-        if (parsed_field == 0)
-            return false;
-    }
-
-    if (qd_field_iterator_equal(qd_parse_raw(parsed_field), address_entity_type))
-        *entity_type = QD_ROUTER_ADDRESS;
-    else if (qd_field_iterator_equal(qd_parse_raw(parsed_field), link_entity_type))
-        *entity_type = QD_ROUTER_LINK;
-    else if (qd_field_iterator_equal(qd_parse_raw(parsed_field), config_address_entity_type))
-        *entity_type = QD_ROUTER_CONFIG_ADDRESS;
-    else if (qd_field_iterator_equal(qd_parse_raw(parsed_field), link_route_entity_type))
-        *entity_type = QD_ROUTER_CONFIG_LINK_ROUTE;
-    else if (qd_field_iterator_equal(qd_parse_raw(parsed_field), auto_link_entity_type))
-        *entity_type = QD_ROUTER_CONFIG_AUTO_LINK;
-    else if (qd_field_iterator_equal(qd_parse_raw(parsed_field), console_entity_type))
-        *entity_type = QD_ROUTER_FORBIDDEN;
-    else
-        return false;
-
-
-    parsed_field = qd_parse_value_by_key(properties_fld, OPERATION);
-
-    if (parsed_field == 0)
-        return false;
-
-    if (qd_field_iterator_equal(qd_parse_raw(parsed_field), MANAGEMENT_QUERY))
-        (*operation_type) = QD_ROUTER_OPERATION_QUERY;
-    else if (qd_field_iterator_equal(qd_parse_raw(parsed_field), MANAGEMENT_CREATE))
-        (*operation_type) = QD_ROUTER_OPERATION_CREATE;
-    else if (qd_field_iterator_equal(qd_parse_raw(parsed_field), MANAGEMENT_READ))
-        (*operation_type) = QD_ROUTER_OPERATION_READ;
-    else if (qd_field_iterator_equal(qd_parse_raw(parsed_field), MANAGEMENT_UPDATE))
-        (*operation_type) = QD_ROUTER_OPERATION_UPDATE;
-    else if (qd_field_iterator_equal(qd_parse_raw(parsed_field), MANAGEMENT_DELETE))
-        (*operation_type) = QD_ROUTER_OPERATION_DELETE;
-    else
-        // This is an unknown operation type. cannot be handled, return false.
-        return false;
-
-    // Obtain the count and offset.
-    parsed_field = qd_parse_value_by_key(properties_fld, COUNT);
-    if (parsed_field)
-        (*count) = qd_parse_as_int(parsed_field);
-    else
-        (*count) = -1;
-
-    parsed_field = qd_parse_value_by_key(properties_fld, OFFSET);
-    if (parsed_field)
-        (*offset) = qd_parse_as_int(parsed_field);
-    else
-        (*offset) = 0;
-
-    return true;
-}
-

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/src/router_pynode.c
----------------------------------------------------------------------
diff --git a/src/router_pynode.c b/src/router_pynode.c
index 3984f74..0908268 100644
--- a/src/router_pynode.c
+++ b/src/router_pynode.c
@@ -264,7 +264,10 @@ static PyObject* qd_unmap_destination(PyObject *self, PyObject *args)
 
 static PyObject* qd_get_agent(PyObject *self, PyObject *args) {
     RouterAdapter *adapter = (RouterAdapter*) self;
-    PyObject *agent = adapter->router->qd->agent;
+    if (adapter) {
+
+    }
+    PyObject *agent = 0 ;//adapter->router->qd->agent;
     if (agent) {
         Py_INCREF(agent);
         return agent;
@@ -435,6 +438,7 @@ qd_error_t qd_router_python_setup(qd_router_t *router)
 
     pModule = PyImport_ImportModule("qpid_dispatch_internal.router"); QD_ERROR_PY_RET();
     pClass = PyObject_GetAttrString(pModule, "RouterEngine");
+    printf ("qd_router_python_setup 2 %p \n", pClass);
     Py_DECREF(pModule);
     QD_ERROR_PY_RET();
 

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/1df96814/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index 0787022..6efd782 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1452,26 +1452,6 @@ void qd_server_run(qd_dispatch_t *qd)
 }
 
 
-void qd_server_start(qd_dispatch_t *qd)
-{
-    qd_server_t *qd_server = qd->server;
-    int i;
-
-    if (!qd_server)
-        return;
-
-    assert(qd_server->conn_handler); // Server can't run without a connection handler.
-
-    for (i = 0; i < qd_server->thread_count; i++)
-        thread_start(qd_server->threads[i]);
-
-    qd_server->heartbeat_timer = qd_timer(qd, heartbeat_cb, qd_server);
-    qd_timer_schedule(qd_server->heartbeat_timer, HEARTBEAT_INTERVAL);
-
-    qd_server_announce(qd_server);
-}
-
-
 void qd_server_stop(qd_dispatch_t *qd)
 {
     qd_server_t *qd_server = qd->server;


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


Mime
View raw message