activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r468414 [5/7] - in /incubator/activemq/sandbox/qpid/src/main/java/org/apache: activemq/amqp/ activemq/amqp/broker/ activemq/amqp/command/ activemq/amqp/transport/ activemq/amqp/wireformat/ activemq/amqp/wireformat/v8_0/ activemq/qpid/broker...
Date Fri, 27 Oct 2006 15:27:30 GMT
Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeFactory.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,28 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.exchange;
+
+import org.apache.qpid.AMQException;
+
+
+public interface ExchangeFactory
+{
+    Exchange createExchange(String exchange, String type, boolean durable, boolean autoDelete,
+                            int ticket)
+            throws AMQException;
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeInUseException.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,28 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.exchange;
+
+import org.apache.qpid.AMQException;
+
+public class ExchangeInUseException extends AMQException
+{
+    public ExchangeInUseException(String exchangeName)
+    {
+        super("Exchange " + exchangeName + " is currently in use");
+    }
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ExchangeRegistry.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,39 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.exchange;
+
+import org.apache.qpid.AMQException;
+
+
+public interface ExchangeRegistry extends MessageRouter
+{
+    void registerExchange(Exchange exchange);
+
+    /**
+     * Unregister an exchange
+     * @param name name of the exchange to delete
+     * @param inUse if true, do NOT delete the exchange if it is in use (has queues bound to it)
+     * @throws ExchangeInUseException when the exchange cannot be deleted because it is in use
+     * @throws AMQException
+     */
+    void unregisterExchange(String name, boolean inUse) throws ExchangeInUseException, AMQException;
+
+    Exchange getExchange(String name);
+
+	ExchangeFactory getExchangeFactory();
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/HeadersBinding.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,142 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.exchange;
+
+import org.apache.log4j.Logger;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Defines binding and matching based on a set of headers.
+ */
+class HeadersBinding
+{
+    private static final Logger _logger = Logger.getLogger(HeadersBinding.class);
+
+    private final Map _mappings = new HashMap();
+    private final Set<Object> required = new HashSet<Object>();
+    private final Set<Map.Entry> matches = new HashSet<Map.Entry>();
+    private boolean matchAny;
+
+    /**
+     * Creates a binding for a set of mappings. Those mappings whose value is
+     * null or the empty string are assumed only to be required headers, with
+     * no constraint on the value. Those with a non-null value are assumed to
+     * define a required match of value. 
+     * @param mappings the defined mappings this binding should use
+     */
+    HeadersBinding(Map mappings)
+    {
+        //noinspection unchecked
+        this(mappings == null ? new HashSet<Map.Entry>() : mappings.entrySet());
+        _mappings.putAll(mappings);
+    }
+
+    private HeadersBinding(Set<Map.Entry> entries)
+    {
+        for (Map.Entry e : entries)
+        {
+            if (isSpecial(e.getKey()))
+            {
+                processSpecial((String) e.getKey(), e.getValue());
+            }
+            else if (e.getValue() == null || e.getValue().equals(""))
+            {
+                required.add(e.getKey());
+            }
+            else
+            {
+                matches.add(e);
+            }
+        }
+    }
+
+    protected Map getMappings()
+    {
+        return _mappings;
+    }
+
+    /**
+     * Checks whether the supplied headers match the requirements of this binding
+     * @param headers the headers to check
+     * @return true if the headers define any required keys and match any required
+     * values
+     */
+    public boolean matches(Map headers)
+    {
+        if(headers == null)
+        {
+            return required.isEmpty() && matches.isEmpty();
+        }
+        else
+        {
+            return matchAny ? or(headers) : and(headers);
+        }
+    }
+
+    private boolean and(Map headers)
+    {
+        //need to match all the defined mapping rules:
+        return headers.keySet().containsAll(required)
+                && headers.entrySet().containsAll(matches);
+    }
+
+    private boolean or(Map headers)
+    {
+        //only need to match one mapping rule:
+        return !Collections.disjoint(headers.keySet(), required)
+                || !Collections.disjoint(headers.entrySet(), matches);
+    }
+
+    private void processSpecial(String key, Object value)
+    {
+        if("X-match".equalsIgnoreCase(key))
+        {
+            matchAny = isAny(value);
+        }
+        else
+        {
+            _logger.warn("Ignoring special header: " + key);
+        }
+    }
+
+    private boolean isAny(Object value)
+    {
+        if(value instanceof String)
+        {
+            if("any".equalsIgnoreCase((String) value)) return true;
+            if("all".equalsIgnoreCase((String) value)) return false;
+        }
+        _logger.warn("Ignoring unrecognised match type: " + value);
+        return false;//default to all
+    }
+
+    static boolean isSpecial(Object key)
+    {
+        return key instanceof String && isSpecial((String) key);
+    }
+
+    static boolean isSpecial(String key)
+    {
+        return key.startsWith("X-") || key.startsWith("x-");
+    }
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/HeadersExchange.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,265 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.exchange;
+
+import org.apache.activemq.amqp.command.*;
+import org.apache.log4j.Logger;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.server.management.MBeanConstructor;
+import org.apache.qpid.server.management.MBeanDescription;
+import org.apache.qpid.server.queue.AMQMessage;
+import org.apache.qpid.server.queue.AMQQueue;
+
+import javax.management.JMException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.openmbean.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * An exchange that binds queues based on a set of required headers and header values
+ * and routes messages to these queues by matching the headers of the message against
+ * those with which the queues were bound.
+ * <p/>
+ * <pre>
+ * The Headers Exchange
+ *
+ *  Routes messages according to the value/presence of fields in the message header table.
+ *  (Basic and JMS content has a content header field called "headers" that is a table of
+ *   message header fields).
+ *
+ *  class = "headers"
+ *  routing key is not used
+ *
+ *  Has the following binding arguments:
+ *
+ *  the X-match field - if "all", does an AND match (used for GRM), if "any", does an OR match.
+ *  other fields prefixed with "X-" are ignored (and generate a console warning message).
+ *  a field with no value or empty value indicates a match on presence only.
+ *  a field with a value indicates match on field presence and specific value.
+ *
+ *  Standard instances:
+ *
+ *  amq.match - pub/sub on field content/value
+ *  </pre>
+ */
+public class HeadersExchange extends AbstractExchange
+{
+    private static final Logger _logger = Logger.getLogger(HeadersExchange.class);
+
+    private final List<Registration> _bindings = new CopyOnWriteArrayList<Registration>();
+
+    /**
+     * HeadersExchangeMBean class implements the management interface for the
+     * Header Exchanges.
+     */
+    @MBeanDescription("Management Bean for Headers Exchange")
+    private final class HeadersExchangeMBean extends ExchangeMBean
+    {
+        private String[]   _bindingItemNames = {"Queue", "HeaderBinding"};
+        private String[]   _bindingItemDescriptions = {"Queue Name", "Header attribute bindings"};
+        private String[]   _bindingItemIndexNames = {"HeaderBinding"};
+        private OpenType[] _bindingItemTypes = new OpenType[2];
+
+        private CompositeType      _bindingDataType = null;
+        private TabularType        _bindinglistDataType = null;
+        private TabularDataSupport _bindingList = null;
+
+        @MBeanConstructor("Creates an MBean for AMQ Headers exchange")
+        public HeadersExchangeMBean()  throws NotCompliantMBeanException
+        {
+            super();
+            init();
+        }
+        /**
+         * initialises the OpenType objects.
+         */
+        private void init()
+        {
+            try
+            {
+                _bindingItemTypes[0] = SimpleType.STRING;
+                _bindingItemTypes[1] = new ArrayType(1, SimpleType.STRING);
+
+                _bindingDataType = new CompositeType("QueueAndHeaderAttributesBinding",
+                                             "Queue name and header bindings",
+                                             _bindingItemNames,
+                                             _bindingItemDescriptions,
+                                             _bindingItemTypes);
+                _bindinglistDataType = new TabularType("HeaderBindings",
+                                             "List of queue bindings for " + getName(),
+                                             _bindingDataType,
+                                             _bindingItemIndexNames);
+            }
+            catch(OpenDataException ex)
+            {
+                //It should never occur.
+                _logger.error("OpenDataTypes could not be created.", ex);
+                throw new RuntimeException(ex);
+            }
+        }
+
+        public TabularData viewBindings()
+            throws OpenDataException
+        {
+            _bindingList = new TabularDataSupport(_bindinglistDataType);
+            for (Iterator<Registration> itr = _bindings.iterator(); itr.hasNext();)
+            {
+                Registration registration = itr.next();
+                String queueName = registration.queue.getName();
+
+                HeadersBinding headers = registration.binding;
+                Map<Object, Object> headerMappings = headers.getMappings();
+                List<String> mappingList = new ArrayList<String>();
+
+                for (Map.Entry<Object, Object> en : headerMappings.entrySet())
+                {
+                    String key = en.getKey().toString();
+                    String value = en.getValue().toString();
+
+                    mappingList.add(key + "=" + value);
+                }
+
+                Object[] bindingItemValues = {queueName, mappingList.toArray(new String[0])};
+                CompositeData bindingData = new CompositeDataSupport(_bindingDataType,
+                                                                     _bindingItemNames,
+                                                                     bindingItemValues);
+                _bindingList.put(bindingData);
+            }
+
+            return _bindingList;
+        }
+
+        /**
+         * Creates bindings. Binding pattern is as follows-
+         * <attributename>=<value>,<attributename>=<value>,...
+         * @param queueName
+         * @param binding
+         * @throws JMException
+         */
+        public void createBinding(String queueName, String binding)
+            throws JMException
+        {
+            AMQQueue queue = queueRegistry.getQueue(queueName);
+
+            if (queue == null)
+            {
+                throw new JMException("Queue \"" + queueName + "\" is not registered with the exchange.");
+            }
+
+            String[] bindings  = binding.split(",");
+            FieldTable fieldTable = new FieldTable();
+            for (int i = 0; i < bindings.length; i++)
+            {
+                String[] keyAndValue = bindings[i].split("=");
+                if (keyAndValue == null || keyAndValue.length < 2)
+                {
+                    throw new JMException("Format for headers binding should be \"<attribute1>=<value1>,<attribute2>=<value2>\" ");
+                }
+                fieldTable.put(keyAndValue[0], keyAndValue[1]);
+            }
+
+            _bindings.add(new Registration(new HeadersBinding(fieldTable), queue));
+        }
+
+    } // End of MBean class
+
+    public void registerQueue(String routingKey, AMQQueue queue, FieldTable args) throws AMQException
+    {
+        _logger.debug("Exchange " + getName() + ": Binding " + queue.getName() + " with " + args);
+        _bindings.add(new Registration(new HeadersBinding(args), queue));
+    }
+
+    public void deregisterQueue(String routingKey, AMQQueue queue) throws AMQException
+    {
+        _logger.debug("Exchange " + getName() + ": Unbinding " + queue.getName());
+        _bindings.remove(new Registration(null, queue));
+    }
+
+    public void route(AMQMessage payload) throws AMQException
+    {
+        Map headers = getHeaders(payload.getContentHeaderBody());
+        if (_logger.isDebugEnabled())
+        {
+            _logger.debug("Exchange " + getName() + ": routing message with headers " + headers);
+        }
+        boolean delivered = false;
+        for (Registration e : _bindings)
+        {
+            if (e.binding.matches(headers))
+            {
+                if (_logger.isDebugEnabled())
+                {
+                    _logger.debug("Exchange " + getName() + ": delivering message with headers " +
+                                  headers + " to " + e.queue.getName());
+                }
+                e.queue.deliver(payload);
+                delivered = true;
+            }
+        }
+        if (!delivered)
+        {
+            _logger.warn("Exchange " + getName() + ": message not routable.");
+        }
+    }
+
+    protected Map getHeaders(ContentHeaderBody contentHeaderFrame)
+    {
+        //what if the content type is not 'basic'? 'file' and 'stream' content classes also define headers,
+        //but these are not yet implemented.
+        return ((BasicContentHeaderProperties) contentHeaderFrame.properties).getHeaders();
+    }
+
+    protected ExchangeMBean createMBean() throws AMQException
+    {
+        try
+        {
+            return new HeadersExchangeMBean();
+        }
+        catch (NotCompliantMBeanException ex)
+        {
+            _logger.error("Exception occured in creating the HeadersExchangeMBean", ex);
+            throw new AMQException("Exception occured in creating the HeadersExchangeMBean", ex);
+        }
+    }
+
+    private static class Registration
+    {
+        private final HeadersBinding binding;
+        private final AMQQueue queue;
+
+        Registration(HeadersBinding binding, AMQQueue queue)
+        {
+            this.binding = binding;
+            this.queue = queue;
+        }
+
+        public int hashCode()
+        {
+            return queue.hashCode();
+        }
+
+        public boolean equals(Object o)
+        {
+            return o instanceof Registration && ((Registration) o).queue.equals(queue);
+        }
+    }
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/Index.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/Index.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/Index.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/Index.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,85 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.exchange;
+
+import org.apache.qpid.server.queue.AMQQueue;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * An index of queues against routing key. Allows multiple queues to be stored
+ * against the same key. Used in the DestNameExchange.
+ */
+class Index
+{
+    private ConcurrentMap<String, List<AMQQueue>> _index
+            = new ConcurrentHashMap<String, List<AMQQueue>>();
+
+    boolean add(String key, AMQQueue queue)
+    {
+        List<AMQQueue> queues = _index.get(key);
+        if(queues == null)
+        {
+            queues = new CopyOnWriteArrayList<AMQQueue>();
+            //next call is atomic, so there is no race to create the list
+            List<AMQQueue> active = _index.putIfAbsent(key, queues);
+            if(active != null)
+            {
+                //someone added the new one in faster than we did, so use theirs
+                queues = active;
+            }
+        }
+        if(queues.contains(queue))
+        {
+            return false;
+        }
+        else
+        {
+            return queues.add(queue);
+        }
+    }
+
+    boolean remove(String key, AMQQueue queue)
+    {
+        List<AMQQueue> queues = _index.get(key);
+        if (queues != null)
+        {
+            boolean removed = queues.remove(queue);
+            if (queues.size() == 0)
+            {
+                _index.remove(key);
+            }
+            return removed;
+        }
+        return false;
+    }
+
+    List<AMQQueue> get(String key)
+    {
+        return _index.get(key);
+    }
+
+    Map<String, List<AMQQueue>> getBindingsMap()
+    {
+        return _index;
+    }
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ManagedExchange.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ManagedExchange.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ManagedExchange.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/ManagedExchange.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,90 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.exchange;
+
+import org.apache.qpid.server.management.MBeanAttribute;
+import org.apache.qpid.server.management.MBeanOperation;
+import org.apache.qpid.server.management.MBeanOperationParameter;
+
+import javax.management.openmbean.TabularData;
+import javax.management.JMException;
+import javax.management.MBeanOperationInfo;
+import java.io.IOException;
+
+/**
+ * The management interface exposed to allow management of an Exchange.
+ * @author  Robert J. Greig
+ * @author  Bhupendra Bhardwaj
+ * @version 0.1
+ */
+public interface ManagedExchange
+{
+    static final String TYPE = "Exchange";
+
+    /**
+     * Returns the name of the managed exchange.
+     * @return the name of the exchange.
+     * @throws IOException
+     */
+    @MBeanAttribute(name="Name", description="Name of exchange")
+    String getName() throws IOException;
+
+    @MBeanAttribute(name="TicketNo", description="Exchange Ticket No")
+    Integer getTicketNo() throws IOException;
+
+    /**
+     * Tells if the exchange is durable or not.
+     * @return true if the exchange is durable.
+     * @throws IOException
+     */
+    @MBeanAttribute(name="Durable", description="true if Exchange is durable")
+    boolean isDurable() throws IOException;
+
+    /**
+     * Tells if the exchange is set for autodelete or not.
+     * @return true if the exchange is set as autodelete.
+     * @throws IOException
+     */
+    @MBeanAttribute(name="AutoDelete", description="true if Exchange is AutoDelete")
+    boolean isAutoDelete() throws IOException;
+
+    // Operations
+
+    /**
+     * Returns all the bindings this exchange has with the queues.
+     * @return  the bindings with the exchange.
+     * @throws IOException
+     * @throws JMException
+     */
+    @MBeanOperation(name="viewBindings", description="view the queue bindings for this exchange")
+    TabularData viewBindings() throws IOException, JMException;
+
+    /**
+     * Creates new binding with the given queue and binding.
+     * @param queueName
+     * @param binding
+     * @throws JMException
+     */
+    @MBeanOperation(name="createBinding",
+                         description="create a new binding with this exchange",
+                         impact= MBeanOperationInfo.ACTION)
+    void createBinding(@MBeanOperationParameter(name="queue name", description="queue name") String queueName,
+                       @MBeanOperationParameter(name="binding", description="queue binding")String binding)
+        throws JMException;
+
+}
\ No newline at end of file

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/MessageRouter.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/MessageRouter.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/MessageRouter.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/MessageRouter.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,36 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.exchange;
+
+import org.apache.qpid.server.queue.AMQMessage;
+import org.apache.qpid.AMQException;
+
+/**
+ * Separated out from the ExchangeRegistry interface to allow components
+ * that use only this part to have a dependency with a reduced footprint.
+ *
+ */
+public interface MessageRouter
+{
+    /**
+     * Routes content through exchanges, delivering it to 1 or more queues.
+     * @param message the message to be routed
+     * @throws org.apache.qpid.AMQException if something goes wrong delivering data
+     */
+    void routeContent(AMQMessage message) throws AMQException;
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/NoRouteException.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/NoRouteException.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/NoRouteException.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/exchange/NoRouteException.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,39 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.exchange;
+
+import org.apache.qpid.server.RequiredDeliveryException;
+import org.apache.qpid.server.queue.AMQMessage;
+import org.apache.qpid.protocol.AMQConstant;
+
+/**
+ * Thrown by an exchange if there is no way to route a message with the
+ * mandatory flag set.
+ */
+public class NoRouteException extends RequiredDeliveryException
+{
+    public NoRouteException(String msg, AMQMessage message)
+    {
+        super(msg, message);
+    }
+
+    public int getReplyCode()
+    {
+        return AMQConstant.NO_ROUTE.getCode();
+    }
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/AMQManagedObject.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/AMQManagedObject.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/AMQManagedObject.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/AMQManagedObject.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,94 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.management;
+
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanNotificationInfo;
+import javax.management.NotCompliantMBeanException;
+import javax.management.NotificationBroadcaster;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+
+/**
+ * This class provides additinal feature of Notification Broadcaster to the
+ * DefaultManagedObject.
+ * @author  Bhupendra Bhardwaj
+ * @version 0.1
+ */
+public abstract class AMQManagedObject extends DefaultManagedObject
+                                       implements NotificationBroadcaster
+{
+    /**
+     * broadcaster support class
+     */
+    protected NotificationBroadcasterSupport _broadcaster = new NotificationBroadcasterSupport();
+
+    /**
+     * sequence number for notifications
+     */
+    protected long _notificationSequenceNumber = 0;
+
+    protected MBeanInfo _mbeanInfo;
+
+    protected AMQManagedObject(Class<?> managementInterface, String typeName)
+        throws NotCompliantMBeanException
+    {
+        super(managementInterface, typeName);
+        buildMBeanInfo();
+    }
+
+    @Override
+    public MBeanInfo getMBeanInfo()
+    {
+        return _mbeanInfo;
+    }
+    
+    private void buildMBeanInfo() throws NotCompliantMBeanException
+    {
+        _mbeanInfo = new MBeanInfo(this.getClass().getName(),
+                      MBeanIntrospector.getMBeanDescription(this.getClass()),
+                      MBeanIntrospector.getMBeanAttributesInfo(getManagementInterface()),
+                      MBeanIntrospector.getMBeanConstructorsInfo(this.getClass()),
+                      MBeanIntrospector.getMBeanOperationsInfo(getManagementInterface()),
+                      this.getNotificationInfo());
+    }
+
+
+
+    // notification broadcaster implementation
+
+    public void addNotificationListener(NotificationListener listener,
+                                        NotificationFilter filter,
+                                        Object handback)
+    {
+        _broadcaster.addNotificationListener(listener, filter, handback);
+    }
+
+    public void removeNotificationListener(NotificationListener listener)
+        throws ListenerNotFoundException
+    {
+        _broadcaster.removeNotificationListener(listener);
+    }
+
+    public MBeanNotificationInfo[] getNotificationInfo()
+    {
+        return null;
+    } 
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/DefaultManagedObject.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/DefaultManagedObject.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/DefaultManagedObject.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/DefaultManagedObject.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,183 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.management;
+
+import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import org.apache.qpid.AMQException;
+
+/**
+ * Provides implementation of the boilerplate ManagedObject interface. Most managed objects should find it useful
+ * to extend this class rather than implementing ManagedObject from scratch.
+ *
+ */
+public abstract class DefaultManagedObject extends StandardMBean implements ManagedObject
+{
+    private Class<?> _managementInterface;
+
+    private String _typeName;
+
+	private ManagedObjectRegistry managedObjectRegistry;
+
+    protected DefaultManagedObject(Class<?> managementInterface, String typeName)
+        throws NotCompliantMBeanException
+    {
+        super(managementInterface);
+        _managementInterface = managementInterface;
+        _typeName = typeName;
+    }
+
+    public String getType()
+    {
+        return _typeName;
+    }
+
+    public Class<?> getManagementInterface()
+    {
+        return _managementInterface;
+    }
+
+    public ManagedObject getParentObject()
+    {
+        return null;
+    }
+
+    public void register() throws AMQException
+    {
+        try
+        {
+            getManagedObjectRegistry().registerObject(this);
+        }
+        catch (JMException e)
+        {
+            throw new AMQException("Error registering managed object " + this + ": " + e, e);
+        }
+    }
+
+    public void unregister() throws AMQException
+    {
+        try
+        {
+            getManagedObjectRegistry().unregisterObject(this);
+        }
+        catch (JMException e)
+        {
+            throw new AMQException("Error unregistering managed object: " + this + ": " + e, e);
+        }
+    }
+
+    private ManagedObjectRegistry getManagedObjectRegistry() {
+    	if( managedObjectRegistry == null ) {
+    		managedObjectRegistry = createManagedObjectRegistry();
+    	}
+		return managedObjectRegistry;
+	}
+	public void setManagedObjectRegistry(ManagedObjectRegistry managedObjectRegistry) {
+		this.managedObjectRegistry = managedObjectRegistry;
+	}
+	private ManagedObjectRegistry createManagedObjectRegistry() {
+		return new NoopManagedObjectRegistry();
+	}
+
+	public String toString()
+    {
+        return getObjectInstanceName() + "[" + getType() + "]";
+    }
+
+    /**
+     * Created the ObjectName as per the JMX Specs
+     * @return ObjectName
+     * @throws MalformedObjectNameException
+     */
+    public ObjectName getObjectName()
+        throws MalformedObjectNameException
+    {
+        String name = getObjectInstanceName();
+        StringBuffer objectName = new StringBuffer(ManagedObject.DOMAIN);
+
+        objectName.append(":type=");
+        objectName.append(getHierarchicalType(this));
+
+        objectName.append(",");
+        objectName.append(getHierarchicalName(this));
+        objectName.append("name=").append(name);
+
+        return new ObjectName(objectName.toString());
+    }
+
+    private String getHierarchicalType(ManagedObject obj)
+    {
+        String parentType = null;
+        if (obj.getParentObject() != null)
+        {
+            parentType = getHierarchicalType(obj.getParentObject()).toString();
+            return parentType + "." + obj.getType();
+        }
+        else
+            return obj.getType();
+    }
+
+    private String getHierarchicalName(ManagedObject obj)
+    {
+        String parentName = null;
+        if (obj.getParentObject() != null)
+        {
+            parentName = obj.getParentObject().getType() + "=" +
+                         obj.getParentObject().getObjectInstanceName() + ","+
+                         getHierarchicalName(obj.getParentObject());
+
+            return parentName;
+        }
+        else
+            return "";
+    }
+
+    protected static StringBuffer jmxEncode(StringBuffer jmxName, int attrPos)
+    {
+        for (int i = attrPos; i < jmxName.length(); i++)
+        {
+            if (jmxName.charAt(i) == ',')
+            {
+                jmxName.setCharAt(i, ';');
+            }
+            else if (jmxName.charAt(i) == ':')
+            {
+                jmxName.setCharAt(i, '-');
+            }
+            else if (jmxName.charAt(i) == '?' ||
+                    jmxName.charAt(i) == '*' ||
+                    jmxName.charAt(i) == '\\')
+            {
+                jmxName.insert(i, '\\');
+                i++;
+            }
+            else if (jmxName.charAt(i) == '\n')
+            {
+                jmxName.insert(i, '\\');
+                i++;
+                jmxName.setCharAt(i, 'n');
+            }
+        }
+        return jmxName;
+    }
+
+}
\ No newline at end of file

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/JMXManagedObjectRegistry.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,49 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.management;
+
+import org.apache.log4j.Logger;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import java.lang.management.ManagementFactory;
+
+public class JMXManagedObjectRegistry implements ManagedObjectRegistry
+{
+    private static final Logger _log = Logger.getLogger(JMXManagedObjectRegistry.class);
+
+    private final MBeanServer _mbeanServer;
+
+    public JMXManagedObjectRegistry()
+    {
+        _log.info("Initialising managed object registry using platform MBean server");
+        // we use the platform MBean server currently but this must be changed or at least be configuurable
+        _mbeanServer = ManagementFactory.getPlatformMBeanServer();
+    }
+
+    public void registerObject(ManagedObject managedObject) throws JMException
+    {
+         _mbeanServer.registerMBean(managedObject, managedObject.getObjectName());
+    }
+
+    public void unregisterObject(ManagedObject managedObject) throws JMException
+    {
+        _mbeanServer.unregisterMBean(managedObject.getObjectName());
+    }
+
+}
\ No newline at end of file

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanAttribute.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanAttribute.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanAttribute.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanAttribute.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,39 @@
+package org.apache.qpid.server.management;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ *
+ */
+
+/**
+ * Annotation for MBean attributes. This should be used with getter or setter
+ * methods of attributes.
+ * @author  Bhupendra Bhardwaj
+ * @version 0.1
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@Inherited
+public @interface MBeanAttribute
+{
+    String name();
+    String description();
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanConstructor.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanConstructor.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanConstructor.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanConstructor.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,37 @@
+package org.apache.qpid.server.management;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ *
+ */
+
+/**
+ * Annotation for MBean constructors.
+ * @author  Bhupendra Bhardwaj
+ * @version 0.1
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.CONSTRUCTOR)
+@Inherited
+public @interface MBeanConstructor
+{
+    String value();
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanDescription.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanDescription.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanDescription.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanDescription.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,36 @@
+package org.apache.qpid.server.management;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ *
+ */
+
+/**
+ * Annotation for MBean class.
+ * @author  Bhupendra Bhardwaj
+ * @version 0.1
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Inherited
+public @interface MBeanDescription {
+    String value();
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanIntrospector.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanIntrospector.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanIntrospector.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanIntrospector.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,385 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.management;
+
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanParameterInfo;
+import javax.management.NotCompliantMBeanException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This class is a utility class to introspect the MBean class and the management
+ * interface class for various purposes.
+ * @author  Bhupendra Bhardwaj
+ * @version 0.1
+ */
+class MBeanIntrospector {
+
+    private static final String _defaultAttributeDescription = "Management attribute";
+    private static final String _defaultOerationDescription = "Management operation";
+    private static final String _defaultConstructorDescription = "MBean constructor";
+    private static final String _defaultMbeanDescription = "Management interface of the MBean";
+
+    /**
+     * Introspects the management interface class for MBean attributes.
+     * @param interfaceClass
+     * @return MBeanAttributeInfo[]
+     * @throws NotCompliantMBeanException
+     */
+    static MBeanAttributeInfo[] getMBeanAttributesInfo(Class interfaceClass)
+        throws NotCompliantMBeanException
+    {
+        List<MBeanAttributeInfo> attributesList = new ArrayList<MBeanAttributeInfo>();
+
+        /**
+         * Using reflection, all methods of the managemetn interface will be analysed,
+         * and MBeanInfo will be created.
+         */
+        for (Method method : interfaceClass.getMethods())
+        {
+            int    argCount = method.getParameterTypes().length;
+            String name = method.getName();
+            Class<?>  resultType = method.getReturnType();
+            MBeanAttributeInfo attributeInfo = null;
+
+            if (isAttributeGetterMethod(method))
+            {
+                String desc = getAttributeDescription(method);
+                attributeInfo = new MBeanAttributeInfo(name.substring(3),
+                                                resultType.getName(),
+                                                desc,
+                                                true,
+                                                false,
+                                                false);
+                int index = getIndexIfAlreadyExists(attributeInfo, attributesList);
+                if (index == -1)
+                {
+                    attributesList.add(attributeInfo);
+                }
+                else
+                {
+                    attributeInfo = new MBeanAttributeInfo(name.substring(3),
+                                                resultType.getName(),
+                                                desc,
+                                                true,
+                                                true,
+                                                false);
+                    attributesList.set(index, attributeInfo);
+                }
+            }
+            else if (isAttributeSetterMethod(method))
+            {
+                String desc = getAttributeDescription(method);
+                attributeInfo = new MBeanAttributeInfo(name.substring(3),
+                                                method.getParameterTypes()[0].getName(),
+                                                desc,
+                                                false,
+                                                true,
+                                                false);
+                int index = getIndexIfAlreadyExists(attributeInfo, attributesList);
+                if (index == -1)
+                {
+                    attributesList.add(attributeInfo);
+                }
+                else
+                {
+                    attributeInfo = new MBeanAttributeInfo(name.substring(3),
+                                                method.getParameterTypes()[0].getName(),
+                                                desc,
+                                                true,
+                                                true,
+                                                false);
+                    attributesList.set(index, attributeInfo);
+                }
+            }
+            else if (isAttributeBoolean(method))
+            {
+                attributeInfo = new MBeanAttributeInfo(name.substring(2),
+                                                resultType.getName(),
+                                                getAttributeDescription(method),
+                                                true,
+                                                false,
+                                                true);
+                attributesList.add(attributeInfo);
+            }
+        }
+
+        return attributesList.toArray(new MBeanAttributeInfo[0]);
+    }
+
+    /**
+     * Introspects the management interface class for management operations.
+     * @param interfaceClass
+     * @return MBeanOperationInfo[]
+     */
+    static MBeanOperationInfo[] getMBeanOperationsInfo(Class interfaceClass)
+    {
+        List<MBeanOperationInfo> operationsList = new ArrayList<MBeanOperationInfo>();
+
+        for (Method method : interfaceClass.getMethods())
+        {
+            if (!isAttributeGetterMethod(method) &&
+                !isAttributeSetterMethod(method) &&
+                !isAttributeBoolean(method))
+            {
+                operationsList.add(getOperationInfo(method));
+            }
+        }
+
+        return operationsList.toArray(new MBeanOperationInfo[0]);
+    }
+
+    /**
+     * Checks if the method is an attribute getter method.
+     * @param method
+     * @return true if the method is an attribute getter method.
+     */
+    private static boolean isAttributeGetterMethod(Method method)
+    {
+        if (!(method.getName().equals("get")) &&
+            method.getName().startsWith("get") &&
+            method.getParameterTypes().length == 0 &&
+            !method.getReturnType().equals(void.class))
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * Checks if the method is an attribute setter method.
+     * @param method
+     * @return true if the method is an attribute setter method.
+     */
+    private static boolean isAttributeSetterMethod(Method method)
+    {
+        if (!(method.getName().equals("set")) &&
+            method.getName().startsWith("set") &&
+            method.getParameterTypes().length == 1 &&
+            method.getReturnType().equals(void.class))
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * Checks if the attribute is a boolean and the method is a isX kind og method.
+     * @param method
+     * @return true if the method is an attribute isX type of method
+     */
+    private static boolean isAttributeBoolean(Method method)
+    {
+        if (!(method.getName().equals("is")) &&
+            method.getName().startsWith("is") &&
+            method.getParameterTypes().length == 0 &&
+            method.getReturnType().equals(boolean.class))
+        {
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * Helper method to retrieve the attribute index from the list of attributes.
+     * @param attribute
+     * @param list
+     * @return attribute index no. -1 if attribtue doesn't exist
+     * @throws NotCompliantMBeanException
+     */
+    private static int getIndexIfAlreadyExists(MBeanAttributeInfo attribute,
+                                                    List<MBeanAttributeInfo> list)
+        throws NotCompliantMBeanException
+    {
+        String exceptionMsg = "Conflicting attribute methods for attribute " + attribute.getName();
+
+        for (MBeanAttributeInfo memberAttribute : list)
+        {
+            if (attribute.getName().equals(memberAttribute.getName()))
+            {
+                if (!attribute.getType().equals(memberAttribute.getType()))
+                {
+                    throw new NotCompliantMBeanException(exceptionMsg);
+                }
+                if (attribute.isReadable() && memberAttribute.isReadable())
+                {
+                    if (attribute.isIs() != memberAttribute.isIs())
+                    {
+                        throw new NotCompliantMBeanException(exceptionMsg);
+                    }
+                }
+
+                return list.indexOf(memberAttribute);
+            }
+        }
+
+        return -1;
+    }
+
+    /**
+     * Retrieves the attribute description from annotation
+     * @param attributeMethod
+     * @return attribute description
+     */
+    private static String getAttributeDescription(Method attributeMethod)
+    {
+        MBeanAttribute anno = attributeMethod.getAnnotation(MBeanAttribute.class);
+        if (anno != null)
+        {
+            return anno.description();
+        }
+        return _defaultAttributeDescription;
+    }
+
+    /**
+     * Introspects the method to retrieve the operation information.
+     * @param operation
+     * @return MBeanOperationInfo
+     */
+    private static MBeanOperationInfo getOperationInfo(Method operation)
+    {
+        MBeanOperationInfo operationInfo = null;
+        Class<?> returnType = operation.getReturnType();
+
+        MBeanParameterInfo[] paramsInfo = getParametersInfo(operation.getParameterAnnotations(),
+                                                            operation.getParameterTypes());
+
+        String operationDesc = _defaultOerationDescription;
+        int impact = MBeanOperationInfo.UNKNOWN;
+
+        if (operation.getAnnotation(MBeanOperation.class) != null)
+        {
+            operationDesc = operation.getAnnotation(MBeanOperation.class).description();
+            impact = operation.getAnnotation(MBeanOperation.class).impact();
+        }
+        operationInfo = new MBeanOperationInfo(operation.getName(),
+                                               operationDesc,
+                                               paramsInfo,
+                                               returnType.getName(),
+                                               impact);
+
+        return operationInfo;
+    }
+
+    /**
+     * Constructs the parameter info.
+     * @param paramsAnno
+     * @param paramTypes
+     * @return MBeanParameterInfo[]
+     */
+    private static MBeanParameterInfo[] getParametersInfo(Annotation[][] paramsAnno,
+                                                          Class<?>[] paramTypes)
+    {
+        int noOfParams = paramsAnno.length;
+
+        MBeanParameterInfo[] paramsInfo = new MBeanParameterInfo[noOfParams];
+
+        for (int i = 0; i < noOfParams; i++)
+        {
+            MBeanParameterInfo paramInfo = null;
+            String type = paramTypes[i].getName();
+            for (Annotation anno : paramsAnno[i])
+            {
+                String name,desc;
+                if (MBeanOperationParameter.class.isInstance(anno))
+                {
+                    name = MBeanOperationParameter.class.cast(anno).name();
+                    desc = MBeanOperationParameter.class.cast(anno).description();
+                    paramInfo = new MBeanParameterInfo(name, type, desc);
+                }
+            }
+
+
+            if (paramInfo == null)
+            {
+                paramInfo = new MBeanParameterInfo("p " + (i + 1), type, "parameter " + (i + 1));
+            }
+            if (paramInfo != null)
+                paramsInfo[i] = paramInfo;
+        }
+
+        return paramsInfo;
+    }
+
+    /**
+     * Introspects the MBean class for constructors
+     * @param implClass
+     * @return MBeanConstructorInfo[]
+     */
+    static MBeanConstructorInfo[] getMBeanConstructorsInfo(Class implClass)
+    {
+        List<MBeanConstructorInfo> constructors = new ArrayList<MBeanConstructorInfo>();
+
+        for (Constructor cons : implClass.getConstructors())
+        {
+            MBeanConstructorInfo constructorInfo = getMBeanConstructorInfo(cons);
+            //MBeanConstructorInfo constructorInfo = new MBeanConstructorInfo("desc", cons);
+            if (constructorInfo != null)
+                constructors.add(constructorInfo);
+        }
+
+        return constructors.toArray(new MBeanConstructorInfo[0]);
+    }
+
+    /**
+     * Retrieves the constructor info from given constructor.
+     * @param cons
+     * @return MBeanConstructorInfo
+     */
+    private static MBeanConstructorInfo getMBeanConstructorInfo(Constructor cons)
+    {
+        String desc = null;
+        Annotation anno = cons.getAnnotation(MBeanConstructor.class);
+        if (anno != null && MBeanConstructor.class.isInstance(anno))
+        {
+            desc = MBeanConstructor.class.cast(anno).value();
+        }
+
+        //MBeanParameterInfo[] paramsInfo = getParametersInfo(cons.getParameterAnnotations(),
+        //                                                    cons.getParameterTypes());
+
+        return new MBeanConstructorInfo(cons.getName(),
+                                        desc != null ? _defaultConstructorDescription : desc ,
+                                        null);
+    }
+
+    /**
+     * Retrieves the description from the annotations of given class
+     * @param annotatedClass
+     * @return class description
+     */
+    static String getMBeanDescription(Class annotatedClass)
+    {
+        Annotation anno = annotatedClass.getAnnotation(MBeanDescription.class);
+        if (anno != null && MBeanDescription.class.isInstance(anno))
+        {
+            return MBeanDescription.class.cast(anno).value();
+        }
+        return _defaultMbeanDescription;
+    }
+
+}
\ No newline at end of file

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanOperation.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanOperation.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanOperation.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanOperation.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,40 @@
+package org.apache.qpid.server.management;
+
+import javax.management.MBeanOperationInfo;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Target;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ *
+ */
+
+/**
+ * Annotation for MBean operations.
+ * @author  Bhupendra Bhardwaj
+ * @version 0.1
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@Inherited
+public @interface MBeanOperation
+{
+    String name();
+    String description();
+    int impact() default MBeanOperationInfo.INFO;
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanOperationParameter.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanOperationParameter.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanOperationParameter.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/MBeanOperationParameter.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,35 @@
+package org.apache.qpid.server.management;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.
+ *
+ */
+
+/**
+ * Annotation for MBean operation parameters.
+ * @author  Bhupendra Bhardwaj
+ * @version 0.1
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+public @interface MBeanOperationParameter {
+    String name();
+    String description();
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/Managable.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/Managable.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/Managable.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/Managable.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,31 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.management;
+
+/**
+ * Any object that can return a related MBean should implement this interface.
+ *
+ * This enables other classes to get the managed object, which in turn is useful when
+ * constructing relationships between managed objects without having to maintain
+ * separate data structures containing MBeans.
+ *
+ */
+public interface Managable
+{
+    ManagedObject getManagedObject();
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedBroker.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedBroker.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedBroker.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedBroker.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,95 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.management;
+
+import javax.management.JMException;
+import javax.management.MBeanOperationInfo;
+import java.io.IOException;
+
+/**
+ * The ManagedBroker is the management interface to expose management
+ * features of the Broker.
+ *
+ * @author   Bhupendra Bhardwaj
+ * @version  0.1
+ */
+public interface ManagedBroker
+{
+    static final String TYPE = "BrokerManager";
+
+    /**
+     * Creates a new Exchange.
+     * @param name
+     * @param type
+     * @param durable
+     * @param passive
+     * @throws IOException
+     * @throws JMException
+     */
+    @MBeanOperation(name="createNewExchange", description="Creates a new Exchange",
+                         impact= MBeanOperationInfo.ACTION)
+    void createNewExchange(@MBeanOperationParameter(name="name", description="Name of the new exchange")String name,
+                           @MBeanOperationParameter(name="excahnge type", description="Type of the exchange")String type,
+                           @MBeanOperationParameter(name="durable", description="true if the Exchang should be durable")boolean durable,
+                           @MBeanOperationParameter(name="passive", description="true of the Exchange should be passive")boolean passive)
+        throws IOException, JMException;
+
+    /**
+     * unregisters all the channels, queuebindings etc and unregisters
+     * this exchange from managed objects.
+     * @param exchange
+     * @throws IOException
+     * @throws JMException
+     */
+    @MBeanOperation(name="unregisterExchange",
+                         description="Unregisters all the related channels and queuebindings of this exchange",
+                         impact= MBeanOperationInfo.ACTION)
+    void unregisterExchange(@MBeanOperationParameter(name="exchange name", description="Name of the exchange")String exchange)
+        throws IOException, JMException;
+
+    /**
+     * Create a new Queue on the Broker server
+     * @param queueName
+     * @param durable
+     * @param owner
+     * @param autoDelete
+     * @throws IOException
+     * @throws JMException
+     */
+    @MBeanOperation(name="createQueue", description="Create a new Queue on the Broker server",
+                         impact= MBeanOperationInfo.ACTION)
+    void createQueue(@MBeanOperationParameter(name="queue name", description="Name of the new queue")String queueName,
+                     @MBeanOperationParameter(name="durable", description="true if the queue should be durable")boolean durable,
+                     @MBeanOperationParameter(name="owner", description="Owner name")String owner,
+                     @MBeanOperationParameter(name="autoDelete", description="true if the queue should be auto delete") boolean autoDelete)
+        throws IOException, JMException;
+
+    /**
+     * Unregisters the Queue bindings, removes the subscriptions and unregisters
+     * from the managed objects.
+     * @param queueName
+     * @throws IOException
+     * @throws JMException
+     */
+    @MBeanOperation(name="deleteQueue",
+                         description="Unregisters the Queue bindings, removes the subscriptions and deletes the queue",
+                         impact= MBeanOperationInfo.ACTION)
+    void deleteQueue(@MBeanOperationParameter(name="queue name", description="Name of the queue")String queueName)
+        throws IOException, JMException;
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedObject.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedObject.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedObject.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedObject.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.management;
+
+import org.apache.qpid.AMQException;
+
+import javax.management.ObjectName;
+import javax.management.MalformedObjectNameException;
+
+/**
+ * This should be implemented by all Managable objects.
+ */
+public interface ManagedObject
+{
+    static final String DOMAIN = "org.apache.qpid";
+
+    /**
+     * @return the name that uniquely identifies this object instance. It must be
+     * unique only among objects of this type at this level in the hierarchy so
+     * the uniqueness should not be too difficult to ensure.
+     */
+    String getObjectInstanceName();
+
+    String getType();
+
+    Class<?> getManagementInterface();
+
+    ManagedObject getParentObject();
+
+    void register() throws AMQException;
+
+    void unregister() throws AMQException;
+
+    /**
+     * Returns the ObjectName required for the mbeanserver registration.
+     * @return ObjectName
+     * @throws MalformedObjectNameException
+     */
+    ObjectName getObjectName() throws MalformedObjectNameException;
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedObjectRegistry.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedObjectRegistry.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedObjectRegistry.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/ManagedObjectRegistry.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,39 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.management;
+
+import javax.management.JMException;
+
+/**
+ * Handles the registration (and unregistration and so on) of managed objects.
+ *
+ * Managed objects are responsible for exposting attributes, operations and notifications. They will expose
+ * these outside the JVM therefore it is important not to use implementation objects directly as managed objects.
+ * Instead, creating inner classes and exposing those is an effective way of exposing internal state in a
+ * controlled way.
+ *
+ * Although we do not explictly use them while targetting Java 5, the enhanced MXBean approach in Java 6 will
+ * be the obvious choice for managed objects.
+ *
+ */
+public interface ManagedObjectRegistry
+{
+    void registerObject(ManagedObject managedObject) throws JMException;
+
+    void unregisterObject(ManagedObject managedObject) throws JMException;
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/NoopManagedObjectRegistry.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/NoopManagedObjectRegistry.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/NoopManagedObjectRegistry.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/management/NoopManagedObjectRegistry.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,45 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.management;
+
+import org.apache.log4j.Logger;
+
+import javax.management.JMException;
+
+/**
+ * This managed object registry does not actually register MBeans. This can be used in tests when management is
+ * not required or when management has been disabled.
+ *
+ */
+public class NoopManagedObjectRegistry implements ManagedObjectRegistry
+{
+    private static final Logger _log = Logger.getLogger(NoopManagedObjectRegistry.class);
+
+    public NoopManagedObjectRegistry()
+    {
+        _log.info("Management is disabled");
+    }
+
+    public void registerObject(ManagedObject managedObject) throws JMException
+    {
+    }
+
+    public void unregisterObject(ManagedObject managedObject) throws JMException
+    {
+    }
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSession.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,28 @@
+package org.apache.qpid.server.protocol;
+
+import org.apache.activemq.amqp.command.AMQDataBlock;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.server.AMQChannel;
+
+public interface AMQProtocolSession {
+
+    /**
+     * Write a datablock, encoding where necessary (e.g. into a sequence of bytes)
+     * @param frame the frame to be encoded and written
+     */
+	void writeFrame(AMQDataBlock frame);
+
+	/**
+     * @return a key that uniquely identifies this session
+     */
+	String getKey();
+		
+    /**
+     * Get the channel for this session associated with the specified id. A channel
+     * id is unique per connection (i.e. per session).
+     * @param channelId the channel id which must be valid
+     * @return null if no channel exists, the channel otherwise
+     */
+	AMQChannel getChannel(int channelId) throws AMQException;
+
+}

Added: incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/protocol/ExchangeInitialiser.java
URL: http://svn.apache.org/viewvc/incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/protocol/ExchangeInitialiser.java?view=auto&rev=468414
==============================================================================
--- incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/protocol/ExchangeInitialiser.java (added)
+++ incubator/activemq/sandbox/qpid/src/main/java/org/apache/qpid/server/protocol/ExchangeInitialiser.java Fri Oct 27 08:27:20 2006
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.server.protocol;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.server.exchange.ExchangeFactory;
+import org.apache.qpid.server.exchange.ExchangeRegistry;
+
+public class ExchangeInitialiser
+{
+    public void initialise(ExchangeFactory factory, ExchangeRegistry registry) throws AMQException{        
+        define(registry, factory, ExchangeDefaults.DIRECT_EXCHANGE_NAME, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
+        define(registry, factory, ExchangeDefaults.TOPIC_EXCHANGE_NAME, ExchangeDefaults.TOPIC_EXCHANGE_CLASS);
+        define(registry, factory, ExchangeDefaults.HEADERS_EXCHANGE_NAME, ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
+    }
+
+    private void define(ExchangeRegistry r, ExchangeFactory f,
+                        String name, String type) throws AMQException
+    {
+        r.registerExchange(f.createExchange(name, type, true, false, 0));
+    }
+}



Mime
View raw message