You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2010/01/31 01:31:57 UTC

svn commit: r904934 [2/11] - in /qpid/trunk/qpid/java: broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/diagnostic/ broker-plugins/src/main/java/org/apache/qpid/extras/exchanges/example/ broker/ broker/src/main/java/org/apache/qpid/qmf/ br...

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFGetQueryCommand.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFGetQueryCommand.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFGetQueryCommand.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFGetQueryCommand.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,182 @@
+/*
+ *
+ * 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.qmf;
+
+import org.apache.qpid.transport.codec.BBDecoder;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.AMQException;
+
+import java.util.*;
+
+public class QMFGetQueryCommand extends QMFCommand
+{
+    private Map<String, Object> _map;
+
+
+    public QMFGetQueryCommand(QMFCommandHeader header, BBDecoder decoder)
+    {
+        super(header);
+
+        _map = decoder.readMap();
+    }
+
+    public void process(VirtualHost virtualHost, ServerMessage message)
+    {
+        String exchangeName = message.getMessageHeader().getReplyToExchange();
+        String routingKey = message.getMessageHeader().getReplyToRoutingKey();
+
+        IApplicationRegistry appRegistry = virtualHost.getApplicationRegistry();
+        QMFService service = appRegistry.getQMFService();
+
+        String className = (String) _map.get("_class");
+        String packageName = (String) _map.get("_package");
+        byte[] objectIdBytes = (byte[]) _map.get("_objectId");
+        UUID objectId;
+        if(objectIdBytes != null)
+        {
+            long msb = 0;
+            long lsb = 0;
+
+            for (int i = 0; i != 8; i++)
+            {
+                msb = (msb << 8) | (objectIdBytes[i] & 0xff);
+            }
+            for (int i = 8; i != 16; i++)
+            {
+                lsb = (lsb << 8) | (objectIdBytes[i] & 0xff);
+            }
+            objectId = new UUID(msb, lsb);
+        }
+        else
+        {
+            objectId = null;
+        }
+
+        List<QMFCommand> commands = new ArrayList<QMFCommand>();
+        final long sampleTime = System.currentTimeMillis() * 1000000l;
+
+        Collection<QMFPackage> packages;
+
+        if(packageName != null && packageName.length() != 0)
+        {
+            QMFPackage qmfPackage = service.getPackage(packageName);
+            if(qmfPackage == null)
+            {
+                packages = Collections.EMPTY_LIST;
+            }
+            else
+            {
+                packages = Collections.singleton(qmfPackage);
+            }
+        }
+        else
+        {
+            packages = service.getSupportedSchemas();
+        }
+
+        for(QMFPackage qmfPackage : packages)
+        {
+
+            Collection<QMFClass> qmfClasses;
+
+            if(className != null && className.length() != 0)
+            {
+                QMFClass qmfClass = qmfPackage.getQMFClass(className);
+                if(qmfClass == null)
+                {
+                    qmfClasses = Collections.EMPTY_LIST;
+                }
+                else
+                {
+                    qmfClasses = Collections.singleton(qmfClass);
+                }
+            }
+            else
+            {
+                qmfClasses = qmfPackage.getClasses();
+            }
+
+
+            for(QMFClass qmfClass : qmfClasses)
+            {
+                Collection<QMFObject> objects;
+
+                if(objectId != null)
+                {
+                    QMFObject obj = service.getObjectById(qmfClass, objectId);
+                    if(obj == null)
+                    {
+                        objects = Collections.EMPTY_LIST;
+                    }
+                    else
+                    {
+                        objects = Collections.singleton(obj);
+                    }
+                }
+                else
+                {
+                    objects = service.getObjects(qmfClass);
+                }
+
+                for(QMFObject object : objects)
+                {
+
+                    commands.add(object.asGetQueryResponseCmd(this, sampleTime));
+                }
+            }
+
+
+        }
+
+
+        commands.add( new QMFCommandCompletionCommand(this));
+
+
+        for(QMFCommand cmd : commands)
+        {
+
+
+            QMFMessage responseMessage = new QMFMessage(routingKey, cmd);
+
+            Exchange exchange = virtualHost.getExchangeRegistry().getExchange(exchangeName);
+
+            ArrayList<? extends BaseQueue> queues = exchange.route(responseMessage);
+
+            for(BaseQueue q : queues)
+            {
+                try
+                {
+                    q.enqueue(responseMessage);
+                }
+                catch (AMQException e)
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
+            }
+        }
+    }
+
+}
\ No newline at end of file

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMessage.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMessage.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMessage.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMessage.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,205 @@
+/*
+ *
+ * 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.qmf;
+
+import org.apache.qpid.server.message.*;
+import org.apache.qpid.transport.codec.BBEncoder;
+
+import java.nio.ByteBuffer;
+import java.util.Set;
+
+public class QMFMessage implements ServerMessage, InboundMessage, AMQMessageHeader
+{
+
+    private ByteBuffer _content;
+    private String _routingKey;
+
+    public QMFMessage(String routingKey, QMFCommand command)
+    {
+        this(routingKey, new QMFCommand[] { command });
+    }
+
+
+    public QMFMessage(String routingKey, QMFCommand[] commands)
+    {
+        _routingKey = routingKey;
+        BBEncoder encoder = new BBEncoder(256);
+
+        for(QMFCommand cmd : commands)
+        {
+            cmd.encode(encoder);
+        }
+
+
+        _content = encoder.buffer();
+    }
+
+    public String getRoutingKey()
+    {
+        return _routingKey;
+    }
+
+    public AMQMessageHeader getMessageHeader()
+    {
+        return this;
+    }
+
+    public boolean isPersistent()
+    {
+        return false;
+    }
+
+    public boolean isRedelivered()
+    {
+        return false;
+    }
+
+    public long getSize()
+    {
+        return _content.limit();
+    }
+
+    public boolean isImmediate()
+    {
+        return false;
+    }
+
+    public String getCorrelationId()
+    {
+        return null;
+    }
+
+    public long getExpiration()
+    {
+        return 0;
+    }
+
+    public String getMessageId()
+    {
+        return null;
+    }
+
+    public String getMimeType()
+    {
+        return null;
+    }
+
+    public String getEncoding()
+    {
+        return null;
+    }
+
+    public byte getPriority()
+    {
+        return 4;
+    }
+
+    public long getTimestamp()
+    {
+        return 0;
+    }
+
+    public String getType()
+    {
+        return null;
+    }
+
+    public String getReplyTo()
+    {
+        return null;
+    }
+
+    public String getReplyToExchange()
+    {
+        return null;
+    }
+
+    public String getReplyToRoutingKey()
+    {
+        return null;
+    }
+
+    public Object getHeader(String name)
+    {
+        return null;
+    }
+
+    public boolean containsHeaders(Set<String> names)
+    {
+        return false;
+    }
+
+    public boolean containsHeader(String name)
+    {
+        return false;
+    }
+
+    public MessageReference newReference()
+    {
+        return new QMFMessageReference(this);
+    }
+
+    public Long getMessageNumber()
+    {
+        return null;
+    }
+
+    public long getArrivalTime()
+    {
+        return 0;
+    }
+
+    public int getContent(ByteBuffer buf, int offset)
+    {
+        ByteBuffer src = _content.duplicate();
+        _content.position(offset);
+        _content = _content.slice();
+        int len = _content.remaining();
+        if(len > buf.remaining())
+        {
+            len = buf.remaining();
+        }
+
+        buf.put(src);
+
+        return len;
+    }
+
+    private class QMFMessageReference extends MessageReference<QMFMessage>
+    {
+        public QMFMessageReference(QMFMessage message)
+        {
+            super(message);
+        }
+
+        protected void onReference(QMFMessage message)
+        {
+
+        }
+
+        protected void onRelease(QMFMessage message)
+        {
+
+        }
+    }
+
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethod.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethod.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethod.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethod.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,157 @@
+/*
+ *
+ * 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.qmf;
+
+import org.apache.qpid.transport.codec.Encoder;
+import org.apache.qpid.transport.codec.BBDecoder;
+
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.ArrayList;
+
+public abstract class QMFMethod<T extends QMFObject>
+{
+    private final LinkedHashMap<String,Object> _map = new LinkedHashMap<String,Object>();
+    private final List<Argument> _arguments = new ArrayList<Argument>();
+
+    private static final String NAME = "name";
+    private static final String TYPE = "type";
+    private static final String REF_PACKAGE = "refPackage";
+    private static final String REF_CLASS = "refClass";
+    private static final String UNIT = "unit";
+    private static final String MIN = "min";
+    private static final String MAX = "max";
+    private static final String MAX_LENGTH = "maxlen";
+    private static final String DESCRIPTION = "desc";
+    private static final String DEFAULT = "default";
+    private static final String DIRECTION = "dir";
+    private static final String ARG_COUNT = "argCount";
+
+
+
+    public enum Direction
+    {
+        I,
+        O,
+        IO;
+    }
+
+    public class Argument
+    {
+        private final LinkedHashMap<String,Object> _map = new LinkedHashMap<String,Object>();
+
+        public Argument(String name, QMFType type)
+        {
+            _map.put(NAME, name);
+            _map.put(TYPE, type.codeValue());
+        }
+
+        public void setRefPackage(String refPackage)
+        {
+            _map.put(REF_PACKAGE, refPackage);
+        }
+
+        public void setRefClass(String refClass)
+        {
+            _map.put(REF_CLASS, refClass);
+        }
+
+        public void setUnit(String unit)
+        {
+            _map.put(UNIT, unit);
+        }
+
+        public void setMax(Number max)
+        {
+            _map.put(MAX, max);
+        }
+
+        public void setMin(Number min)
+        {
+            _map.put(MIN, min);
+        }
+
+        public void setMaxLength(int len)
+        {
+            _map.put(MAX_LENGTH, len);
+        }
+
+        public void setDefault(Object dflt)
+        {
+            _map.put(DEFAULT, dflt);
+        }
+
+        public void setDescription(String desc)
+        {
+            _map.put(DESCRIPTION, desc);
+        }
+
+        public void setDirection(Direction direction)
+        {
+            _map.put(DIRECTION, direction.toString());
+        }
+
+        public void encode(Encoder encoder)
+        {
+            encoder.writeMap(_map);
+        }
+
+        public String getName()
+        {
+            return (String) _map.get(NAME);
+        }
+    }
+
+    public QMFMethod(String name, String description)
+    {
+        _map.put(NAME, name);
+        _map.put(ARG_COUNT, 0);
+        if(description != null)
+        {
+            _map.put(DESCRIPTION, description);
+        }
+
+    }
+
+    abstract public QMFMethodInvocation<T> parse(final BBDecoder decoder);
+
+    protected void addArgument(Argument arg)
+    {
+        _arguments.add(arg);
+        _map.put(ARG_COUNT, _arguments.size());
+    }
+
+
+    public void encode(Encoder encoder)
+    {
+        encoder.writeMap(_map);
+        for(Argument arg : _arguments)
+        {
+            arg.encode(encoder);
+        }
+    }
+
+    public String getName()
+    {
+        return (String) _map.get(NAME);
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodInvocation.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodInvocation.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodInvocation.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodInvocation.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,26 @@
+/*
+ *
+ * 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.qmf;
+
+public interface QMFMethodInvocation<T extends QMFObject>
+{
+    QMFMethodResponseCommand execute(T obj, QMFMethodRequestCommand cmd);
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodRequestCommand.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodRequestCommand.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodRequestCommand.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodRequestCommand.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,88 @@
+/*
+ *
+ * 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.qmf;
+
+import org.apache.qpid.transport.codec.BBDecoder;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.AMQException;
+
+import java.util.UUID;
+import java.util.ArrayList;
+
+public class QMFMethodRequestCommand extends QMFCommand
+{
+    private QMFMethodInvocation _methodInstance;
+    private QMFObject _object;
+
+    public QMFMethodRequestCommand(final QMFCommandHeader header, final BBDecoder decoder, final QMFService qmfService)
+    {
+        super(header);
+        UUID objectId = decoder.readUuid();
+        String packageName = decoder.readStr8();
+        String className = decoder.readStr8();
+        byte[] hash = decoder.readBin128();
+        String methodName = decoder.readStr8();
+
+        QMFPackage qmfPackage = qmfService.getPackage(packageName);
+        QMFClass qmfClass = qmfPackage.getQMFClass(className);
+        _object = qmfService.getObjectById(qmfClass, objectId);
+        QMFMethod method = qmfClass.getMethod(methodName);
+        _methodInstance = method.parse(decoder);
+
+    }
+
+    public void process(final VirtualHost virtualHost, final ServerMessage message)
+    {
+        String exchangeName = message.getMessageHeader().getReplyToExchange();
+        String queueName = message.getMessageHeader().getReplyToRoutingKey();
+
+        QMFCommand[] commands = new QMFCommand[2];
+        commands[0] = _methodInstance.execute(_object, this);
+        commands[1] = new QMFCommandCompletionCommand(this);
+
+        Exchange exchange = virtualHost.getExchangeRegistry().getExchange(exchangeName);
+
+        for(QMFCommand cmd : commands)
+        {
+            QMFMessage responseMessage = new QMFMessage(queueName, cmd);
+
+
+            ArrayList<? extends BaseQueue> queues = exchange.route(responseMessage);
+
+
+            for(BaseQueue q : queues)
+            {
+                try
+                {
+                    q.enqueue(responseMessage);
+                }
+                catch (AMQException e)
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
+            }
+        }
+
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodResponseCommand.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodResponseCommand.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodResponseCommand.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFMethodResponseCommand.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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.qmf;
+
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.transport.codec.BBEncoder;
+
+public class QMFMethodResponseCommand extends QMFCommand
+{
+    public QMFMethodResponseCommand(final QMFMethodRequestCommand cmd)
+    {
+        super( new QMFCommandHeader(cmd.getHeader().getVersion(),
+                                    cmd.getHeader().getSeq(),
+                                    QMFOperation.METHOD_RESPONSE));
+    }
+
+    @Override
+    public void encode(final BBEncoder encoder)
+    {
+        super.encode(encoder);
+        encoder.writeUint32(0);
+        encoder.writeStr16("OK");
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFObject.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFObject.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFObject.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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.qmf;
+
+import java.util.UUID;
+
+public abstract class QMFObject<C extends QMFClass, D extends QMFObject.Delegate>
+{
+    private long _deleteTime;
+
+    public interface Delegate
+    {
+        UUID getId();
+        long getCreateTime();
+    }
+
+
+    private D _delegate;
+
+    protected QMFObject(D delegate)
+    {
+        _delegate = delegate;
+    }
+
+    public D getDelegate()
+    {
+        return _delegate;
+    }
+
+    abstract public C getQMFClass();
+
+    public final UUID getId()
+    {
+        return _delegate.getId();
+    }
+
+    public final long getCreateTime()
+    {
+        return _delegate.getCreateTime();
+    }
+
+    public final void setDeleteTime()
+    {
+        _deleteTime = System.currentTimeMillis();
+    }
+
+    public final long getDeleteTime()
+    {
+        return _deleteTime;
+    }
+
+
+
+    abstract public QMFCommand asConfigInfoCmd(long sampleTime);
+    abstract public QMFCommand asInstrumentInfoCmd(long sampleTime);
+    abstract public QMFCommand asGetQueryResponseCmd(final QMFGetQueryCommand queryCommand, long sampleTime);
+
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFObjectClass.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFObjectClass.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFObjectClass.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFObjectClass.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.qmf;
+
+import java.util.List;
+
+public abstract class QMFObjectClass<T extends QMFObject, S extends QMFObject.Delegate> extends QMFClass
+{
+    public QMFObjectClass(String name,
+                          byte[] schemaHash,
+                          List<QMFProperty> properties,
+                          List<QMFStatistic> statistics, List<QMFMethod> methods)
+    {
+        super(QMFClass.Type.OBJECT, name, schemaHash, properties, statistics, methods);
+    }
+
+    public QMFObjectClass(String name, byte[] schemaHash)
+    {
+        super(QMFClass.Type.OBJECT, name, schemaHash);
+    }
+
+
+    public abstract T newInstance(S delegate);
+
+
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFOperation.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFOperation.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFOperation.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFOperation.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,67 @@
+/*
+ *
+ * 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.qmf;
+
+public enum QMFOperation
+{
+
+
+    BROKER_REQUEST('B'),
+    BROKER_RESPONSE('b'),           // This message contains a broker response, sent from the broker in response to a broker request message.
+    COMMAND_COMPLETION('z'),        // This message is sent to indicate the completion of a request.
+    CLASS_QUERY('Q'),               // Class query messages are used by a management console to request a list of schema classes that are known by the management broker.
+    CLASS_INDICATION('q'),          // Sent by the management broker, a class indication notifies the peer of the existence of a schema class.
+    SCHEMA_REQUEST('S'),            // Schema request messages are used to request the full schema details for a class.
+    SCHEMA_RESPONSE('s'),           // Schema response message contain a full description of the schema for a class.
+    HEARTBEAT_INDEICATION('h'),     // This message is published once per publish-interval. It can be used by a client to positively determine which objects did not change during the interval (since updates are not published for objects with no changes).
+    CONFIG_INDICATION('c'),
+    INSTRUMENTATION_INDICATION('i'),
+    GET_QUERY_RESPONSE('g'),      // This message contains a content record. Content records contain the values of all properties or statistics in an object. Such records are broadcast on a periodic interval if 1) a change has been made in the value of one of the elements, or 2) if a new management client has bound a queue to the management exchange.
+    GET_QUERY('G'), 	            // Sent by a management console, a get query requests that the management broker provide content indications for all objects that match the query criteria.
+    METHOD_REQUEST('M'), 	        // This message contains a method request.
+    METHOD_RESPONSE('m'), 	        // This message contains a method result.
+    PACKAGE_QUERY('P'), 	        // This message contains a schema package query request, requesting that the broker dump the list of known packages
+    PACKAGE_INDICATION('p'), 	    // This message contains a schema package indication, identifying a package known by the broker
+    AGENT_ATTACH_REUQEST('A'), 	    // This message is sent by a remote agent when it wishes to attach to a management broker
+    AGENT_ATTACH_RESPONSE('a'), 	// The management broker sends this response if an attaching remote agent is permitted to join
+    CONSOLE_ADDED_INDICATION('x'),     // This message is sent to all remote agents by the management broker when a new console binds to the management exchange
+    EVENT('e')
+    ;
+
+
+    private final char _opcode;
+
+    private static final QMFOperation[] OP_CODES = new QMFOperation[256];
+
+
+    QMFOperation(char opcode)
+    {
+        _opcode = opcode;
+    }
+
+
+    public char getOpcode()
+    {
+        return _opcode;
+    }
+
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackage.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackage.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackage.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackage.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,67 @@
+/*
+ *
+ * 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.qmf;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.HashMap;
+
+public class QMFPackage
+{
+    private final String _name;
+    private final Map<String, QMFClass> _classes = new HashMap<String, QMFClass>();
+
+    public QMFPackage(String name)
+    {
+        _name = name;
+    }
+
+    public QMFPackage(String name, Collection<QMFClass> classes)
+    {
+        this(name);
+        setClasses(classes);
+    }
+
+    protected void setClasses(Collection<QMFClass> classes)
+    {
+        for(QMFClass qmfClass : classes)
+        {
+            qmfClass.setPackage(this);
+            _classes.put(qmfClass.getName(), qmfClass);
+        }
+    }
+
+    public String getName()
+    {
+        return _name;
+    }
+
+    public Collection<QMFClass> getClasses()
+    {
+        return _classes.values();
+    }
+
+    public QMFClass getQMFClass(String className)
+    {
+        return _classes.get(className);
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageIndicationCommand.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageIndicationCommand.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageIndicationCommand.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageIndicationCommand.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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.qmf;
+
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.transport.codec.BBEncoder;
+
+public class QMFPackageIndicationCommand extends QMFCommand
+{
+    private String _supportedSchema;
+
+    public QMFPackageIndicationCommand(QMFPackageQueryCommand qmfPackageQueryCommand, String supportedSchema)
+    {
+        super( new QMFCommandHeader(qmfPackageQueryCommand.getHeader().getVersion(),
+                                    qmfPackageQueryCommand.getHeader().getSeq(),
+                                    QMFOperation.PACKAGE_INDICATION));
+        _supportedSchema = supportedSchema;
+
+    }
+
+    public void encode(BBEncoder encoder)
+    {
+        super.encode(encoder);
+        encoder.writeStr8(_supportedSchema);
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageQueryCommand.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageQueryCommand.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageQueryCommand.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFPackageQueryCommand.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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.qmf;
+
+import org.apache.qpid.transport.codec.BBDecoder;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.AMQException;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class QMFPackageQueryCommand extends QMFCommand
+{
+    public QMFPackageQueryCommand(QMFCommandHeader header, BBDecoder decoder)
+    {
+        super(header);
+    }
+
+    public void process(VirtualHost virtualHost, ServerMessage message)
+    {
+        String exchangeName = message.getMessageHeader().getReplyToExchange();
+        String routingKey = message.getMessageHeader().getReplyToRoutingKey();
+
+
+        IApplicationRegistry appRegistry = virtualHost.getApplicationRegistry();
+        QMFService service = appRegistry.getQMFService();
+
+        Collection<QMFPackage> supportedSchemas = service.getSupportedSchemas();
+        
+        QMFCommand[] commands = new QMFCommand[ supportedSchemas.size() + 1 ];
+
+        int i = 0;
+        for(QMFPackage p : supportedSchemas)
+        {
+            commands[i++] = new QMFPackageIndicationCommand(this, p.getName());
+        }
+        commands[ commands.length - 1 ] = new QMFCommandCompletionCommand(this);
+
+
+        for(QMFCommand cmd : commands)
+        {
+
+            QMFMessage responseMessage = new QMFMessage(routingKey, cmd);
+
+            Exchange exchange = virtualHost.getExchangeRegistry().getExchange(exchangeName);
+
+            ArrayList<? extends BaseQueue> queues = exchange.route(responseMessage);
+
+
+            for(BaseQueue q : queues)
+            {
+                try
+                {
+                    q.enqueue(responseMessage);
+                }
+                catch (AMQException e)
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
+            }
+        }
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFProperty.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFProperty.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFProperty.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFProperty.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,123 @@
+/*
+ *
+ * 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.qmf;
+
+import org.apache.qpid.transport.codec.Encoder;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+
+public class QMFProperty
+{
+    private final Map<String, Object> _map = new LinkedHashMap<String, Object>();
+    private static final String NAME = "name";
+    private static final String TYPE = "type";
+    private static final String ACCESS = "access";
+    private static final String INDEX = "index";
+    private static final String OPTIONAL = "optional";
+    private static final String REF_PACKAGE = "refPackage";
+    private static final String REF_CLASS = "refClass";
+    private static final String UNIT = "unit";
+    private static final String MIN = "min";
+    private static final String MAX = "max";
+    private static final String MAX_LENGTH = "maxlen";
+    private static final String DESCRIPTION = "desc";
+
+
+    public static enum AccessCode
+    {
+        RC,
+        RW,
+        RO;
+
+        public int codeValue()
+        {
+            return ordinal()+1;
+        }
+    }
+
+    public QMFProperty(String name, QMFType type, AccessCode accessCode, boolean index, boolean optional)
+    {
+        _map.put(NAME, name);
+        _map.put(TYPE, type.codeValue());
+        _map.put(ACCESS, accessCode.codeValue());
+        _map.put(INDEX, index ? 1 : 0);
+        _map.put(OPTIONAL, optional ? 1 :0);
+    }
+
+
+    public void setQMFClass(QMFClass qmfClass)
+    {
+ /*       _map.put(REF_CLASS, qmfClass.getName());
+        _map.put(REF_PACKAGE, qmfClass.getPackage().getName());*/
+    }
+
+    public void setReferencedClass(String refClass)
+    {
+        _map.put(REF_CLASS, refClass);
+    }
+
+    public void setReferencedPackage(String refPackage)
+    {
+        _map.put(REF_CLASS, refPackage);
+    }
+
+
+    public String getName()
+    {
+        return (String) _map.get(NAME);
+    }
+
+
+    public void setUnit(String unit)
+    {
+        _map.put(UNIT, unit);
+    }
+
+    public void setMin(Number min)
+    {
+        _map.put(MIN, min);
+    }
+
+    public void setMax(Number max)
+    {
+        _map.put(MAX, max);
+    }
+
+    public void setMaxLength(int maxlen)
+    {
+        _map.put(MAX_LENGTH, maxlen);
+    }
+
+
+    public void setDescription(String description)
+    {
+        _map.put(DESCRIPTION, description);
+    }
+
+    public void encode(Encoder encoder)
+    {
+        encoder.writeMap(_map);
+    }
+
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaRequestCommand.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaRequestCommand.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaRequestCommand.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaRequestCommand.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,88 @@
+/*
+ *
+ * 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.qmf;
+
+import org.apache.qpid.transport.codec.BBDecoder;
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.exchange.Exchange;
+import org.apache.qpid.server.queue.BaseQueue;
+import org.apache.qpid.AMQException;
+
+import java.util.Collection;
+import java.util.ArrayList;
+
+public class QMFSchemaRequestCommand extends QMFCommand
+{
+    private final String _packageName;
+    private final String _className;
+    private final byte[] _hash;
+
+    public QMFSchemaRequestCommand(QMFCommandHeader header, BBDecoder decoder)
+    {
+        super(header);
+        _packageName = decoder.readStr8();
+        _className = decoder.readStr8();
+        _hash = decoder.readBin128();
+    }
+
+    public void process(VirtualHost virtualHost, ServerMessage message)
+    {
+        String exchangeName = message.getMessageHeader().getReplyToExchange();
+        String routingKey = message.getMessageHeader().getReplyToRoutingKey();
+
+        IApplicationRegistry appRegistry = virtualHost.getApplicationRegistry();
+        QMFService service = appRegistry.getQMFService();
+
+        QMFPackage qmfPackage = service.getPackage(_packageName);
+        QMFClass qmfClass = qmfPackage.getQMFClass( _className );
+
+        QMFCommand[] commands = new QMFCommand[2];
+        commands[0] = new QMFSchemaResponseCommand(this, qmfClass);
+        commands[ 1 ] = new QMFCommandCompletionCommand(this);
+
+
+
+        Exchange exchange = virtualHost.getExchangeRegistry().getExchange(exchangeName);
+
+        for(QMFCommand cmd : commands)
+        {
+            QMFMessage responseMessage = new QMFMessage(routingKey, cmd);
+
+
+            ArrayList<? extends BaseQueue> queues = exchange.route(responseMessage);
+
+            for(BaseQueue q : queues)
+            {
+                try
+                {
+                    q.enqueue(responseMessage);
+                }
+                catch (AMQException e)
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
+            }
+        }
+    }
+}

Added: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaResponseCommand.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaResponseCommand.java?rev=904934&view=auto
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaResponseCommand.java (added)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/qmf/QMFSchemaResponseCommand.java Sun Jan 31 00:31:49 2010
@@ -0,0 +1,83 @@
+/*
+ *
+ * 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.qmf;
+
+import org.apache.qpid.server.virtualhost.VirtualHost;
+import org.apache.qpid.server.message.ServerMessage;
+import org.apache.qpid.transport.codec.BBEncoder;
+
+import java.util.Collection;
+
+public class QMFSchemaResponseCommand extends QMFCommand
+{
+    private final QMFClass _qmfClass;
+
+
+    public QMFSchemaResponseCommand(QMFSchemaRequestCommand qmfSchemaRequestCommand, QMFClass qmfClass)
+    {
+        super(new QMFCommandHeader(qmfSchemaRequestCommand.getHeader().getVersion(),
+                                   qmfSchemaRequestCommand.getHeader().getSeq(),
+                                   QMFOperation.SCHEMA_RESPONSE));
+        _qmfClass = qmfClass;
+    }
+
+    @Override
+    public void encode(BBEncoder encoder)
+    {
+        super.encode(encoder);
+        encoder.writeUint8(_qmfClass.getType().getValue());
+        encoder.writeStr8(_qmfClass.getPackage().getName());
+        encoder.writeStr8(_qmfClass.getName());
+        encoder.writeBin128(_qmfClass.getSchemaHash());
+
+        Collection<QMFProperty> props = _qmfClass.getProperties();
+        Collection<QMFStatistic> stats = _qmfClass.getStatistics();
+        Collection<QMFMethod> methods = _qmfClass.getMethods();
+
+        encoder.writeUint16(props.size());
+        if(_qmfClass.getType() == QMFClass.Type.OBJECT)
+        {
+            encoder.writeUint16(stats.size());
+            encoder.writeUint16(methods.size());
+        }
+
+        for(QMFProperty prop : props)
+        {
+            prop.encode(encoder);
+        }
+
+        if(_qmfClass.getType() == QMFClass.Type.OBJECT)
+        {
+
+            for(QMFStatistic stat : stats)
+            {
+                stat.encode(encoder);
+            }
+
+            for(QMFMethod method : methods)
+            {
+                method.encode(encoder);
+            }
+        }
+
+    }
+}



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org