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 2014/05/02 11:43:20 UTC

svn commit: r1591845 - in /qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2: ./ src/main/java/org/apache/qpid/server/qmf2/ src/main/java/org/apache/qpid/server/qmf2/agentdata/ src/main/resources/MET...

Author: rgodfrey
Date: Fri May  2 09:43:19 2014
New Revision: 1591845

URL: http://svn.apache.org/r1591845
Log:
QPID-5610 , QPID-5578 , QPID-5715 : Update the QMF2 plugin for changes to VirtualHost(Node) model and ConfiguredObject model

Added:
    qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java
    qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPluginImpl.java
      - copied, changed from r1591843, qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java
Removed:
    qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementFactory.java
    qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.PluginFactory
Modified:
    qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/pom.xml
    qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementAgent.java
    qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/agentdata/Broker.java

Modified: qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/pom.xml
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/pom.xml?rev=1591845&r1=1591844&r2=1591845&view=diff
==============================================================================
--- qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/pom.xml (original)
+++ qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/pom.xml Fri May  2 09:43:19 2014
@@ -44,6 +44,13 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.qpid</groupId>
+      <artifactId>qpid-broker-codegen</artifactId>
+      <version>${project.version}</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
       <version>${slf4j-version}</version>

Modified: qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementAgent.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementAgent.java?rev=1591845&r1=1591844&r2=1591845&view=diff
==============================================================================
--- qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementAgent.java (original)
+++ qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementAgent.java Fri May  2 09:43:19 2014
@@ -22,29 +22,24 @@
 package org.apache.qpid.server.qmf2;
 
 // Misc Imports
+
+import static org.apache.qpid.qmf2.common.WorkItem.WorkItemType.METHOD_CALL;
+
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-// Simple Logging Facade 4 Java
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-// QMF2 Imports
 import org.apache.qpid.qmf2.agent.Agent;
 import org.apache.qpid.qmf2.agent.MethodCallParams;
 import org.apache.qpid.qmf2.agent.MethodCallWorkItem;
 import org.apache.qpid.qmf2.agent.QmfAgentData;
 import org.apache.qpid.qmf2.common.ObjectId;
-import org.apache.qpid.qmf2.common.QmfData;
-import org.apache.qpid.qmf2.common.QmfEvent;
 import org.apache.qpid.qmf2.common.QmfEventListener;
 import org.apache.qpid.qmf2.common.QmfException;
-import org.apache.qpid.qmf2.common.QmfType;
 import org.apache.qpid.qmf2.common.WorkItem;
 import org.apache.qpid.qmf2.util.ConnectionHelper;
-import static org.apache.qpid.qmf2.common.WorkItem.WorkItemType.*;
-
-// Java Broker model Imports
 import org.apache.qpid.server.model.Binding;
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.ConfigurationChangeListener;
@@ -52,13 +47,15 @@ import org.apache.qpid.server.model.Conf
 import org.apache.qpid.server.model.Connection;
 import org.apache.qpid.server.model.Consumer;
 import org.apache.qpid.server.model.Exchange;
-import org.apache.qpid.server.model.LifetimePolicy;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.Publisher;
 import org.apache.qpid.server.model.Queue;
 import org.apache.qpid.server.model.Session;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.VirtualHostNode;
+
+// Simple Logging Facade 4 Java
+// QMF2 Imports
+// Java Broker model Imports
 
 /**
  * This class implements a QMF2 Agent providing access to the Java broker Management Objects via QMF2 thus
@@ -215,8 +212,10 @@ public class QmfManagementAgent implemen
     {
         childAdded(null, _broker);
 
-        for (VirtualHost<?> vhost : _broker.getVirtualHosts())
+        for (VirtualHostNode<?> vhostNode : _broker.getVirtualHostNodes())
         {
+            VirtualHost<?,?,?> vhost = vhostNode.getVirtualHost();
+
             // We don't add QmfAgentData VirtualHost objects. Possibly TODO, but it's a bit awkward at the moment
             // because the C++ Broker doesn't *seem* to do much with them and the command line tools such
             // as qpid-config don't appear to be VirtualHost aware. A way to stay compatible is to mark queues,

Added: qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java?rev=1591845&view=auto
==============================================================================
--- qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java (added)
+++ qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java Fri May  2 09:43:19 2014
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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.server.qmf2;
+
+import org.apache.qpid.server.model.ManagedAttribute;
+import org.apache.qpid.server.model.ManagedObject;
+import org.apache.qpid.server.model.Plugin;
+
+@ManagedObject( category = false, type = "MANAGEMENT-QMF2" )
+public interface QmfManagementPlugin<X extends QmfManagementPlugin<X>> extends Plugin<X>
+{
+
+    // attributes
+    String CONNECTION_URL = "connectionURL";
+
+    @ManagedAttribute( automate = true , defaultValue = "amqp://guest:guest@/?brokerlist='tcp://0.0.0.0:5672'")
+    String getConnectionURL();
+}

Copied: qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPluginImpl.java (from r1591843, qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java)
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPluginImpl.java?p2=qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPluginImpl.java&p1=qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java&r1=1591843&r2=1591845&rev=1591845&view=diff
==============================================================================
--- qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPlugin.java (original)
+++ qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/QmfManagementPluginImpl.java Fri May  2 09:43:19 2014
@@ -22,33 +22,26 @@
 package org.apache.qpid.server.qmf2;
 
 // Misc Imports
-import java.lang.reflect.Type;
-import java.net.InetSocketAddress;
-import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.UUID;
 
-// Simple Logging Facade 4 Java
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-// Java Broker Management Imports
+import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
-
 import org.apache.qpid.server.model.Broker;
 import org.apache.qpid.server.model.Exchange;
 import org.apache.qpid.server.model.LifetimePolicy;
-import org.apache.qpid.server.model.ManagedAttribute;
-import org.apache.qpid.server.model.Plugin;
+import org.apache.qpid.server.model.ManagedAttributeField;
+import org.apache.qpid.server.model.ManagedObjectFactoryConstructor;
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.VirtualHostNode;
 import org.apache.qpid.server.model.adapter.AbstractPluginAdapter;
 
-import org.apache.qpid.server.plugin.PluginFactory;
-import org.apache.qpid.server.util.MapValueConverter;
+// Simple Logging Facade 4 Java
+// Java Broker Management Imports
 
 /**
  * This class is a Qpid Java Broker Plugin which follows the Plugin API added in Qpid 0.22 it implements 
@@ -88,60 +81,45 @@ import org.apache.qpid.server.util.MapVa
  * </pre>
  * @author Fraser Adams
  */
-public class QmfManagementPlugin extends AbstractPluginAdapter<QmfManagementPlugin>
+public class QmfManagementPluginImpl extends AbstractPluginAdapter<QmfManagementPluginImpl>
 {
-    private static final Logger _log = LoggerFactory.getLogger(QmfManagementPlugin.class);
+    private static final Logger _log = LoggerFactory.getLogger(QmfManagementPluginImpl.class);
 
     private static final String OPERATIONAL_LOGGING_NAME = "QMF2";
 
     /************* Static initialiser used to implement org.apache.qpid.server.model.Plugin *************/
 
     public static final String PLUGIN_TYPE = "MANAGEMENT-QMF2";
+    public static final String QMF_DEFAULT_DIRECT = "qmf.default.direct";
+    public static final String QMF_DEFAULT_TOPIC = "qmf.default.topic";
 
-    // attributes
-    public static final String NAME = "name";
-    public static final String CONNECTION_URL = "connectionURL";
-
-    // default values
-    public static final String DEFAULT_NAME = "qmf2Management";
-    public static final String DEFAULT_CONNECTION_URL = "amqp://guest:guest@/?brokerlist='tcp://0.0.0.0:5672'";
-
-    @SuppressWarnings("serial")
-    private static final Map<String, Object> DEFAULTS = Collections.unmodifiableMap(new HashMap<String, Object>()
-    {{
-        put(NAME, DEFAULT_NAME);
-        put(CONNECTION_URL, DEFAULT_CONNECTION_URL);
-        put(PluginFactory.PLUGIN_TYPE, PLUGIN_TYPE);
-    }});
-
-    @SuppressWarnings("serial")
-    private static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>()
-    {{
-        put(NAME, String.class);
-        put(CONNECTION_URL, String.class);
-        put(PluginFactory.PLUGIN_TYPE, String.class);
-    }});
 
     /************************************ End of Static initialiser *************************************/
 
     private final Broker<?> _broker;          // Passed in by Plugin bootstrapping.
-    private final String _defaultVirtualHost; // Pulled from the broker attributes.
-    private final String _connectionURL;      // Pulled from the Plugin config.
+    private String _defaultVirtualHost; // Pulled from the broker attributes.
+
+    @ManagedAttributeField
+    private String _connectionURL;      // Pulled from the Plugin config.
     private QmfManagementAgent _agent;
 
     /**
      * Constructor, called at broker startup by QmfManagementFactory.createInstance().
-     * @param id the UUID of the Plugin.
      * @param attributes a Map containing configuration information for the Plugin.
      * @param broker the root Broker Management Object from which the other Management Objects may be obtained.
      */
-    public QmfManagementPlugin(UUID id, Broker broker, Map<String, Object> attributes)
+    @ManagedObjectFactoryConstructor
+    public QmfManagementPluginImpl(Map<String, Object> attributes, Broker broker)
     {
-        super(id, DEFAULTS, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), broker);
-        addParent(Broker.class, broker);
+        super(attributes, broker);
         _broker = broker;
-        _defaultVirtualHost = (String)broker.getAttribute("defaultVirtualHost");
-        _connectionURL = (String)getAttribute(CONNECTION_URL);
+    }
+
+    @Override
+    protected void onOpen()
+    {
+        super.onOpen();
+        _defaultVirtualHost = _broker.getDefaultVirtualHost();
     }
 
     /**
@@ -149,12 +127,11 @@ public class QmfManagementPlugin extends
      * has its own state set to State.ACTIVE or State.STOPPED.
      * When State.ACTIVE is set this calls the start() method to startup the Plugin, when State.STOPPED
      * is set this calls the stop() method to shutdown the Plugin.
-     * @param currentState the current state of the Plugin (ignored).
      * @param desiredState the desired state of the Plugin (either State.ACTIVE or State.STOPPED).
      * @return true if a valid state has been set, otherwise false.
      */
     @Override // From org.apache.qpid.server.model.adapter.AbstractAdapter
-    protected boolean setState(State currentState, State desiredState)
+    protected boolean setState(State desiredState)
     {
         if (desiredState == State.ACTIVE)
         {
@@ -195,47 +172,44 @@ public class QmfManagementPlugin extends
             // Iterate through the Virtual Hosts looking for the default Virtual Host. When we find the default
             // we create the QMF exchanges then construct the QmfManagementAgent passing it the ConnectionURL.
             boolean foundDefaultVirtualHost = false;
-            for (VirtualHost<?> vhost : _broker.getVirtualHosts())
+
+            for(VirtualHostNode<?> node : _broker.getVirtualHostNodes())
             {
+                VirtualHost<?, ?, ?> vhost = node.getVirtualHost();
+
                 if (vhost.getName().equals(_defaultVirtualHost))
                 {
                     foundDefaultVirtualHost = true;
 
-                    // Check if "qmf.default.direct" or "qmf.default.topic" already exist. It is important to
-                    // check as attempting to add an Exchange that already exists will cause IllegalArgumentException.
-                    boolean needDefaultDirect = true;
-                    boolean needDefaultTopic  = true;
-                    for (Exchange exchange : vhost.getExchanges())
-                    {
-                        if (exchange.getName().equals("qmf.default.direct"))
-                        {
-                            needDefaultDirect = false;
-                        }
-                        else if (exchange.getName().equals("qmf.default.topic"))
-                        {
-                            needDefaultTopic = false;
-                        }
-                    }
-
                     // Create the QMF2 exchanges if necessary.
-                    Map<String, Object> attributes = Collections.emptyMap();
-                    if (needDefaultDirect)
+                    if (vhost.getChildByName(Exchange.class, QMF_DEFAULT_DIRECT) == null)
                     {
-                        vhost.createExchange("qmf.default.direct", State.ACTIVE, true,
-                                             LifetimePolicy.PERMANENT, "direct", attributes);
+                        Map<String, Object> attributes = new HashMap<>();
+                        attributes.put(Exchange.NAME, QMF_DEFAULT_DIRECT);
+                        attributes.put(Exchange.TYPE, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
+                        attributes.put(Exchange.STATE, State.ACTIVE);
+                        attributes.put(Exchange.LIFETIME_POLICY, LifetimePolicy.PERMANENT);
+                        attributes.put(Exchange.DURABLE, true);
+                        vhost.createExchange(attributes);
                     }
 
-                    if (needDefaultTopic)
+                    if (vhost.getChildByName(Exchange.class, QMF_DEFAULT_TOPIC) == null)
                     {
-                        vhost.createExchange("qmf.default.topic", State.ACTIVE, true,
-                                             LifetimePolicy.PERMANENT, "topic", attributes);
+                        Map<String, Object> attributes = new HashMap<>();
+                        attributes.put(Exchange.NAME, QMF_DEFAULT_TOPIC);
+                        attributes.put(Exchange.TYPE, ExchangeDefaults.TOPIC_EXCHANGE_CLASS);
+                        attributes.put(Exchange.STATE, State.ACTIVE);
+                        attributes.put(Exchange.LIFETIME_POLICY, LifetimePolicy.PERMANENT);
+                        attributes.put(Exchange.DURABLE, true);
+                        vhost.createExchange(attributes);
                     }
 
                     // Now create the *real* Agent which maps Broker Management Objects to QmdAgentData Objects.
                     _agent = new QmfManagementAgent(_connectionURL, _broker);
                 }
-            }
 
+
+            }
             // If we can't find a defaultVirtualHost we log that fact, the Plugin can't start in this case.
             // Question. If defaultVirtualHost isn't configured or it doesn't match the name of one of the actual
             // Virtual Hosts should we make the first one we find the de facto default for this Plugin??
@@ -271,34 +245,11 @@ public class QmfManagementPlugin extends
     }
 
     /**
-     * Accessor to retrieve the names of the available attributes. It is important to provide this overridden
-     * method because the Constructor uses this information when populating the underlying AbstractPlugin
-     * information. If we don't provide this override method getAttribute(name) will return the default values.
-     * @return the names of the available Plugin config attributes as a Collection.
-     */
-    @Override // From org.apache.qpid.server.model.adapter.AbstractPluginAdapter
-    public Collection<String> getAttributeNames()
-    {
-        return getAttributeNames(QmfManagementPlugin.class);
-    }
-
-    /**
-     * Accessor to retrieve the Plugin Type.
-     * @return the Plugin Type e.g. the String "MANAGEMENT-QMF2".
-     */
-    @Override // From org.apache.qpid.server.model.Plugin
-    public String getPluginType()
-    {
-        return PLUGIN_TYPE;
-    }
-
-    /**
      * Accessor to retrieve the connectionURL attribute.
      * @return the JMS connectionURL of the Plugin.
      */
-    @ManagedAttribute
     public String getConnectionURL()
     {
-        return (String)getAttribute(CONNECTION_URL);
+        return _connectionURL;
     }
 }

Modified: qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/agentdata/Broker.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/agentdata/Broker.java?rev=1591845&r1=1591844&r2=1591845&view=diff
==============================================================================
--- qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/agentdata/Broker.java (original)
+++ qpid/branches/QPID-5610-maven3-build-qmf-tools/qpid/tools/src/java/qpid-broker-plugins-management-qmf2/src/main/java/org/apache/qpid/server/qmf2/agentdata/Broker.java Fri May  2 09:43:19 2014
@@ -22,30 +22,20 @@
 package org.apache.qpid.server.qmf2.agentdata;
 
 // Misc Imports
+
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
-// Simple Logging Facade 4 Java
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-// QMF2 Imports
 import org.apache.qpid.qmf2.agent.Agent;
 import org.apache.qpid.qmf2.agent.QmfAgentData;
 import org.apache.qpid.qmf2.common.Handle;
 import org.apache.qpid.qmf2.common.ObjectId;
 import org.apache.qpid.qmf2.common.QmfData;
-/*import org.apache.qpid.qmf2.common.QmfEvent;
-import org.apache.qpid.qmf2.common.QmfEventListener;
-import org.apache.qpid.qmf2.common.QmfException;
-import org.apache.qpid.qmf2.common.QmfType;*/
-import org.apache.qpid.qmf2.common.SchemaEventClass;
-import org.apache.qpid.qmf2.common.SchemaMethod;
 import org.apache.qpid.qmf2.common.SchemaObjectClass;
-import org.apache.qpid.qmf2.common.SchemaProperty;
-
-// Java Broker model Imports
 import org.apache.qpid.server.model.Binding;
 import org.apache.qpid.server.model.Exchange;
 import org.apache.qpid.server.model.LifetimePolicy;
@@ -55,6 +45,15 @@ import org.apache.qpid.server.model.Queu
 import org.apache.qpid.server.model.State;
 import org.apache.qpid.server.model.Transport;
 import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.VirtualHostNode;
+
+// Simple Logging Facade 4 Java
+// QMF2 Imports
+/*import org.apache.qpid.qmf2.common.QmfEvent;
+import org.apache.qpid.qmf2.common.QmfEventListener;
+import org.apache.qpid.qmf2.common.QmfException;
+import org.apache.qpid.qmf2.common.QmfType;*/
+// Java Broker model Imports
 
 /**
  * This class provides a concrete implementation of QmfAgentData for the Broker Management Object.
@@ -112,8 +111,8 @@ public class Broker extends QmfAgentData
      */
     private class NameParser
     {
-        private String _vhostName = _defaultVirtualHost;
-        private VirtualHost<?> _vhost = null;
+        private String _vhostName;
+        private VirtualHost<?,?,?> _vhost = null;
         private String _exchangeName = "";
         private Exchange<?> _exchange = null;
         private String _queueName = "";
@@ -148,13 +147,18 @@ public class Broker extends QmfAgentData
                     _vhostName = _vhostName.substring(6, _vhostName.length());
                 }
             }
+            else
+            {
+                _vhostName = _defaultVirtualHost;
+            }
 
             // If the vhostName isn't malformed then try to find the actual Virtual Host that it relates to.
             // If it is malformed the vhost stays set to null, which will cause an exception to be returned later.
             if (!malformedVHostName)
             {
-                for (VirtualHost vhost : _broker.getVirtualHosts())
+                for (VirtualHostNode<?> vhostNode : _broker.getVirtualHostNodes())
                 {
+                    VirtualHost<?,?,?> vhost = vhostNode.getVirtualHost();
                     if (vhost.getName().equals(_vhostName))
                     {
                         _vhost = vhost;
@@ -539,22 +543,19 @@ System.out.println("properties = " + pro
                                 return;
                             }
 
-                            // TODO delete this block when adding an AlternateExchange is implemented.
-                            if (alternateExchange != null)
-                            {
-                                agent.raiseException(handle,
-                                    "Setting an Alternate Exchange on an Exchange is not yet implemented.");
-                                return;
-                            }
-
                             // Note that for Qpid 0.20 the "qpid.msg_sequence=1" and "qpid.ive=1" properties are
                             // not suppored, indeed no exchange properties seem to be supported yet.
-                            vhost.createExchange(nameParser.getExchangeName(), State.ACTIVE, durable,
-                                                 LifetimePolicy.PERMANENT, exchangeType, properties);
-                            if (alternateExchange != null)
-                            {
-                                // TODO set Alternate Exchange. There doesn't seem to be a way to do this yet!!!
-                            }
+                            Map<String,Object> attributes = new HashMap<>();
+                            attributes.put(Exchange.NAME, nameParser.getExchangeName());
+                            attributes.put(Exchange.STATE, State.ACTIVE);
+                            attributes.put(Exchange.DURABLE, durable);
+                            attributes.put(Exchange.LIFETIME_POLICY, LifetimePolicy.PERMANENT);
+                            attributes.put(Exchange.TYPE, exchangeType);
+                            attributes.put(Exchange.ALTERNATE_EXCHANGE, alternateExchange);
+
+
+                            vhost.createExchange(attributes);
+
                         } // End of create exchange.
                         else if (type.equals("queue")) // create queue.
                         {
@@ -583,7 +584,6 @@ System.out.println("properties = " + pro
                             attributes.put(Queue.DURABLE, durable);
                             attributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.PERMANENT);
 
-                            Queue queue = vhost.createQueue(attributes);
 
                             // Set the queue's alternateExchange, which is just a little bit involved......
                             // The queue.setAttribute() method needs an org.apache.qpid.server.model.Exchange instance
@@ -600,13 +600,14 @@ System.out.println("properties = " + pro
                                 QmfAgentData object = agent.getObject(objectId);
                                 if (object != null)
                                 {
-                                    org.apache.qpid.server.qmf2.agentdata.Exchange ex = 
+                                    org.apache.qpid.server.qmf2.agentdata.Exchange ex =
                                         (org.apache.qpid.server.qmf2.agentdata.Exchange)object;
 
                                     Exchange altEx = ex.getExchange();
-                                    queue.setAttribute("alternateExchange", null, altEx);
+                                    attributes.put(Queue.ALTERNATE_EXCHANGE, altEx.getId());
                                 }
                             }
+                            Queue queue = vhost.createQueue(attributes);
                         }
                         else if (type.equals("binding")) // create binding.
                         {



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