You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by fa...@apache.org on 2013/04/08 17:19:09 UTC

svn commit: r1465662 [13/26] - in /qpid/trunk/qpid/tools/src/java: ./ bin/ bin/qpid-web/ bin/qpid-web/authentication/ bin/qpid-web/web/ bin/qpid-web/web/itablet/ bin/qpid-web/web/itablet/css/ bin/qpid-web/web/itablet/images/ bin/qpid-web/web/itablet/im...

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaObjectClass.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaObjectClass.java?rev=1465662&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaObjectClass.java (added)
+++ qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaObjectClass.java Mon Apr  8 15:19:04 2013
@@ -0,0 +1,378 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.qmf2.common;
+
+// Misc Imports
+import java.security.MessageDigest;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Subclass of SchemaClass.
+ * <p>
+ * The structure of QmfData objects is formally defined by the class SchemaObjectClass.
+ * <p>
+ * Agent applications may dynamically construct instances of these objects by adding properties and methods
+ * at run time. However, once the Schema is made public, it must be considered immutable, as the hash value
+ * must be constant once the Schema is in use.
+ * <p>
+ * Note that <a href=https://cwiki.apache.org/qpid/qmfv2-api-proposal.html>QMF2 API</a> suggests that
+ * the properties and methods are represented by an unordered map of SchemaProperty or SchemaMethod entries indexed by
+ * property or method name, however these are actually represented in the QMF2 protocol as a "List of SCHEMA_PROPERTY
+ * and "List of SCHEMA_METHOD" elements that describe the schema objects's properties and methods". In this
+ * implementation getProperties() returns a List<SchemaProperty> and getMethods() returns a List<SchemaMethod>
+ * reflecting the reality of the protocol rather than what is suggested by the API documentation.
+ *
+ * @author Fraser Adams
+ */
+public final class SchemaObjectClass extends SchemaClass
+{
+    private List<SchemaMethod>   _methods = new ArrayList<SchemaMethod>();
+    private List<SchemaProperty> _properties = new ArrayList<SchemaProperty>();
+    private String[]             _idNames = {};
+
+    /**
+     * The main constructor, taking a java.util.Map as a parameter.
+     *
+     * @param m the map used to construct the SchemaObjectClass.
+     */
+    public SchemaObjectClass(final Map m)
+    {
+       super(m);
+        if (m != null)
+        {
+            List<Map> mapEncodedMethods = this.<List<Map>>getValue("_methods");
+            if (mapEncodedMethods != null)
+            { // In theory this shouldn't be null as "_methods" property of SchemaClass is not optional but.....
+                for (Map method : mapEncodedMethods)
+                {
+                    addMethod(new SchemaMethod(method));
+                }
+            }
+
+            List<Map> mapEncodedProperties = this.<List<Map>>getValue("_properties");
+            if (mapEncodedProperties != null)
+            { // In theory this shouldn't be null as "_properties" property of SchemaClass is not optional but.....
+                for (Map property : mapEncodedProperties)
+                {
+                    addProperty(new SchemaProperty(property));
+                }
+            }
+        }
+    }
+
+    /**
+     * Construct a SchemaObjectClass from a package name and a class name.
+     *
+     * @param packageName the package name.
+     * @param className the class name.
+     */
+    public SchemaObjectClass(final String packageName, final String className)
+    {
+        setClassId(new SchemaClassId(packageName, className, "_data"));
+    }
+
+    /**
+     * Construct a SchemaObjectClass from a SchemaClassId.
+     *
+     * @param classId the SchemaClassId identifying this SchemaObjectClass.
+     */
+    public SchemaObjectClass(final SchemaClassId classId)
+    {
+        setClassId(new SchemaClassId(classId.getPackageName(), classId.getClassName(), "_data"));
+    }
+
+    /**
+     * Return optional string description of this Schema Object.
+     * @return optional string description of this Schema Object.
+     */
+    public String getDesc()
+    {
+        return getStringValue("_desc");
+    }
+
+    /**
+     * Set the Schema Object's description.
+     *
+     * @param description optional string description of this Schema Object.
+     */
+    public void setDesc(final String description)
+    {
+        setValue("_desc", description);
+    }
+
+    /**
+     * Return the list of property names to use when constructing the object identifier.
+     * <p>
+     * Get the value of the list of property names to use when constructing the object identifier.    
+     * When a QmfAgentData object is created the values of the properties specified here are used to
+     * create the associated ObjectId object name.
+     * @return the list of property names to use when constructing the object identifier.
+     */
+    public String[] getIdNames()
+    {
+        // As it's not performance critical copy _idNames, because "return _idNames;" causes findBugs to moan.
+        return Arrays.copyOf(_idNames, _idNames.length);
+    }
+
+    /**
+     * Return the count of SchemaProperties in this instance.
+     * @return the count of SchemaProperties in this instance.
+     */
+    public long getPropertyCount()
+    {
+        return getProperties().size();
+    }
+
+    /**
+     * Return Schema Object's properties.
+     * <p>
+     * Note that <a href=https://cwiki.apache.org/qpid/qmfv2-api-proposal.html>QMF2 API</a> suggests that
+     * the properties are represented by an unordered map of SchemaProperty indexed by property name, however it
+     * is actually represented in the QMF2 protocol as a "List of SCHEMA_PROPERTY elements that describe the
+     * schema objects's properties. In this implementation getProperties() returns a List<SchemaProperty> 
+     * reflecting the reality of the protocol rather than what is suggested by the API documentation.
+     *
+     * @return Schema Object's properties.
+     */
+    public List<SchemaProperty> getProperties()
+    {
+        return _properties;
+    }
+
+    /**
+     * Return the SchemaProperty for the parameter "name".
+     * @param name the name of the SchemaProperty to return.
+     * @return the SchemaProperty for the parameter "name".
+     */
+    public SchemaProperty getProperty(final String name)
+    {
+        for (SchemaProperty p : _properties)
+        {
+            if (p.getName().equals(name))
+            {
+                return p;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Return the SchemaProperty for the index i.
+     * @param i the index of the SchemaProperty to return.
+     * @return the SchemaProperty for the index i.
+     */
+    public SchemaProperty getProperty(final int i)
+    {
+        return _properties.get(i);
+    }
+
+    /**
+     * Return the count of SchemaMethod's in this instance.
+     * @return the count of SchemaMethod's in this instance.
+     */
+    public long getMethodCount()
+    {
+        return getMethods().size();
+    }
+
+    /**
+     * Return Schema Object's methods.
+     * <p>
+     * Note that <a href=https://cwiki.apache.org/qpid/qmfv2-api-proposal.html>QMF2 API</a> suggests that
+     * the methods are represented by an unordered map of SchemaMethod indexed by method name, however it
+     * is actually represented in the QMF2 protocol as a "List of SCHEMA_METHOD elements that describe the
+     * schema objects's methods. In this implementation getMethods() returns a List<SchemaMethod> 
+     * reflecting the reality of the protocol rather than what is suggested by the API documentation.
+     *
+     * @return Schema Object's methods.
+     */
+    public List<SchemaMethod> getMethods()
+    {
+        return _methods;
+    }
+
+    /**
+     * Return the SchemaMethod for the parameter "name".
+     * @param name the name of the SchemaMethod to return.
+     * @return the SchemaMethod for the parameter "name".
+     */
+    public SchemaMethod getMethod(final String name)
+    {
+        for (SchemaMethod m : _methods)
+        {
+            if (m.getName().equals(name))
+            {
+                return m;
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Return the SchemaMethod for the index i.
+     * @param i the index of the SchemaMethod to return.
+     * @return the SchemaMethod for the index i.
+     */
+    public SchemaMethod getMethod(final int i)
+    {
+        return _methods.get(i);
+    }
+
+    /**
+     * Add a new Property.
+     *
+     * @param name the name of the SchemaProperty.
+     * @param value the SchemaProperty associated with "name".
+     */
+    public void addProperty(final String name, final SchemaProperty value)
+    {
+        value.setValue("_name", name);
+        _properties.add(value);
+    }
+
+    /**
+     * Add a new Property.
+     *
+     * @param value the SchemaProperty associated with "name".
+     */
+    public void addProperty(final SchemaProperty value)
+    {
+        _properties.add(value);
+    }
+
+    /**
+     * Add a new Method.
+     *
+     * @param name the name of the SchemaMethod.
+     * @param value the SchemaMethod associated with "name".
+     */
+    public void addMethod(final String name, final SchemaMethod value)
+    {
+        value.setValue("_name", name);
+        _methods.add(value);
+    }
+
+    /**
+     * Add a new Method.
+     *
+     * @param value the SchemaMethod associated with "name".
+     */
+    public void addMethod(final SchemaMethod value)
+    {
+        _methods.add(value);
+    }
+
+    /**
+     * Set the value of the list of property names to use when constructing the object identifier. 
+     * <p>   
+     * When a QmfAgentData object is created the values of the properties specified here are used to
+     * create the associated ObjectId object name.
+     * @param idNames the list of property names to use when constructing the object identifier.
+     */
+    public void setIdNames(final String... idNames)
+    {
+        _idNames = idNames;
+    }
+
+    /**
+     * Helper/debug method to list the QMF Object properties and their type.
+     */
+    @Override
+    public void listValues()
+    {
+        System.out.println("SchemaObjectClass:");
+        getClassId().listValues();
+
+        if (hasValue("_desc")) System.out.println("desc: " + getDesc());
+
+        if (getMethodCount() > 0)
+        {
+            System.out.println("methods:");
+        }
+        for (SchemaMethod m : _methods)
+        {
+            m.listValues();
+        }
+
+        if (getPropertyCount() > 0)
+        {
+            System.out.println("properties:");
+        }
+        for (SchemaProperty p : _properties)
+        {
+            p.listValues();
+        }
+    }
+
+    /**
+     * Return the underlying map. 
+     * <p>
+     * We need to convert any methods from SchemaMethod to Map and any properties from SchemaProperty to Map
+     *
+     * @return the underlying map. 
+     */
+    @Override
+    public Map<String, Object> mapEncode()
+    {
+        List<Map> mapEncodedMethods = new ArrayList<Map>();
+        for (SchemaMethod m : _methods)
+        {
+            mapEncodedMethods.add(m.mapEncode());
+        }
+        setValue("_methods", mapEncodedMethods);
+
+        List<Map> mapEncodedProperties = new ArrayList<Map>();
+        for (SchemaProperty p : _properties)
+        {
+            mapEncodedProperties.add(p.mapEncode());
+        }
+        setValue("_properties", mapEncodedProperties);
+
+        setValue("_schema_id", getClassId().mapEncode());
+
+        return super.mapEncode();
+    }
+
+    /**
+     * Generate the partial hash for the schema fields in this class.
+     * @param md5 the MessageDigest to be updated.
+     */
+    @Override
+    protected void updateHash(MessageDigest md5)
+    {
+        super.updateHash(md5);
+
+        for (SchemaMethod m : _methods)
+        {
+            m.updateHash(md5);
+        }
+
+        for (SchemaProperty p : _properties)
+        {
+            p.updateHash(md5);
+        }
+    }
+}
+

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaObjectClass.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaObjectClass.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaProperty.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaProperty.java?rev=1465662&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaProperty.java (added)
+++ qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaProperty.java Mon Apr  8 15:19:04 2013
@@ -0,0 +1,364 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.qmf2.common;
+
+// Misc Imports
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.util.Map;
+
+// Reuse this class as it provides a handy mechanism to parse an options String into a Map
+import org.apache.qpid.messaging.util.AddressParser;
+
+/**
+ * The SchemaProperty class describes a single data item in a QmfData object. A SchemaProperty is a list of
+ * named attributes and their values. QMF defines a set of primitive attributes. An application can extend
+ * this set of attributes with application-specific attributes.
+ * <p>
+ * QMF reserved attribute names all start with the underscore character ("_"). Do not create an application-specific
+ * attribute with a name starting with an underscore.
+ * <p>
+ * Once instantiated, the SchemaProperty is immutable.
+ * <p>
+ * Note that there appear to be some differences between the fields mentioned in
+ * <a href=https://cwiki.apache.org/qpid/qmfv2-api-proposal.html>QMF2 API propsal</a> and
+ * <a href=https://cwiki.apache.org/qpid/qmf-map-message-protocol.html>QMF2 Map Message protocol</a>.
+ * I've gone with what's stated in the protocol documentation as this seems more accurate, at least for Qpid 0.10
+ *
+ * @author Fraser Adams
+ */
+public final class SchemaProperty extends QmfData
+{
+    /**
+     * Construct a SchemaProperty from its Map representation.
+     */
+    public SchemaProperty(final Map m)
+    {
+       super(m);
+    }
+
+    /**
+     * Construct a SchemaProperty from its name and type.
+     *
+     * @param name the name of the SchemaProperty.
+     * @param type the QmfType of the SchemaProperty.
+     */
+    public SchemaProperty(final String name, final QmfType type) throws QmfException
+    {
+        this(name, type, null);
+    }
+
+    /**
+     * Construct a SchemaProperty from its name, type and options.
+     *
+     * @param name the name of the SchemaProperty.
+     * @param type the QmfType of the SchemaProperty.
+     * @param options a String containing the SchemaProperty options in the form:
+     * <pre>
+     * "{&lt;option1&gt;: &lt;value1&gt;, &lt;option2&gt;: &lt;value2&gt;}".
+     * </pre>
+     * Example:
+     * <pre>
+     * "{dir:IN, unit:metre, min:1, max:5, desc: 'ladder extension range'}"
+     * </pre>
+     */
+    public SchemaProperty(final String name, final QmfType type, final String options) throws QmfException
+    {
+        setValue("_name", name);
+        setValue("_type", type.toString());
+
+        if (options != null && options.length() != 0)
+        {
+            Map optMap = new AddressParser(options).map();
+
+            if (optMap.containsKey("index"))
+            {
+                String value = optMap.get("index").toString();
+                setValue("_index", Boolean.valueOf(value));
+            }
+
+            if (optMap.containsKey("access"))
+            {
+                String value = (String)optMap.get("access");
+                if (value.equals("RC") || value.equals("RO") || value.equals("RW"))
+                {
+                    setValue("_access", value);
+                }
+                else
+                {
+                    throw new QmfException("Invalid value for 'access' option. Expected RC, RO, or RW");
+                }
+            }
+
+            if (optMap.containsKey("unit"))
+            {
+                String value = (String)optMap.get("unit");
+                setValue("_unit", value);
+            }
+
+            if (optMap.containsKey("min"))
+            { // Slightly odd way of parsing, but AddressParser stores integers as Integer, which seems OK but it limits
+              // things like queue length to 2GB. I think this should change so this code deliberately avoids assuming
+              // integers are encoded as Integer by using the String representation instead.
+                long value = Long.parseLong(optMap.get("min").toString());
+                setValue("_min", value);
+            }
+
+            if (optMap.containsKey("max"))
+            { // Slightly odd way of parsing, but AddressParser stores integers as Integer. which seems OK but it limits
+              // things like queue length to 2GB. I think this should change so this code deliberately avoids assuming
+              // integers are encoded as Integer by using the String representation instead.
+                long value = Long.parseLong(optMap.get("max").toString());
+                setValue("_max", value);
+            }
+
+            if (optMap.containsKey("maxlen"))
+            { // Slightly odd way of parsing, but AddressParser stores integers as Integer, which seems OK but it limits
+              // things like queue length to 2GB. I think this should change so this code deliberately avoids assuming
+              // integers are encoded as Integer by using the String representation instead.
+                long value = Long.parseLong(optMap.get("maxlen").toString());
+                setValue("_maxlen", value);
+            }
+
+            if (optMap.containsKey("desc"))
+            {
+                String value = (String)optMap.get("desc");
+                setValue("_desc", value);
+            }
+
+            if (optMap.containsKey("dir"))
+            {
+                String value = (String)optMap.get("dir");
+                if (value.equals("IN"))
+                {
+                    setValue("_dir", "I");
+                }
+                else if (value.equals("OUT"))
+                {
+                    setValue("_dir", "O");
+                }
+                else if (value.equals("INOUT"))
+                {
+                    setValue("_dir", "IO");
+                }
+                else
+                {
+                    throw new QmfException("Invalid value for 'dir' option. Expected IN, OUT, or INOUT");
+                }
+            }
+
+            if (optMap.containsKey("subtype"))
+            {
+                String value = (String)optMap.get("subtype");
+                setValue("_subtype", value);
+            }
+        }
+    }
+
+    /**
+     * Return the property's name.
+     * @return the property's name.
+     */
+    public String getName()
+    {
+        return getStringValue("_name");
+    }
+
+    /**
+     * Return the property's QmfType.
+     * @return the property's QmfType.
+     */
+    public QmfType getType()
+    {
+        return QmfType.valueOf(getStringValue("_type"));
+    }
+
+    /**
+     * Return true iff this property is an index of an object.
+     * @return true iff this property is an index of an object. Default is false.
+     */
+    public boolean isIndex()
+    {
+        return hasValue("_index") ? getBooleanValue("_index") : false;
+    }
+
+    /**
+     * Return true iff this property is optional.
+     * @return true iff this property is optional. Default is false.
+     */
+    public boolean isOptional()
+    {
+        return hasValue("_optional") ? getBooleanValue("_optional") : false;
+    }
+
+    /**
+     * Return the property's remote access rules.
+     * @return the property's remote access rules "RC"=read/create, "RW"=read/write, "RO"=read only (default).
+     */
+    public String getAccess()
+    {
+        return getStringValue("_access");
+    }
+
+    /**
+     * Return an annotation string describing units of measure for numeric values (optional).
+     * @return an annotation string describing units of measure for numeric values (optional).
+     */
+    public String getUnit()
+    {
+        return getStringValue("_unit");
+    }
+
+    /**
+     * Return minimum value (optional).
+     * @return minimum value (optional).
+     */
+    public long getMin()
+    {
+        return getLongValue("_min");
+    }
+
+    /**
+     * Return maximum value (optional).
+     * @return maximum value (optional).
+     */
+    public long getMax()
+    {
+        return getLongValue("_max");
+    }
+
+    /**
+     * Return maximum length for string values (optional).
+     * @return maximum length for string values (optional).
+     */
+    public long getMaxLen()
+    {
+        return getLongValue("_maxlen");
+    }
+
+    /**
+     * Return optional string description of this Property.
+     * @return optional string description of this Property.
+     */
+    public String getDesc()
+    {
+        return getStringValue("_desc");
+    }
+
+    /**
+     * Return the direction of information travel.
+     * @return "I"=input, "O"=output, or "IO"=input/output (required for method arguments, otherwise optional).
+     */
+    public String getDirection()
+    {
+        return getStringValue("_dir");
+    }
+
+    /**
+     * Return string indicating the formal application type.
+     * @return string indicating the formal application type for the data, example: "URL", "Telephone number", etc.
+     */
+    public String getSubtype()
+    {
+        return getStringValue("_subtype");
+    }
+
+    /**
+     * Return a SchemaClassId. If the type is a reference to another managed object.
+     * @return a SchemaClassId. If the type is a reference to another managed object, this field may be used.
+               to specify the required class for that object 
+     */
+    public SchemaClassId getReference()
+    {
+        return new SchemaClassId((Map)getValue("_references"));
+    }
+
+    /**
+     * Return the value of the attribute named "name".
+     * @return the value of the attribute named "name".
+     * <p>
+     * This method can be used to retrieve application-specific attributes. "name" should start with the prefix "x-".
+     */
+    public String getAttribute(final String name)
+    {
+        return getStringValue(name);
+    }
+
+    /**
+     * Generate the partial hash for the schema fields in this class.
+     * @param md5 the MessageDigest to be updated
+     */
+    protected void updateHash(MessageDigest md5)
+    {
+        try
+        {
+            md5.update(getName().getBytes("UTF-8"));
+            md5.update(getType().toString().getBytes("UTF-8"));
+            md5.update(getSubtype().getBytes("UTF-8"));
+            md5.update(getAccess().getBytes("UTF-8"));
+            if (isIndex())
+            {
+                md5.update((byte)1);
+            }
+            else
+            {
+                md5.update((byte)0);
+            }
+            if (isOptional())
+            {
+                md5.update((byte)1);
+            }
+            else
+            {
+                md5.update((byte)0);
+            }
+            md5.update(getUnit().getBytes("UTF-8"));
+            md5.update(getDesc().getBytes("UTF-8"));
+            md5.update(getDirection().getBytes("UTF-8"));
+        }
+        catch (UnsupportedEncodingException uee)
+        {
+        }
+    }
+
+    /**
+     * Helper/debug method to list the QMF Object properties and their type.
+     */
+    @Override
+    public void listValues()
+    {
+        System.out.println("SchemaProperty:");
+        System.out.println("_name: " + getName());
+        System.out.println("_type: " + getType());
+        if (hasValue("_index")) System.out.println("is index: " + isIndex());
+        if (hasValue("_optional")) System.out.println("is optional: " + isOptional());
+        if (hasValue("_access")) System.out.println("access: " + getAccess());
+        if (hasValue("_unit")) System.out.println("unit: " + getUnit());
+        if (hasValue("_min")) System.out.println("min: " + getMin());
+        if (hasValue("_max")) System.out.println("max: " + getMax());
+        if (hasValue("_max_len")) System.out.println("maxlen: " + getMaxLen());
+        if (hasValue("_desc")) System.out.println("desc: " + getDesc());
+        if (hasValue("_dir")) System.out.println("dir: " + getDirection());
+        if (hasValue("_subtype")) System.out.println("subtype: " + getSubtype());
+        if (hasValue("_references")) System.out.println("reference: " + getReference());
+    }
+}
+

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaProperty.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/SchemaProperty.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkItem.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkItem.java?rev=1465662&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkItem.java (added)
+++ qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkItem.java Mon Apr  8 15:19:04 2013
@@ -0,0 +1,399 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.qmf2.common;
+
+import java.util.HashMap;
+import java.util.Map;
+
+// QMF2 Imports
+import org.apache.qpid.qmf2.console.Agent;
+
+/**
+ * Descriptions below are taken from <a href=https://cwiki.apache.org/qpid/qmfv2-api-proposal.html>QMF2 API Proposal</a> 
+ * <p>
+ * A WorkItem describes an event that has arrived for the application to process.
+ * <p>
+ * The Notifier is invoked when one or more WorkItems become available for processing.
+ * <p>
+ * The type of the Object returned by getParams is determined by the WorkItemType and described below.
+ * <p>
+ *
+ * <table width="100%" border="1"><thead><tr><th>WorkItem Type</th><th>Description</th></tr></thead><tbody>
+ *
+ *
+ * <tr>
+ * <td>AGENT_ADDED:</td>
+ * <td>
+ * When the QMF Console receives the first heartbeat from an Agent, an AGENT_ADDED WorkItem is pushed onto the
+ * work-queue.
+ * <p>
+ * The getParams() method returns a map which contains a reference to the new Console Agent instance. The reference is
+ * indexed from the map using the key string "agent". There is no handle associated with this WorkItem.
+ * <p>
+ * Note: If a new Agent is discovered as a result of the Console findAgent() method, then no AGENT_ADDED WorkItem is 
+ * generated for that Agent.
+ * <p>
+ * Use AgentAddedWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>AGENT_DELETED:</td>
+ * <td>
+ * When a known Agent stops sending heartbeat messages the Console will time out that Agent. On Agent timeout, an  
+ * AGENT_DELETED WorkItem is pushed onto the work-queue.
+ * <p>
+ * The getParams() method returns a map which contains a reference to the Agent instance that has been deleted.
+ * The reference is indexed from the map using the key string "agent". There is no handle associated with this WorkItem.
+ * <p>
+ * The Console application must release all saved references to the Agent before returning the WorkItem.
+ * <p>
+ * Use AgentDeletedWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>AGENT_RESTARTED:</td>
+ * <td>
+ * Sent when the QMF Console detects an Agent was restarted, an AGENT_RESTARTED WorkItem is pushed onto the work-queue.
+ * <p>
+ * The getParams() method returns a map which contains a reference to the Console Agent instance. The reference
+ * is indexed from the map using the key string "agent". There is no handle associated with this WorkItem.
+ * <p>
+ * Use AgentRestartedWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>AGENT_HEARTBEAT:</td>
+ * <td>
+ * When the QMF Console receives heartbeats from an Agent, an AGENT_HEARTBEAT WorkItem is pushed onto the work-queue.
+ * <p>
+ * The getParams() method returns a map which contains a reference to the Console Agent instance. The reference
+ * is indexed from the map using the key string "agent". There is no handle associated with this WorkItem.
+ * <p>
+ * Note: the first heartbeat results in an AGENT_ADDED WorkItem for Agent not an AGENT_HEARTBEAT.
+ * <p>
+ * Use AgentHeartbeatWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>NEW_PACKAGE:</td><td>TBD</td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>NEW_CLASS:</td><td>TBD</td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>OBJECT_UPDATE:</td>
+ * <td>
+ * The OBJECT_UPDATE WorkItem is generated in response to an asynchronous refresh made by a QmfConsoleData object.
+ * <p>
+ * The getParams() method will return a QmfConsoleData.
+ * <p>
+ * The getHandle() method returns the reply handle provided to the refresh() method call.
+ * This handle is merely the handle used for the asynchronous response, it is not associated with the QmfConsoleData
+ * in any other way.
+ * <p>
+ * Use ObjectUpdateWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>METHOD_RESPONSE:</td>
+ * <td>
+ * The METHOD_RESPONSE WorkItem is generated in response to an asynchronous invokeMethod made by a QmfConsoleData object.
+ * <p>
+ * The getParams() method will return a MethodResult object.
+ * <p>
+ * The getHandle() method returns the reply handle provided to the refresh() method call.
+ * This handle is merely the handle used for the asynchronous response, it is not associated with the QmfConsoleData
+ * in any other way.
+ * <p>
+ * Use MethodResponseWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>EVENT_RECEIVED:</td>
+ * <td>
+ * When an Agent generates a QmfEvent an EVENT_RECEIVED WorkItem is pushed onto the work-queue.
+ * <p>
+ * The getParams() method returns a map which contains a reference to the Console Agent instance that generated
+ * the Event and a reference to the QmfEvent itself. The Agent reference is indexed from the map using the key string
+ * "agent, The QmfEvent reference is indexed from the map using the key string "event". There is no handle associated
+ * with this WorkItem.
+ * <p>
+ * Use EventReceivedWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>SUBSCRIBE_RESPONSE:</td>
+ * <td>
+ * The SUBSCRIBE_RESPONSE WorkItem returns the result of a subscription request made by this Console. This WorkItem is 
+ * generated when the Console's createSubscription() is called in an asychronous manner, rather than pending for the result. 
+ * <p>
+ * The getParams() method will return an instance of the SubscribeParams class.
+ * <p>
+ * The SubscriptionId object must be used when the subscription is refreshed or cancelled. It must be passed to the
+ * Console's refresh_subscription() and cancelSubscription() methods. The value of the SubscriptionId does not change
+ * over the lifetime of the subscription.
+ * <p>
+ * The console handle will be provided by the Agent on each data indication event that corresponds to this subscription.
+ * It should not change for the lifetime of the subscription.
+ * <p>
+ * The getHandle() method returns the reply handle provided to the createSubscription() method call. This handle is
+ * merely the handle used for the asynchronous response, it is not associated with the subscription in any other way.
+ * <p>
+ * Once a subscription is created, the Agent that maintains the subscription will periodically issue updates for the 
+ * subscribed data. This update will contain the current values of the subscribed data, and will appear as the first 
+ * SUBSCRIPTION_INDICATION WorkItem for this subscription.
+ * <p>
+ * Use SubscribeResponseWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>SUBSCRIPTION_INDICATION:</td>
+ * <td>
+ * The SUBSCRIPTION_INDICATION WorkItem signals the arrival of an update to subscribed data from the Agent. 
+ * <p>
+ * The getParams() method will return an instance of the SubscribeIndication class. 
+ * The getHandle() method returns null.
+ * <p>
+ * Use SubscriptionIndicationWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>RESUBSCRIBE_RESPONSE:</td>
+ * <td>
+ * The RESUBSCRIBE_RESPONSE WorkItem is generated in response to a subscription refresh request made by this Console.
+ * This WorkItem is generated when the Console's refreshSubscription() is called in an asychronous manner, rather than 
+ * pending for the result. 
+ * <p>
+ * The getParams() method will return an instance of the SubscribeParams class.
+ * <p>
+ * The getHandle() method returns the reply handle provided to the refreshSubscription() method call. This handle is
+ * merely the handle used for the asynchronous response, it is not associated with the subscription in any other way.
+ * <p>
+ * Use ResubscribeResponseWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>METHOD_CALL:</td>
+ * <td>
+ * The METHOD_CALL WorkItem describes a method call that must be serviced by the application on behalf of this Agent.
+ * <p>
+ * The getParams() method will return an instance of the MethodCallParams class.
+ * <p>
+ * Use MethodCallWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>QUERY:</td>
+ * <td>
+ * The QUERY WorkItem describes a query that the application must service. The application should call the 
+ * queryResponse() method for each object that satisfies the query. When complete, the application must call the 
+ * queryComplete() method. If a failure occurs, the application should indicate the error to the agent by calling
+ * the query_complete() method with a description of the error.
+ * <p>
+ * The getParams() method will return an instance of the QmfQuery class.
+ * <p>
+ * The getHandle() WorkItem method returns the reply handle which should be passed to the Agent's queryResponse()
+ * and queryComplete() methods.
+ * <p>
+ * Use QueryWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>SUBSCRIBE_REQUEST:</td>
+ * <td>
+ * The SUBSCRIBE_REQUEST WorkItem provides a query that the agent application must periodically publish until the 
+ * subscription is cancelled or expires. On receipt of this WorkItem, the application should call the Agent 
+ * subscriptionResponse() method to acknowledge the request. On each publish interval, the application should call Agent 
+ * subscriptionIndicate(), passing a list of the objects that satisfy the query. The subscription remains in effect until
+ * an UNSUBSCRIBE_REQUEST WorkItem for the subscription is received, or the subscription expires.
+ * <p>
+ * The getParams() method will return an instance of the SubscriptionParams class.
+ * <p>
+ * The getHandle() WorkItem method returns the reply handle which should be passed to the Agent's 
+ * subscriptionResponse() method.
+ * <p>
+ * Use SubscribeRequestWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>RESUBSCRIBE_REQUEST:</td>
+ * <td>
+ * The RESUBSCRIBE_REQUEST is sent by a Console to renew an existing subscription. The Console may request a new
+ * duration for the subscription, otherwise the previous lifetime interval is repeated.
+ * <p>
+ * The getParams() method will return an instance of the ResubscribeParams class.
+ * <p>
+ * The getHandle() WorkItem method returns the reply handle which should be passed to the Agent's 
+ * subscriptionResponse() method.
+ * <p>
+ * Use ResubscribeRequestWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ *
+ *
+ * <tr>
+ * <td>UNSUBSCRIBE_REQUEST:</td>
+ * <td>
+ * The UNSUBSCRIBE_REQUEST is sent by a Console to terminate an existing subscription. The Agent application should
+ * terminate the given subscription if it exists, and cancel sending any further updates against it.
+ * <p>
+ * The getParams() method will return a String holding the subscriptionId.
+ * <p>
+ * The getHandle() method returns null.
+ * <p>
+ * Use UnsubscribeRequestWorkItem to enable neater access.
+ * </td>
+ * </tr>
+ * </table>
+ * <p>
+ * The following diagram illustrates the QMF2 WorkItem class hierarchy.
+ * <p>
+ * <img src="doc-files/WorkItem.png"/>
+ * @author Fraser Adams
+ */
+
+public class WorkItem
+{
+    /**
+     * An Enumeration of the types of WorkItems produced on the Console or Agent.
+     */
+    public enum WorkItemType
+    {
+        // Enumeration of the types of WorkItems produced on the Console
+        AGENT_ADDED,
+        AGENT_DELETED,
+        AGENT_RESTARTED,
+        AGENT_HEARTBEAT,
+        NEW_PACKAGE,
+        NEW_CLASS,
+        OBJECT_UPDATE,
+        EVENT_RECEIVED,
+        METHOD_RESPONSE,
+        SUBSCRIBE_RESPONSE,
+        SUBSCRIPTION_INDICATION,
+        RESUBSCRIBE_RESPONSE,
+        // Enumeration of the types of WorkItems produced on the Agent
+        METHOD_CALL,
+        QUERY,
+        SUBSCRIBE_REQUEST,
+        RESUBSCRIBE_REQUEST,
+        UNSUBSCRIBE_REQUEST;
+    }
+
+    private final WorkItemType _type;
+    private final Handle       _handle;
+    private final Object       _params;
+
+    /**
+     * Construct a WorkItem
+     *
+     * @param type the type of WorkItem specified by the WorkItemType enum
+     * @param handle the handle passed by async calls - the correlation ID
+     * @param params the payload of the WorkItem
+     */
+    public WorkItem(WorkItemType type, Handle handle, Object params)
+    {
+        _type = type;
+        _handle = handle;
+        _params = params;
+    }
+
+    /**
+     * Return the type of work item.
+     * @return the type of work item.
+     */
+    public final WorkItemType getType()
+    {
+        return _type;
+    }
+
+    /**
+     * Return the reply handle for an asynchronous operation, if present.
+     * @return the reply handle for an asynchronous operation, if present.
+     */
+    public final Handle getHandle()
+    {
+        return _handle;
+    }
+
+    /**              
+     * Return the payload of the work item.
+     * @return the payload of the work item.
+     * <p>
+     * The type of this object is determined by the type of the workitem as follows:
+     * <pre>
+     * <b>Console</b>
+     * AGENT_ADDED: Map{"agent":Agent}                      - Use AgentAddedWorkItem to enable neater access
+     * AGENT_DELETED: Map{"agent":Agent}                    - Use AgentDeletedWorkItem to enable neater access
+     * AGENT_RESTARTED: Map{"agent":Agent}                  - Use AgentRestartedWorkItem to enable neater access
+     * AGENT_HEARTBEAT: Map{"agent":Agent}                  - Use AgentHeartbeatWorkItem to enable neater access
+     * OBJECT_UPDATE: QmfConsoleData                        - Use ObjectUpdateWorkItem to enable neater access
+     * METHOD_RESPONSE: MethodResult                        - Use MethodResponseWorkItem to enable neater access
+     * EVENT_RECEIVED: Map{"agent":Agent, "event":QmfEvent} - Use EventReceivedWorkItem to enable neater access
+     * SUBSCRIBE_RESPONSE: SubscribeParams                  - Use SubscribeResponseWorkItem to enable neater access
+     * SUBSCRIPTION_INDICATION: SubscribeIndication         - Use SubscriptionIndicationWorkItem to enable neater access
+     * RESUBSCRIBE_RESPONSE: SubscribeParams                - Use ResubscribeResponseWorkItem to enable neater access
+     *
+     * <b>Agent</b>
+     * METHOD_CALL: MethodCallParams                        - Use MethodCallWorkItem to enable neater access
+     * QUERY: QmfQuery                                      - Use QueryWorkItem to enable neater access
+     * SUBSCRIBE_REQUEST: SubscriptionParams                - Use SubscribeRequestWorkItem to enable neater access
+     * RESUBSCRIBE_REQUEST: ResubscribeParams               - Use ResubscribeRequestWorkItem to enable neater access
+     * UNSUBSCRIBE_REQUEST: String (subscriptionId)         - Use UnsubscribeRequestWorkItem to enable neater access
+     * </pre>
+     */
+    @SuppressWarnings("unchecked")
+    public final <T> T getParams()
+    {
+        return (T)_params;
+    }
+}
+

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkItem.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkQueue.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkQueue.java?rev=1465662&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkQueue.java (added)
+++ qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkQueue.java Mon Apr  8 15:19:04 2013
@@ -0,0 +1,106 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.qmf2.common;
+
+// Misc Imports
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * This is an implementation of a QMF2 WorkQueue. In practice this is likely to be used by an Agent or Console.
+ *
+ * @author Fraser Adams
+ */
+public class WorkQueue
+{
+    /**
+     * Used to implement a thread safe queue of WorkItem objects
+     */
+    private BlockingQueue<WorkItem> _workQueue = new LinkedBlockingQueue<WorkItem>();
+
+    /**
+     * Return the count of pending WorkItems that can be retrieved.
+     * @return the count of pending WorkItems that can be retrieved.
+     */
+    public int size()
+    {
+        return _workQueue.size();
+    }
+
+    /**
+     * Obtains the next pending work item - blocking version
+     *
+     * @return the next pending work item, or null if none available.
+     */
+    public WorkItem getNextWorkitem()
+    {
+        try
+        {
+            return _workQueue.take();
+        }
+        catch (InterruptedException ie)
+        {
+            return null;
+        }
+    }
+
+    /**
+     * Obtains the next pending work item - balking version
+     *
+     * @param timeout the timeout in seconds. If timeout = 0 it returns immediately with either a WorkItem or null
+     * @return the next pending work item, or null if none available.
+     */
+    public WorkItem getNextWorkitem(long timeout)
+    {
+        try
+        {
+            return _workQueue.poll(timeout, TimeUnit.SECONDS);
+        }
+        catch (InterruptedException ie)
+        {
+            return null;
+        }
+    }
+
+    /**
+     * Adds a WorkItem to the WorkQueue. 
+     *
+     * @param item the WorkItem passed to the WorkQueue
+     */
+    public void addWorkItem(WorkItem item)
+    {
+        // We wrap the blocking put() method in a loop "just in case" InterruptedException occurs
+        // if it does we retry the put otherwise we carry on, notify then exit.
+        while (true)
+        {
+            try
+            {
+                _workQueue.put(item);
+                break;
+            }
+            catch (InterruptedException ie)
+            {
+                continue;
+            }
+        }
+    }
+}

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkQueue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/WorkQueue.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/Console.png
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/Console.png?rev=1465662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/Console.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/QmfData.png
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/QmfData.png?rev=1465662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/QmfData.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/QmfEventListenerModel.png
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/QmfEventListenerModel.png?rev=1465662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/QmfEventListenerModel.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/QmfQuery.png
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/QmfQuery.png?rev=1465662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/QmfQuery.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/Schema.png
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/Schema.png?rev=1465662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/Schema.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/Subscriptions.png
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/Subscriptions.png?rev=1465662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/Subscriptions.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/WorkItem.png
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/WorkItem.png?rev=1465662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/WorkItem.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/WorkQueueEventModel.png
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/WorkQueueEventModel.png?rev=1465662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/common/doc-files/WorkQueueEventModel.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/Agent.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/Agent.java?rev=1465662&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/Agent.java (added)
+++ qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/Agent.java Mon Apr  8 15:19:04 2013
@@ -0,0 +1,482 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.qmf2.console;
+
+// Misc Imports
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+// QMF2 Imports
+import org.apache.qpid.qmf2.common.ObjectId;
+import org.apache.qpid.qmf2.common.QmfData;
+import org.apache.qpid.qmf2.common.QmfException;
+import org.apache.qpid.qmf2.common.SchemaClass;
+import org.apache.qpid.qmf2.common.SchemaClassId;
+
+/**
+ * Local representation (proxy) of a remote Agent.
+ * <p>
+ * This class holds some state that relates to the Agent and in addition some methods may be called on the agent.
+ * destroy(), invokeMethod() and refresh() are actually called by a proxy class AgentProxy. AgentProxy is actually
+ * an interface that is implemented by Console (as that's where all the JMS stuff is), we use this approach to 
+ * avoid introducing a circular dependency between Agent and Console.
+ * <p>
+ * The Console application maintains a list of all known remote Agents.
+ * Each Agent is represented by an instance of the Agent class:
+ * <p>
+ * The following diagram illustrates the interactions between the Console, AgentProxy and the client side Agent
+ * representation.
+ * <p>
+ * <img src="doc-files/Subscriptions.png"/>
+ * @author Fraser Adams
+ */
+public final class Agent extends QmfData
+{
+    private AgentProxy                      _proxy;
+    private List<String>                    _packages = new ArrayList<String>();
+    private Map<SchemaClassId, SchemaClass> _schemaCache = new ConcurrentHashMap<SchemaClassId, SchemaClass>();
+    private long                            _epoch;
+    private long                            _heartbeatInterval;
+    private long                            _timestamp;
+    private boolean                         _eventsEnabled = true;
+    private boolean                         _isActive = true;
+
+    /**
+     * The main constructor, taking a java.util.Map as a parameter. In essence it "deserialises" its state from the Map.
+     *
+     * @param m the map used to construct the SchemaClass
+     * @param p the AgentProxy instance that implements some of the concrete behaviour of the local Agent representation.
+     */
+    public Agent(final Map m, final AgentProxy p)
+    {
+        super(m);
+        // Populate attributes translating any old style keys if necessary.
+        _epoch = hasValue("_epoch") ? getLongValue("_epoch") : getLongValue("epoch");
+        _heartbeatInterval = hasValue("_heartbeat_interval") ? getLongValue("_heartbeat_interval") : 
+                                                               getLongValue("heartbeat_interval");
+        _timestamp = hasValue("_timestamp") ? getLongValue("_timestamp") : getLongValue("timestamp");
+        _proxy = p;
+    }
+
+    /**
+     * Sets the state of the Agent, used as an assignment operator.
+     * 
+     * @param m the Map used to initialise the Agent.
+     */
+    @SuppressWarnings("unchecked")
+    public void initialise(final Map m)
+    {        
+        Map<String, Object> values = (Map<String, Object>)m.get("_values");
+        _values = (values == null) ? m : values;
+
+        // Populate attributes translating any old style keys if necessary.
+        _epoch = hasValue("_epoch") ? getLongValue("_epoch") : getLongValue("epoch");
+        _heartbeatInterval = hasValue("_heartbeat_interval") ? getLongValue("_heartbeat_interval") : 
+                                                               getLongValue("heartbeat_interval");
+        _timestamp = hasValue("_timestamp") ? getLongValue("_timestamp") : getLongValue("timestamp");
+    }
+
+    /**
+     * Return whether or not events are enabled for this Agent.
+     * @return a boolean indication of whether or not events are enabled for this Agent.
+     */
+    public boolean eventsEnabled()
+    {
+        return _eventsEnabled;
+    }
+
+    /**
+     * Deactivated this Agent. Called by the Console when the Agent times out.
+     */
+    public void deactivate()
+    {
+        _isActive = false;
+    }
+
+    /**
+     * Return the Agent instance name.
+     * @return the Agent instance name.
+     */
+    public String getInstance()
+    {
+        return getStringValue("_instance");
+    }
+
+    /**
+     * Return the identifying name string of the Agent. 
+     * @return the identifying name string of the Agent. This name is used to send AMQP messages directly to this agent.
+     */
+    public String getName()
+    {
+        return getStringValue("_name");
+    }
+
+    /**
+     * Return the product name string of the Agent.
+     * @return the product name string of the Agent.
+     */
+    public String getProduct()
+    {
+        return getStringValue("_product");
+    }
+
+    /**
+     * Return the Agent vendor name.
+     * @return the Agent vendor name.
+     */
+    public String getVendor()
+    {
+        return getStringValue("_vendor");
+    }
+
+    /**
+     * Return the Epoch stamp.
+     * @return the Epoch stamp, used to determine if an Agent has been restarted.
+     */
+    public long getEpoch()
+    {
+        return _epoch;
+    }
+
+    /**
+     * Set the Epoch stamp.
+     * @param epoch the new Epoch stamp, used to indicate that an Agent has been restarted.
+     */
+    public void setEpoch(long epoch)
+    {
+        _epoch = epoch;
+    }
+
+    /**
+     * Return the time that the Agent waits between sending hearbeat messages.
+     * @return the time that the Agent waits between sending hearbeat messages.
+     */
+    public long getHeartbeatInterval()
+    {
+        return _heartbeatInterval;
+    }
+
+    /**
+     * Return the timestamp of the Agent's last update.
+     * @return the timestamp of the Agent's last update.
+     */
+    public long getTimestamp()
+    {
+        return _timestamp;
+    }
+
+    /**
+     * Return true if the agent is alive.
+     * @return true if the agent is alive (heartbeats have not timed out).
+     */
+    public boolean isActive()
+    {
+        return _isActive;
+    }
+
+    /**
+     * Request that the Agent updates the value of this object's contents.
+     *
+     * @param objectId the ObjectId being queried for..
+     * @param replyHandle the correlation handle used to tie asynchronous method requests with responses.
+     * @param timeout the maximum time to wait for a response, overrides default replyTimeout.
+     * @return the refreshed object.
+     */    
+    public QmfConsoleData refresh(final ObjectId objectId, final String replyHandle, final int timeout) throws QmfException
+    {
+        if (isActive())
+        {
+            return _proxy.refresh(this, objectId, replyHandle, timeout);
+        }
+        else
+        {
+            throw new QmfException("Agent.refresh() called from deactivated Agent");
+        }
+    }
+
+    /**
+     * Helper method to create a Map containing a QMF method request.
+     *
+     * @param objectId the objectId of the remote object.
+     * @param name the remote method name.
+     * @param inArgs the formal parameters of the remote method name.
+     * @return a Map containing a QMF method request.
+     */
+    private Map<String, Object> createRequest(final ObjectId objectId, final String name, final QmfData inArgs)
+    {
+        // Default sizes for HashMap should be fine for request
+        Map<String, Object> request = new HashMap<String, Object>();
+        if (objectId != null)
+        {
+            request.put("_object_id", objectId.mapEncode());
+        }
+        request.put("_method_name", name);
+        if (inArgs != null)
+        {
+            request.put("_arguments", inArgs.mapEncode());
+            if (inArgs.getSubtypes() != null)
+            {
+                request.put("_subtypes", inArgs.getSubtypes());
+            }
+        }
+        return request;
+    }
+
+    /**
+     * Sends a method request to the Agent. Delegates to the AgentProxy to actually send the method as it's the
+     * AgentProxy that knows about connections, sessions and messages.
+     *
+     * @param objectId the objectId of the remote object.
+     * @param name the remote method name.
+     * @param inArgs the formal parameters of the remote method name.
+     * @param timeout the maximum time to wait for a response, overrides default replyTimeout.
+     * @return the MethodResult.
+     */
+    protected MethodResult invokeMethod(final ObjectId objectId, final String name,
+                                        final QmfData inArgs, final int timeout) throws QmfException
+    {
+        if (isActive())
+        {
+            return _proxy.invokeMethod(this, createRequest(objectId, name, inArgs), null, timeout);
+        }
+        else
+        {
+            throw new QmfException("Agent.invokeMethod() called from deactivated Agent");
+        }
+    }
+
+    /**
+     * Sends an asynchronous method request to the Agent. Delegates to the AgentProxy to actually send the method as
+     * it's the AgentProxy that knows about connections, sessions and messages.
+     *
+     * @param objectId the objectId of the remote object.
+     * @param name the remote method name.
+     * @param inArgs the formal parameters of the remote method name.
+     * @param replyHandle the correlation handle used to tie asynchronous method requests with responses.
+     */
+    protected void invokeMethod(final ObjectId objectId, final String name,
+                                final QmfData inArgs, final String replyHandle) throws QmfException
+    {
+        if (isActive())
+        {
+            _proxy.invokeMethod(this, createRequest(objectId, name, inArgs), replyHandle, -1);
+        }
+        else
+        {
+            throw new QmfException("Agent.invokeMethod() called from deactivated Agent");
+        }
+    }
+
+    /**
+     * Sends a method request to the Agent. Delegates to the AgentProxy to actually send the method as it's the
+     * AgentProxy that knows about connections, sessions and messages.
+     *
+     * @param name the remote method name.
+     * @param inArgs the formal parameters of the remote method name.
+     * @return the MethodResult.
+     */
+    public MethodResult invokeMethod(final String name, final QmfData inArgs) throws QmfException
+    {
+        return invokeMethod(null, name, inArgs, -1);
+    }
+
+    /**
+     * Sends a method request to the Agent. Delegates to the AgentProxy to actually send the method as it's the
+     * AgentProxy that knows about connections, sessions and messages.
+     *
+     * @param name the remote method name.
+     * @param inArgs the formal parameters of the remote method name.
+     * @param timeout the maximum time to wait for a response, overrides default replyTimeout.
+     * @return the MethodResult.
+     */
+    public MethodResult invokeMethod(final String name, final QmfData inArgs, final int timeout) throws QmfException
+    {
+        return invokeMethod(null, name, inArgs, timeout);
+    }
+
+    /**
+     * Sends a method request to the Agent. Delegates to the AgentProxy to actually send the method as it's the
+     * AgentProxy that knows about connections, sessions and messages.
+     *
+     * @param name the remote method name.
+     * @param inArgs the formal parameters of the remote method name.
+     * @param replyHandle the correlation handle used to tie asynchronous method requests with responses.
+     */
+    public void invokeMethod(final String name, final QmfData inArgs, final String replyHandle) throws QmfException
+    {
+        invokeMethod(null, name, inArgs, replyHandle);
+    }
+
+    /**
+     * Remove a Subscription. Delegates to the AgentProxy to actually remove the Subscription as it's the AgentProxy
+     * that really knows about subscriptions.
+     *
+     * @param subscription the SubscriptionManager that we wish to remove.
+     */
+    public void removeSubscription(final SubscriptionManager subscription)
+    {
+        _proxy.removeSubscription(subscription);
+    }
+
+    /**
+     * Allows reception of events from this agent.
+     */
+    public void enableEvents()
+    {
+        _eventsEnabled = true;
+    }
+
+    /**
+     * Prevents reception of events from this agent.
+     */
+    public void disableEvents()
+    {
+        _eventsEnabled = false;
+    }
+
+    /**
+     * Releases this Agent instance. Once called, the Console application should not reference this instance again.
+     */
+    public void destroy()
+    {
+        _timestamp = 0;
+        _proxy.destroy(this);
+    }
+
+    /**
+     * Clears the internally cached schema. Generally done when we wich to refresh the schema information from the
+     * remote Agent.
+     */
+    public void clearSchemaCache()
+    {
+        _schemaCache.clear();
+        _packages.clear();
+    }
+
+    /**
+     * Stores the schema and package information obtained by querying the remote Agent.
+     *
+     * @param classes the list of SchemaClassIds obtained by querying the remote Agent.
+     */
+    public void setClasses(final List<SchemaClassId> classes)
+    {
+        if (classes == null)
+        {
+            clearSchemaCache();
+            return;
+        }
+
+        for (SchemaClassId classId : classes)
+        {
+            _schemaCache.put(classId, SchemaClass.EMPTY_SCHEMA);
+            if (!_packages.contains(classId.getPackageName()))
+            {
+                _packages.add(classId.getPackageName());
+            }
+        }
+    }
+
+    /**
+     * Return the list of SchemaClassIds associated with this Agent.
+     * @return the list of SchemaClassIds associated with this Agent.
+     */
+    public List<SchemaClassId> getClasses()
+    {
+        if (_schemaCache.size() == 0)
+        {
+            return Collections.emptyList();
+        }
+        return new ArrayList<SchemaClassId>(_schemaCache.keySet());
+    }
+
+    /**
+     * Return the list of packages associated with this Agent.
+     * @return the list of packages associated with this Agent.
+     */
+    public List<String> getPackages()
+    {
+        return _packages;
+    }
+
+    /**
+     * Return the SchemaClass associated with this Agent.
+     * @return the list of SchemaClass associated with this Agent.
+     * <p>
+     * I <i>believe</i> that there should only be one entry in the list returned when looking up a specific chema by classId.
+     */
+    public List<SchemaClass> getSchema(final SchemaClassId classId)
+    {
+        SchemaClass schema = _schemaCache.get(classId);
+        if (schema == SchemaClass.EMPTY_SCHEMA)
+        {
+            return Collections.emptyList();
+        }
+        
+        List<SchemaClass> results = new ArrayList<SchemaClass>();
+        results.add(schema);
+        return results;
+    }
+
+    /**
+     * Set a schema keyed by SchemaClassId.
+     *
+     * @param classId the SchemaClassId indexing the particular schema.
+     * @param schemaList the schema being indexed.
+     * <p>
+     * I <i>believe</i> that there should only be one entry in the list returned when looking up a specific chema by classId.
+     */
+    public void setSchema(final SchemaClassId classId, final List<SchemaClass> schemaList)
+    {
+        if (schemaList == null || schemaList.size() == 0)
+        {
+            _schemaCache.put(classId, SchemaClass.EMPTY_SCHEMA);
+        }
+        else
+        {
+            // I believe that there should only be one entry in the list returned when looking up
+            // a specific chema by classId
+            _schemaCache.put(classId, schemaList.get(0));
+        }
+    }
+
+    /**
+     * Helper/debug method to list the QMF Object properties and their type.
+     */
+    @Override
+    public void listValues()
+    {
+        super.listValues();
+        System.out.println("Agent:");
+        System.out.println("instance: " + getInstance());
+        System.out.println("name: " + getName());
+        System.out.println("product: " + getProduct());
+        System.out.println("vendor: " + getVendor());
+        System.out.println("epoch: " + getEpoch());
+        System.out.println("heartbeatInterval: " + getHeartbeatInterval());
+        System.out.println("timestamp: " + new Date(getTimestamp()/1000000l));
+    }
+}
+

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/Agent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/Agent.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAccessWorkItem.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAccessWorkItem.java?rev=1465662&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAccessWorkItem.java (added)
+++ qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAccessWorkItem.java Mon Apr  8 15:19:04 2013
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.qmf2.console;
+
+import java.util.HashMap;
+import java.util.Map;
+
+// QMF2 Imports
+import org.apache.qpid.qmf2.common.Handle;
+import org.apache.qpid.qmf2.common.QmfEvent;
+import org.apache.qpid.qmf2.common.WorkItem;
+
+/**
+ * Abstract class that acts as a superclass for all WorkItems that need to set and retrieve an Agent.
+ * <p>
+ * This class is a convenience class to enable neater access the the WorkItem params for this type of WorkItem.
+ *
+ * @author Fraser Adams
+ */
+
+public abstract class AgentAccessWorkItem extends WorkItem
+{
+    /**
+     * Helper method to create the WorkItem params as a Map.
+     *
+     * @param agent the Agent associated with the WorkItem.
+     * @param event the QmfEvent associated with the WorkItem.
+     */
+    protected static Map<String, Object> newParams(final Agent agent, final QmfEvent event)
+    {
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("agent", agent);
+        if (event != null)
+        {
+            params.put("event", event);
+        }
+        return params;
+    }
+
+    /**
+     * Construct an AgentAccessWorkItem. Convenience constructor not in API
+     *
+     * @param type the type of WorkItem specified by the WorkItemType enum
+     * @param handle the handle passed by async calls - the correlation ID
+     * @param params the payload of the WorkItem
+     */
+    public AgentAccessWorkItem(final WorkItemType type, final Handle handle, final Object params)
+    {
+        super(type, handle, params);
+    }
+
+    /**
+     * Return the Agent stored in the params Map.
+     * @return the Agent stored in the params Map.
+     */
+    public final Agent getAgent()
+    {
+        Map<String, Object> p = this.<Map<String, Object>>getParams();
+        return (Agent)p.get("agent");
+    }
+}
+

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAccessWorkItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAccessWorkItem.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAddedWorkItem.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAddedWorkItem.java?rev=1465662&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAddedWorkItem.java (added)
+++ qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAddedWorkItem.java Mon Apr  8 15:19:04 2013
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.qmf2.console;
+
+/**
+ * Descriptions below are taken from <a href=https://cwiki.apache.org/qpid/qmfv2-api-proposal.html>QMF2 API Proposal</a> 
+ * <pre>
+ * AGENT_ADDED: When the QMF Console receives the first heartbeat from an Agent, an AGENT_ADDED WorkItem
+ *              is pushed onto the work-queue. The WorkItem's getParam() call returns a map which contains
+ *              a reference to the new Console Agent instance. The reference is indexed from the map using
+ *              the key string "agent". There is no handle associated with this WorkItem.
+ *
+ *              Note: If a new Agent is discovered as a result of the Console findAgent() method, then no
+ *              AGENT_ADDED WorkItem is generated for that Agent.
+ * </pre>
+ * @author Fraser Adams
+ */
+
+public final class AgentAddedWorkItem extends AgentAccessWorkItem
+{
+    /**
+     * Construct an AgentAddedWorkItem. Convenience constructor not in API
+     *
+     * @param agent the Agent used to populate the WorkItem's param
+     */
+    public AgentAddedWorkItem(final Agent agent)
+    {
+        super(WorkItemType.AGENT_ADDED, null, newParams(agent, null));
+    }
+}
+

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAddedWorkItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentAddedWorkItem.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentDeletedWorkItem.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentDeletedWorkItem.java?rev=1465662&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentDeletedWorkItem.java (added)
+++ qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentDeletedWorkItem.java Mon Apr  8 15:19:04 2013
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.qmf2.console;
+
+/**
+ * Descriptions below are taken from <a href=https://cwiki.apache.org/qpid/qmfv2-api-proposal.html>QMF2 API Proposal</a> 
+ * <pre>
+ * AGENT_DELETED: When a known Agent stops sending heartbeat messages, the Console will time out that Agent.
+ *                On Agent timeout, an AGENT_DELETED WorkItem is pushed onto the work-queue. The WorkItem's
+ *                getParam() call returns a map which contains a reference to the Agent instance that has
+ *                been deleted. The reference is indexed from the map using the key string "agent". There is
+ *                no handle associated with this WorkItem.
+ *
+ *                The Console application must release all saved references to the Agent before returning the
+ *                WorkItem.
+ * </pre>
+ * @author Fraser Adams
+ */
+
+public final class AgentDeletedWorkItem extends AgentAccessWorkItem
+{
+    /**
+     * Construct an AgentDeletedWorkItem. Convenience constructor not in API
+     *
+     * @param agent the Agent used to populate the WorkItem's param
+     */
+    public AgentDeletedWorkItem(final Agent agent)
+    {
+        super(WorkItemType.AGENT_DELETED, null, newParams(agent, null));
+    }
+}
+

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentDeletedWorkItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentDeletedWorkItem.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentHeartbeatWorkItem.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentHeartbeatWorkItem.java?rev=1465662&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentHeartbeatWorkItem.java (added)
+++ qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentHeartbeatWorkItem.java Mon Apr  8 15:19:04 2013
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.qmf2.console;
+
+/**
+ * Descriptions below are taken from <a href=https://cwiki.apache.org/qpid/qmfv2-api-proposal.html>QMF2 API Proposal</a> 
+ * <pre>
+ * AGENT_HEARTBEAT: When the QMF Console receives heartbeats from an Agent, an AGENT_HEARTBEAT WorkItem
+ *                  is pushed onto the work-queue. The WorkItem's getParam() call returns a map which contains
+ *                  a reference to the Console Agent instance. The reference is indexed from the map using
+ *                  the key string "agent". There is no handle associated with this WorkItem.
+ *
+ *                  Note: the first heartbeat results in an AGENT_ADDED WorkItem for Agent not an AGENT_HEARTBEAT.
+ * </pre>
+ * @author Fraser Adams
+ */
+
+public final class AgentHeartbeatWorkItem extends AgentAccessWorkItem
+{
+    /**
+     * Construct an AgentHeartbeatWorkItem. Convenience constructor not in API
+     *
+     * @param agent the Agent used to populate the WorkItem's param
+     */
+    public AgentHeartbeatWorkItem(final Agent agent)
+    {
+        super(WorkItemType.AGENT_HEARTBEAT, null, newParams(agent, null));
+    }
+}
+

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentHeartbeatWorkItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentHeartbeatWorkItem.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentProxy.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentProxy.java?rev=1465662&view=auto
==============================================================================
--- qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentProxy.java (added)
+++ qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentProxy.java Mon Apr  8 15:19:04 2013
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.qmf2.console;
+
+// Misc Imports
+import java.util.Map;
+
+// QMF2 Imports
+import org.apache.qpid.qmf2.common.ObjectId;
+import org.apache.qpid.qmf2.common.QmfException;
+
+/**
+ * This interface is implemented by the Console and provides a number of "Agent" related behaviours.
+ * <p>
+ * Arguably it would be possible to implement these directly in the org.apache.qpid.qmf2.console.Agent class but as
+ * it happens they tend to use more Console behaviours, for example refresh() and invokeMethod() are pretty much
+ * about constructing the appropriate JMS Message, so have more in common with the rest of   
+ * org.apache.qpid.qmf2.console.Console.
+ * <p>
+ * The purpose of this interface is primarily about removing a circular dependency between Console and Agent so the
+ * Agent doesn't invoke these methods on a Console instance, rather it invokes them on an AgentProxy instance.
+ * <p>
+ * The following diagram illustrates the interactions between the Console, AgentProxy and the client side Agent
+ * representation.
+ * <p>
+ * <img src="doc-files/Subscriptions.png"/>
+ * @author Fraser Adams
+ */
+public interface AgentProxy
+{
+    /**
+     * Releases the Agent instance. Once called, the console application should not reference this instance again.
+     *
+     * @param agent the Agent to be destroyed.
+     */
+    public void destroy(Agent agent);
+
+    /**
+     * Request that the Agent update the value of an object's contents.
+     *
+     * @param agent the Agent to get the refresh from.
+     * @param objectId the ObjectId being queried for.
+     * @param replyHandle the correlation handle used to tie asynchronous method requests with responses.
+     * @param timeout the maximum time to wait for a response, overrides default replyTimeout.
+     * @return the refreshed object.
+     */
+    public QmfConsoleData refresh(Agent agent, ObjectId objectId, String replyHandle, int timeout);
+
+    /**
+     * Invoke the named method on the named Agent.
+     *
+     * @param agent the Agent to invoke the method on.
+     * @param content an unordered set of key/value pairs comprising the method arguments.
+     * @param replyHandle the correlation handle used to tie asynchronous method requests with responses.
+     * @param timeout the maximum time to wait for a response, overrides default replyTimeout.
+     * @return the MethodResult.
+     */
+    public MethodResult invokeMethod(Agent agent, Map<String, Object> content, String replyHandle, int timeout) throws QmfException;
+
+    /**
+     * Remove a Subscription.
+     *
+     * @param subscription the SubscriptionManager that we wish to remove.
+     */
+    public void removeSubscription(SubscriptionManager subscription);
+}
+

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/trunk/qpid/tools/src/java/src/main/java/org/apache/qpid/qmf2/console/AgentProxy.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



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