You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2020/10/20 15:00:03 UTC

[activemq-artemis] branch master updated: ARTEMIS-2838 adding missing "send message" tab for addresses

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new 3a82c83  ARTEMIS-2838 adding missing "send message" tab for addresses
     new d954554  This closes #3309
3a82c83 is described below

commit 3a82c830f096563f0372a33d4371832b13494550
Author: Andy Taylor <an...@gmail.com>
AuthorDate: Tue Oct 20 14:37:16 2020 +0100

    ARTEMIS-2838 adding missing "send message" tab for addresses
    
    plus removed some erronious logging
    
    https://issues.apache.org/jira/browse/ARTEMIS-2838
---
 .../plugin/js/components/addressSendMessage.js     | 122 ++++++++++++++
 .../main/webapp/plugin/js/components/addresses.js  |  10 +-
 .../src/main/webapp/plugin/js/components/browse.js |   2 +-
 .../webapp/plugin/js/components/connections.js     |  10 +-
 .../main/webapp/plugin/js/components/consumers.js  |  10 +-
 .../webapp/plugin/js/components/createAddress.js   |  12 +-
 .../webapp/plugin/js/components/deleteQueue.js     |  10 +-
 .../main/webapp/plugin/js/components/navigation.js |  18 +-
 .../webapp/plugin/js/components/preferences.js     |   2 +-
 .../main/webapp/plugin/js/components/producers.js  |   8 +-
 .../src/main/webapp/plugin/js/components/queues.js |  12 +-
 .../webapp/plugin/js/components/sendMessage.js     | 153 ++---------------
 .../main/webapp/plugin/js/components/sessions.js   |  14 +-
 .../src/main/webapp/plugin/js/components/status.js |   4 +-
 .../plugin/js/services/sendMessageService.js       | 182 +++++++++++++++++++++
 15 files changed, 380 insertions(+), 189 deletions(-)

diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addressSendMessage.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addressSendMessage.js
new file mode 100644
index 0000000..04b5ac0
--- /dev/null
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addressSendMessage.js
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+ /// <reference path="tree.component.ts"/>
+var Artemis;
+(function (Artemis) {
+    Artemis.log.debug("loading address send message");
+    Artemis._module.component('artemisAddressSendMessage', {
+        template:
+            `<h1>Send Message
+                <button type="button" class="btn btn-link jvm-title-popover"
+                          uib-popover-template="'send-message-instructions.html'" popover-placement="bottom-left"
+                          popover-title="Instructions" popover-trigger="'outsideClick'">
+                    <span class="pficon pficon-help"></span>
+                </button>
+            </h1>
+
+            <div class="alert alert-warning" ng-show="$ctrl.message.noCredentials">
+                <span class="pficon pficon-warning-triangle-o"></span>
+                <strong>No credentials set for endpoint!</strong>
+                Please set your username and password in the
+                <a href="#" class="alert-link" ng-click="$ctrl.message.openPrefs()">Preferences</a> page.
+            </div>
+
+            <div class="row artemis-message-configuration">
+
+                <div class="col-sm-12">
+                    <form>
+                        <div class="form-group">
+                            <label>Durable </label>
+                            <input id="durable" type="checkbox" ng-model="$ctrl.message.durable" value="true">
+                        </div>
+                    </form>
+                </div>
+            </div>
+
+            <h3>Headers</h3>
+
+            <div class="form-group"  ng-if="$ctrl.message.headers.length > 0">
+                <table class="scr-component-references-table table">
+                    <tbody>
+                        <tr class="input-group"  ng-repeat="header in $ctrl.message.headers">
+                            <td><input type="text" class="form-control" ng-model="header.name" placeholder="Name" autocomplete="off" id="name"></td>
+                            <td><input type="text" class="form-control" ng-model="header.value" placeholder="Value" autocomplete="off" id="value"></td>
+                            <td><div class="input-group-prepend">
+                                <button type="button" class="btn btn-default" title="Delete" ng-click="$ctrl.message.removeHeader(header)">
+                                    <span class="pficon pficon-delete"></span>
+                                </button>
+                            </div></td>
+                        </tr>
+                    </tbody>
+                </table>
+            </div>
+
+            <p>
+                <button type="button" class="btn btn-primary artemis-add-message-button" ng-click="$ctrl.message.addHeader()">Add Header</button>
+            </p>
+
+            <h3>Body</h3>
+
+            <form>
+                <div class="form-group">
+                    <div hawtio-editor="$ctrl.message.message" mode="codeMirrorOptions.mode.name"></div>
+                </div>
+                <div class="form-group">
+                    <select class="form-control artemis-send-message-format" ng-model="codeMirrorOptions.mode.name">
+                        <option value="javascript">JSON</option>
+                        <option value="xml">XML</option>
+                    </select>
+                    <button class="btn btn-default" ng-click="$ctrl.message.formatMessage()"
+                       title="Automatically pretty prints the message so its easier to read">Format
+                    </button>
+                </div>
+            </form>
+
+            <p>
+                <button type="button" class="btn btn-primary artemis-send-message-button" ng-click="$ctrl.message.sendMessage($ctrl.message.durable)">Send message</button>
+            </p>
+            <script type="text/ng-template" id="send-message-instructions.html">
+            <div>
+                <p>
+                    This page allows you to send a message to the chosen address. The message will be of type <code>text</code>
+                    message and it will be possible to add headers to the message. The sending of the message will be authenticated
+                    using the username and password set ion <code>preferences</code>, if this is not set then these will
+                    be null.
+                </p>
+            </div>
+        </script>
+        `,
+        controller: AddressSendMessageController
+    })
+    .name;
+    Artemis.log.debug("loaded queue " + Artemis.createQueueModule);
+
+    function AddressSendMessageController($route, $scope, $element, $timeout, workspace,  jolokia, localStorage, $location, artemisMessage, messageCreator) {
+        Core.initPreferenceScope($scope, localStorage, {
+            'durable': {
+                'value': true,
+                'converter': Core.parseBooleanValue
+            }
+        });
+        var ctrl = this;
+        ctrl.messageCreator = messageCreator;
+        ctrl.message = ctrl.messageCreator.createNewMessage($scope, $location, $route, localStorage, artemisMessage, workspace, $element, $timeout, jolokia);
+
+    }
+    AddressSendMessageController.$inject = ['$route', '$scope', '$element', '$timeout', 'workspace', 'jolokia', 'localStorage', '$location', 'artemisMessage', 'messageCreator'];
+
+})(Artemis || (Artemis = {}));
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js
index f579cd8..1ebf072 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/addresses.js
@@ -16,7 +16,7 @@
  */
 var Artemis;
 (function (Artemis) {
-    //Artemis.log.info("loading addresses");
+    //Artemis.log.debug("loading addresses");
     Artemis._module.component('artemisAddresses', {
         template:
             `<h1>Browse Addresses
@@ -135,14 +135,14 @@ var Artemis;
         };
 
         if (artemisAddress.address) {
-            Artemis.log.info("navigating to address = " + artemisAddress.address.address);
+            Artemis.log.debug("navigating to address = " + artemisAddress.address.address);
             ctrl.filter.values.field = ctrl.filter.fieldOptions[1].id;
             ctrl.filter.values.operation = ctrl.filter.operationOptions[0].id;
             ctrl.filter.values.value = artemisAddress.address.address;
         }
 
         selectQueues = function (address) {
-            Artemis.log.info("navigating to queues:" + address)
+            Artemis.log.debug("navigating to queues:" + address)
             artemisAddress.address = { address: address };
             $location.path("artemis/artemisQueues");
         };
@@ -156,12 +156,12 @@ var Artemis;
         function getAddressNid(address, $location) {
             var rootNID = getRootNid($location);
             var targetNID = rootNID + "addresses-" + address;
-            Artemis.log.info("targetNID=" + targetNID);
+            Artemis.log.debug("targetNID=" + targetNID);
             return targetNID;
         }
         function getRootNid($location) {
             var currentNid = $location.search()['nid'];
-            Artemis.log.info("current nid=" + currentNid);
+            Artemis.log.debug("current nid=" + currentNid);
             var firstDash = currentNid.indexOf('-');
             var secondDash = currentNid.indexOf('-', firstDash + 1);
             var thirdDash = currentNid.indexOf('-', secondDash + 1);
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/browse.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/browse.js
index 2fb9c5d..2373c16 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/browse.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/browse.js
@@ -379,7 +379,7 @@ var Artemis;
         }
 
         ctrl.refresh = function() {
-            Artemis.log.info(ctrl.filter)
+            Artemis.log.debug(ctrl.filter)
             ctrl.pagination.load();
         }
 
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js
index f6f2a8e..0983296 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/connections.js
@@ -16,7 +16,7 @@
  */
 var Artemis;
 (function (Artemis) {
-    Artemis.log.info("loading connections");
+    Artemis.log.debug("loading connections");
     Artemis._module.component('artemisConnections', {
         template:
             `
@@ -133,13 +133,13 @@ var Artemis;
         ];
 
         selectSessions = function (connection) {
-            Artemis.log.info("navigating to connection:" + connection)
+            Artemis.log.debug("navigating to connection:" + connection)
             artemisConnection.connection = { connectionID: connection };
             $location.path("artemis/artemisSessions");
         };
 
         if (artemisSession.session) {
-            Artemis.log.info("navigating to session = " + artemisSession.session.connectionID);
+            Artemis.log.debug("navigating to session = " + artemisSession.session.connectionID);
             ctrl.filter.values.field = ctrl.filter.fieldOptions[0].id;
             ctrl.filter.values.operation = ctrl.filter.operationOptions[0].id;
             ctrl.filter.values.value = artemisSession.session.connectionID;
@@ -179,7 +179,7 @@ var Artemis;
                     ctrl.pagination.reset();
                     ctrl.refreshed = false;
                 }
-                Artemis.log.info(JSON.stringify(connectionsFilter));
+                Artemis.log.debug(JSON.stringify(connectionsFilter));
                 jolokia.request({ type: 'exec', mbean: mbean, operation: method, arguments: [JSON.stringify(connectionsFilter), ctrl.pagination.pageNumber, ctrl.pagination.pageSize] }, Core.onSuccess(populateTable, { error: onError }));
             }
         };
@@ -190,7 +190,7 @@ var Artemis;
         }
 
         ctrl.closeConnection = function () {
-           Artemis.log.info("closing connection: " + ctrl.connectionToDelete);
+           Artemis.log.debug("closing connection: " + ctrl.connectionToDelete);
               if (mbean) {
                   jolokia.request({ type: 'exec',
                      mbean: mbean,
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js
index 0a199de..876c17b 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/consumers.js
@@ -160,26 +160,26 @@ var Artemis;
         };
 
         if (artemisConsumer.consumer) {
-            Artemis.log.info("navigating to consumer = " + artemisConsumer.consumer.sessionID);
+            Artemis.log.debug("navigating to consumer = " + artemisConsumer.consumer.sessionID);
             ctrl.filter.values.field = ctrl.filter.fieldOptions[1].id;
             ctrl.filter.values.operation = ctrl.filter.operationOptions[0].id;
             ctrl.filter.values.value = artemisConsumer.consumer.sessionID;
         }
 
         selectQueue = function (queue) {
-            Artemis.log.info("navigating to queue:" + queue)
+            Artemis.log.debug("navigating to queue:" + queue)
             artemisQueue.queue = { queue: queue };
             $location.path("artemis/artemisQueues");
         };
 
         selectAddress = function (address) {
-            Artemis.log.info("navigating to address:" + address)
+            Artemis.log.debug("navigating to address:" + address)
             artemisAddress.address = { address: address };
             $location.path("artemis/artemisAddresses");
         };
 
         selectSession = function (session) {
-            Artemis.log.info("navigating to session:" + session)
+            Artemis.log.debug("navigating to session:" + session)
             artemisSession.session = { session: session };
             $location.path("artemis/artemisSessions");
         };
@@ -191,7 +191,7 @@ var Artemis;
         }
 
         ctrl.closeConsumer = function () {
-           Artemis.log.info("closing session: " + ctrl.consumerToDelete);
+           Artemis.log.debug("closing session: " + ctrl.consumerToDelete);
               if (mbean) {
                   jolokia.request({ type: 'exec',
                      mbean: mbean,
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/createAddress.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/createAddress.js
index 5e06f15..09ff951 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/createAddress.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/createAddress.js
@@ -86,10 +86,10 @@ var Artemis;
         controller: CreateAddressController
     })
     .name;
-    Artemis.log.info("loaded address " + Artemis.addressModule);
+    Artemis.log.debug("loaded address " + Artemis.addressModule);
 
     function CreateAddressController($scope, workspace, jolokia, localStorage) {
-        Artemis.log.info("loaded address controller");
+        Artemis.log.debug("loaded address controller");
         var ctrl = this;
         ctrl.addressName = "";
         ctrl.routingType = "Anycast";
@@ -113,22 +113,22 @@ var Artemis;
         }
 
         ctrl.createAddress = function (name, routingType) {
-            Artemis.log.info("creating " + routingType);
+            Artemis.log.debug("creating " + routingType);
             var mbean = Artemis.getBrokerMBean(workspace, jolokia);
             if (mbean) {
                 if (routingType == "Multicast") {
                     $scope.message = "Created  Multicast Address " + name;
-                    Artemis.log.info(ctrl.message);
+                    Artemis.log.debug(ctrl.message);
                     jolokia.execute(mbean, "createAddress(java.lang.String,java.lang.String)", name, "MULTICAST",  Core.onSuccess(operationSuccess, { error: onError }));
                 }
                 else if (routingType == "Anycast") {
                     $scope.message = "Created Anycast Address " + name;
-                    Artemis.log.info(ctrl.message);
+                    Artemis.log.debug(ctrl.message);
                     jolokia.execute(mbean, "createAddress(java.lang.String,java.lang.String)", name, "ANYCAST",  Core.onSuccess(operationSuccess, { error: onError }));
                 }
                 else {
                     $scope.message = "Created Anycast/Multicast Address " + name;
-                    Artemis.log.info(ctrl.message);
+                    Artemis.log.debug(ctrl.message);
                     jolokia.execute(mbean, "createAddress(java.lang.String,java.lang.String)", name, "ANYCAST,MULTICAST",  Core.onSuccess(operationSuccess, { error: onError }));
                 }
             }
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/deleteQueue.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/deleteQueue.js
index 6b1143c..e13eb71 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/deleteQueue.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/deleteQueue.js
@@ -89,10 +89,10 @@ var Artemis;
         controller: DeleteQueueController
     })
     .name;
-    Artemis.log.info("loaded delete queue " + Artemis.createQueueModule);
+    Artemis.log.debug("loaded delete queue " + Artemis.createQueueModule);
 
     function DeleteQueueController($scope, workspace, jolokia, localStorage) {
-        Artemis.log.info("loaded queue controller");
+        Artemis.log.debug("loaded queue controller");
         var ctrl = this;
         ctrl.workspace = workspace;
         ctrl.deleteDialog = false;
@@ -130,19 +130,19 @@ var Artemis;
            var selection = ctrl.workspace.selection;
            var entries = selection.entries;
            var mbean = Artemis.getBrokerMBean(ctrl.workspace, jolokia);
-           Artemis.log.info(mbean);
+           Artemis.log.debug(mbean);
            if (mbean) {
                if (selection && jolokia && entries) {
                    var domain = selection.domain;
                    var name = entries["queue"];
-                   Artemis.log.info("name = " + name)
+                   Artemis.log.debug("name = " + name)
                    name = Core.unescapeHTML(name);
                    if (name.charAt(0) === '"' && name.charAt(name.length -1) === '"')
                    {
                        name = name.substr(1,name.length -2);
                    }
                    name = Artemis.ownUnescape(name);
-                   Artemis.log.info(name);
+                   Artemis.log.debug(name);
                    var operation;
                    $scope.message = "Deleted queue " + name;
                    jolokia.execute(mbean, "destroyQueue(java.lang.String)", name,  Core.onSuccess(operationPurgeSuccess, { error: onError }));
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/navigation.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/navigation.js
index 3036e6f..766074d 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/navigation.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/navigation.js
@@ -17,7 +17,7 @@
  /// <reference path="tree.component.ts"/>
 var Artemis;
 (function (Artemis) {
-    Artemis.log.info("loading navigation");
+    Artemis.log.debug("loading navigation");
     var TAB_CONFIG = {
         attributes: {
             title: 'Attributes',
@@ -51,6 +51,10 @@ var Artemis;
             title: 'Send message',
             route: '/artemis/artemisSendMessage'
         },
+        addressSendMessage: {
+            title: 'Send message',
+            route: '/artemis/artemisAddressSendMessage'
+        },
         browseQueue: {
             title: 'Browse queue',
             route: '/artemis/artemisBrowseQueue'
@@ -95,7 +99,7 @@ var Artemis;
         controller: ArtemisNavigationController
     })
     .name;
-    Artemis.log.info("loaded navigation " + Artemis.navigationModule);
+    Artemis.log.debug("loaded navigation " + Artemis.navigationModule);
 
     function ArtemisNavigationController($scope, $location, workspace, localStorage, jolokia) {
         'ngInject';
@@ -157,6 +161,9 @@ var Artemis;
                 if (shouldShowSendMessageTab(workspace)) {
                     tabs.push(new Nav.HawtioTab(TAB_CONFIG.sendMessage.title, TAB_CONFIG.sendMessage.route));
                 }
+                if (shouldShowAddressSendMessageTab(workspace)) {
+                    tabs.push(new Nav.HawtioTab(TAB_CONFIG.addressSendMessage.title, TAB_CONFIG.addressSendMessage.route));
+                }
                 if (shouldShowBrowseMessageTab(workspace)) {
                     tabs.push(new Nav.HawtioTab(TAB_CONFIG.browseQueue.title, TAB_CONFIG.browseQueue.route));
                 }
@@ -185,6 +192,10 @@ var Artemis;
             return workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'}) && hasQueueinvokeRights(workspace, "sendMessage");
         }
 
+        function shouldShowAddressSendMessageTab(workspace) {
+            return workspace.hasDomainAndProperties(artemisJmxDomain, {'component': 'addresses'}) && !workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'}) && hasQueueinvokeRights(workspace, "sendMessage");
+        }
+
         function shouldShowBrowseMessageTab(workspace) {
             return workspace.hasDomainAndProperties(artemisJmxDomain, {'subcomponent': 'queues'}) && hasQueueinvokeRights(workspace, "browse") && hasQueueinvokeRights(workspace, "countMessages");
         }
@@ -197,7 +208,7 @@ var Artemis;
                 arguments: [mbean, operation] },
                 Core.onSuccess(null));
 
-            Artemis.log.info(operation + "=" + response.value);
+            Artemis.log.debug(operation + "=" + response.value);
             return response.value;
         }
         function hasQueueinvokeRights(workspace, operation) {
@@ -223,6 +234,7 @@ var Artemis;
         when('/artemis/artemisCreateQueue', { template: '<artemis-create-queue></artemis-create-queue>'}).
         when('/artemis/artemisDeleteQueue', { template: '<artemis-delete-queue></artemis-delete-queue>'}).
         when('/artemis/artemisSendMessage', { template: '<artemis-send-message></artemis-send-message>'}).
+        when('/artemis/artemisAddressSendMessage', { template: '<artemis-address-send-message></artemis-address-send-message>'}).
         when('/artemis/artemisBrowseQueue', { template: '<artemis-browse-queue></artemis-browse-queue>'}).
         when('/artemis/artemisBrokerDiagram', { template: '<artemis-broker-diagram></artemis-broker-diagram>'}).
         when('/artemis/artemisStatus', { template: '<artemis-status></artemis-status>'}).
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/preferences.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/preferences.js
index 20f54ad..5c0f216 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/preferences.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/preferences.js
@@ -43,7 +43,7 @@ var Artemis;
 
    function configurePreferences(preferencesRegistry, $templateCache, workspace) {
 
-        Artemis.log.info("£££££££££££££££££££££££££rwerewrwerwerwe£££££££££££££££");
+        Artemis.log.debug("£££££££££££££££££££££££££rwerewrwerwerwe£££££££££££££££");
         var path = 'plugin/preferences.html';
         preferencesRegistry.addTab("Artemis", path, function () {
             return workspace.treeContainsDomainAndProperties("org.apache.activemq.artemis");
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js
index 3a4be61..0df9432 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/producers.js
@@ -16,7 +16,7 @@
  */
 var Artemis;
 (function (Artemis) {
-    Artemis.log.info("loading producers");
+    Artemis.log.debug("loading producers");
     Artemis._module.component('artemisProducers', {
         template:
             `<h1>Browse Consumers
@@ -130,19 +130,19 @@ var Artemis;
         };
 
         selectAddress = function (address) {
-            Artemis.log.info("navigating to address:" + address)
+            Artemis.log.debug("navigating to address:" + address)
             artemisAddress.address = { address: address };
             $location.path("artemis/artemisAddresses");
         };
 
         selectSession = function (session) {
-            Artemis.log.info("navigating to session:" + session)
+            Artemis.log.debug("navigating to session:" + session)
             artemisSession.session = { session: session };
             $location.path("artemis/artemisSessions");
         };
 
         if (artemisProducer.producer) {
-            Artemis.log.info("navigating to producer = " + artemisProducer.producer.sessionID);
+            Artemis.log.debug("navigating to producer = " + artemisProducer.producer.sessionID);
             ctrl.filter.values.field = ctrl.filter.fieldOptions[1].id;
             ctrl.filter.values.operation = ctrl.filter.operationOptions[0].id;
             ctrl.filter.values.value = artemisProducer.producer.sessionID;
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js
index 5d55693..71b7408 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/queues.js
@@ -16,7 +16,7 @@
  */
 var Artemis;
 (function (Artemis) {
-    //Artemis.log.info("loading addresses");
+    //Artemis.log.debug("loading addresses");
     Artemis._module.component('artemisQueues', {
         template:
             `<h1>Browse Queues
@@ -167,14 +167,14 @@ var Artemis;
         };
 
         if (artemisQueue.queue) {
-            Artemis.log.info("navigating to queue = " + artemisQueue.queue.queue);
+            Artemis.log.debug("navigating to queue = " + artemisQueue.queue.queue);
             ctrl.filter.values.field = ctrl.filter.fieldOptions[1].id;
             ctrl.filter.values.operation = ctrl.filter.operationOptions[0].id;
             ctrl.filter.values.value = artemisQueue.queue.queue;
         }
 
         if (artemisAddress.address) {
-            Artemis.log.info("navigating to queue = " + artemisAddress.address.address);
+            Artemis.log.debug("navigating to queue = " + artemisAddress.address.address);
             ctrl.filter.values.field = ctrl.filter.fieldOptions[3].id;
             ctrl.filter.values.operation = ctrl.filter.operationOptions[0].id;
             ctrl.filter.values.value = artemisAddress.address.address;
@@ -187,19 +187,19 @@ var Artemis;
             $location.path("artemis/operations").search({"tab": "artemis", "nid": getQueuesNid(item, $location)});
         };
         selectAddress = function (address) {
-            Artemis.log.info("navigating to address:" + address)
+            Artemis.log.debug("navigating to address:" + address)
             artemisAddress.address = { address: address };
             $location.path("artemis/artemisAddresses");
         };
         function getQueuesNid(item, $location) {
             var rootNID = getRootNid($location);
             var targetNID = rootNID + "addresses-" + item.address + "-queues-" + item.routingType.toLowerCase() + "-" + item.name;
-            Artemis.log.info("targetNID=" + targetNID);
+            Artemis.log.debug("targetNID=" + targetNID);
             return targetNID;
         }
         function getRootNid($location) {
             var currentNid = $location.search()['nid'];
-            Artemis.log.info("current nid=" + currentNid);
+            Artemis.log.debug("current nid=" + currentNid);
             var firstDash = currentNid.indexOf('-');
             var secondDash = currentNid.indexOf('-', firstDash + 1);
             var thirdDash = currentNid.indexOf('-', secondDash + 1);
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sendMessage.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sendMessage.js
index 66ba20c..92ad715 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sendMessage.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sendMessage.js
@@ -17,7 +17,7 @@
  /// <reference path="tree.component.ts"/>
 var Artemis;
 (function (Artemis) {
-    Artemis.log.info("loading send message");
+    Artemis.log.debug("loading send message");
     Artemis._module.component('artemisSendMessage', {
         template:
             `<h1>Send Message
@@ -28,11 +28,11 @@ var Artemis;
                 </button>
             </h1>
 
-            <div class="alert alert-warning" ng-show="$ctrl.noCredentials">
+            <div class="alert alert-warning" ng-show="$ctrl.message.noCredentials">
                 <span class="pficon pficon-warning-triangle-o"></span>
                 <strong>No credentials set for endpoint!</strong>
                 Please set your username and password in the
-                <a href="#" class="alert-link" ng-click="$ctrl.openPrefs()">Preferences</a> page.
+                <a href="#" class="alert-link" ng-click="$ctrl.message.openPrefs()">Preferences</a> page.
             </div>
 
             <div class="row artemis-message-configuration">
@@ -41,7 +41,7 @@ var Artemis;
                     <form>
                         <div class="form-group">
                             <label>Durable </label>
-                            <input id="durable" type="checkbox" ng-model="$ctrl.durable" value="true">
+                            <input id="durable" type="checkbox" ng-model="$ctrl.message.durable" value="true">
                         </div>
                     </form>
                 </div>
@@ -49,10 +49,10 @@ var Artemis;
 
             <h3>Headers</h3>
 
-            <div class="form-group"  ng-if="$ctrl.headers.length > 0">
+            <div class="form-group"  ng-if="$ctrl.message.headers.length > 0">
                 <table class="scr-component-references-table table">
                     <tbody>
-                        <tr class="input-group"  ng-repeat="header in $ctrl.headers">
+                        <tr class="input-group"  ng-repeat="header in $ctrl.message.headers">
                             <td><input type="text" class="form-control" ng-model="header.name" placeholder="Name" autocomplete="off" id="name"></td>
                             <td><input type="text" class="form-control" ng-model="header.value" placeholder="Value" autocomplete="off" id="value"></td>
                             <td><div class="input-group-prepend">
@@ -66,14 +66,14 @@ var Artemis;
             </div>
 
             <p>
-                <button type="button" class="btn btn-primary artemis-add-message-button" ng-click="$ctrl.addHeader()">Add Header</button>
+                <button type="button" class="btn btn-primary artemis-add-message-button" ng-click="$ctrl.message.addHeader()">Add Header</button>
             </p>
 
             <h3>Body</h3>
 
             <form>
                 <div class="form-group">
-                    <div hawtio-editor="$ctrl.message" mode="codeMirrorOptions.mode.name"></div>
+                    <div hawtio-editor="$ctrl.message.message" mode="codeMirrorOptions.mode.name"></div>
                 </div>
                 <div class="form-group">
                     <select class="form-control artemis-send-message-format" ng-model="codeMirrorOptions.mode.name">
@@ -87,7 +87,7 @@ var Artemis;
             </form>
 
             <p>
-                <button type="button" class="btn btn-primary artemis-send-message-button" ng-click="$ctrl.sendMessage($ctrl.durable)">Send message</button>
+                <button type="button" class="btn btn-primary artemis-send-message-button" ng-click="$ctrl.message.sendMessage($ctrl.durable)">Send message</button>
             </p>
             <script type="text/ng-template" id="send-message-instructions.html">
             <div>
@@ -103,9 +103,9 @@ var Artemis;
         controller: SendMessageController
     })
     .name;
-    Artemis.log.info("loaded queue " + Artemis.createQueueModule);
+    Artemis.log.debug("loaded queue " + Artemis.createQueueModule);
 
-    function SendMessageController($route, $scope, $element, $timeout, workspace,  jolokia, localStorage, $location, artemisMessage) {
+    function SendMessageController($route, $scope, $element, $timeout, workspace,  jolokia, localStorage, $location, artemisMessage, messageCreator) {
         Core.initPreferenceScope($scope, localStorage, {
             'durable': {
                 'value': true,
@@ -113,134 +113,9 @@ var Artemis;
             }
         });
         var ctrl = this;
-        ctrl.noCredentials = false;
-        ctrl.durable = true;
-        ctrl.message = "";
-        ctrl.headers = [];
-        // bind model values to search params...
-        Core.bindModelToSearchParam($scope, $location, "tab", "subtab", "compose");
-        Core.bindModelToSearchParam($scope, $location, "searchText", "q", "");
-        // only reload the page if certain search parameters change
-        Core.reloadWhenParametersChange($route, $scope, $location);
-        ctrl.checkCredentials = function () {
-            ctrl.noCredentials = (Core.isBlank(localStorage['artemisUserName']) || Core.isBlank(localStorage['artemisPassword']));
-        };
-        if ($location.path().indexOf('artemis') > -1) {
-            ctrl.localStorage = localStorage;
-            $scope.$watch('localStorage.artemisUserName', ctrl.checkCredentials);
-            $scope.$watch('localStorage.artemisPassword', ctrl.checkCredentials);
-            //prefill if it's a resent
-            if (artemisMessage.message !== null) {
-                ctrl.message = artemisMessage.message.bodyText;
-                if (artemisMessage.message.PropertiesText !== null) {
-                    for (var p in artemisMessage.message.StringProperties) {
-                        ctrl.headers.push({name: p, value: artemisMessage.message.StringProperties[p]});
-                    }
-                }
-            }
-            // always reset at the end
-            artemisMessage.message = null;
-        }
-
-        this.openPrefs = function () {
-            Artemis.log.info("opening prefs");
-            $location.path('/preferences').search({'pref': 'Artemis'});
-        }
-
-        var LANGUAGE_FORMAT_PREFERENCE = "defaultLanguageFormat";
-        var sourceFormat = workspace.getLocalStorage(LANGUAGE_FORMAT_PREFERENCE) || "javascript";
-
-        $scope.codeMirrorOptions = CodeEditor.createEditorSettings({
-            mode: {
-                name: sourceFormat
-            }
-        });
-
-        $scope.$on('hawtioEditor_default_instance', function (event, codeMirror) {
-            $scope.codeMirror = codeMirror;
-        });
-
-        ctrl.addHeader = function  () {
-            ctrl.headers.push({name: "", value: ""});
-            // lets set the focus to the last header
-            if ($element) {
-                $timeout(function () {
-                    var lastHeader = $element.find("input.headerName").last();
-                    lastHeader.focus();
-                }, 100);
-            }
-        }
-
-        this.removeHeader = function (header) {
-            var index = ctrl.headers.indexOf(header);
-            ctrl.headers.splice(index, 1);
-        };
-
-        ctrl.defaultHeaderNames = function () {
-            var answer = [];
-
-            function addHeaderSchema(schema) {
-                angular.forEach(schema.definitions.headers.properties, function (value, name) {
-                    answer.push(name);
-                });
-            }
-
-            addHeaderSchema(Artemis.jmsHeaderSchema);
-            return answer;
-        };
-
-        function operationSuccess() {
-            Core.notification("success", "Message sent!");
-            ctrl.headers = [];
-            ctrl.message = "";
-        };
-
-        function onError(response) {
-           Core.notification("error", "Could not send message: " + response.error);
-        }
-
-        ctrl.formatMessage = function () {
-            CodeEditor.autoFormatEditor($scope.codeMirror);
-        };
-        ctrl.sendMessage = function (durable) {
-            var body = ctrl.message;
-            Artemis.log.info(body);
-            doSendMessage(ctrl.durable, body);
-        };
-
-        function doSendMessage(durable, body) {
-            var selection = workspace.selection;
-            if (selection) {
-                var mbean = selection.objectName;
-                if (mbean) {
-                    var headers = null;
-                    if (ctrl.headers.length) {
-                        headers = {};
-                        angular.forEach(ctrl.headers, function (object) {
-                            var key = object.name;
-                            if (key) {
-                                headers[key] = object.value;
-                            }
-                        });
-                        Artemis.log.debug("About to send headers: " + JSON.stringify(headers));
-                    }
-
-                    var user = ctrl.localStorage["artemisUserName"];
-                    var pwd = ctrl.localStorage["artemisPassword"];
-
-                    if (!headers) {
-                        headers = {};
-                    }
-                    var type = 3;
-                    Artemis.log.debug(headers);
-                    Artemis.log.debug(type);
-                    Artemis.log.debug(body);
-                    Artemis.log.debug(durable);
-                    jolokia.execute(mbean, "sendMessage(java.util.Map, int, java.lang.String, boolean, java.lang.String, java.lang.String)", headers, type, body, durable, user, pwd,  Core.onSuccess(operationSuccess, { error: onError }));
-                }
-            }
-        }
+        ctrl.messageCreator = messageCreator;
+        ctrl.message = ctrl.messageCreator.createNewMessage($scope, $location, $route, localStorage, artemisMessage, workspace, $element, $timeout, jolokia);
     }
-    SendMessageController.$inject = ['$route', '$scope', '$element', '$timeout', 'workspace', 'jolokia', 'localStorage', '$location', 'artemisMessage'];
+    SendMessageController.$inject = ['$route', '$scope', '$element', '$timeout', 'workspace', 'jolokia', 'localStorage', '$location', 'artemisMessage', 'messageCreator'];
 
 })(Artemis || (Artemis = {}));
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js
index eab7be6..8abfab9 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/sessions.js
@@ -16,7 +16,7 @@
  */
 var Artemis;
 (function (Artemis) {
-    Artemis.log.info("loading sessions");
+    Artemis.log.debug("loading sessions");
     Artemis._module.component('artemisSessions', {
         template:
             `<h1>Browse Sessions
@@ -156,32 +156,32 @@ var Artemis;
         };
 
         selectConnection = function (connection) {
-            Artemis.log.info("navigating to connection:" + connection)
+            Artemis.log.debug("navigating to connection:" + connection)
             artemisSession.session = { connectionID: connection };
             $location.path("artemis/artemisConnections");
         };
 
         selectConsumers = function (session) {
-            Artemis.log.info("navigating to consumers:" + session)
+            Artemis.log.debug("navigating to consumers:" + session)
             artemisConsumer.consumer = { sessionID: session };
             $location.path("artemis/artemisConsumers");
         };
 
         selectProducers = function (session) {
-            Artemis.log.info("navigating to producers:" + session)
+            Artemis.log.debug("navigating to producers:" + session)
             artemisProducer.producer = { sessionID: session };
             $location.path("artemis/artemisProducers");
         };
 
         if (artemisConnection.connection) {
-            Artemis.log.info("navigating to connection = " + artemisConnection.connection.connectionID);
+            Artemis.log.debug("navigating to connection = " + artemisConnection.connection.connectionID);
             ctrl.filter.values.field = ctrl.filter.fieldOptions[1].id;
             ctrl.filter.values.operation = ctrl.filter.operationOptions[0].id;
             ctrl.filter.values.value = artemisConnection.connection.connectionID;
         }
 
         if (artemisSession.session) {
-            Artemis.log.info("navigating to session = " + artemisSession.session.session);
+            Artemis.log.debug("navigating to session = " + artemisSession.session.session);
             ctrl.filter.values.field = ctrl.filter.fieldOptions[0].id;
             ctrl.filter.values.operation = ctrl.filter.operationOptions[0].id;
             ctrl.filter.values.value = artemisSession.session.session;
@@ -194,7 +194,7 @@ var Artemis;
         }
 
         ctrl.closeSession = function () {
-           Artemis.log.info("closing session: " + ctrl.sessionToDelete);
+           Artemis.log.debug("closing session: " + ctrl.sessionToDelete);
               if (mbean) {
                   jolokia.request({ type: 'exec',
                      mbean: mbean,
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/status.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/status.js
index 48a71ae..967747e 100644
--- a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/status.js
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/components/status.js
@@ -17,7 +17,7 @@
  /// <reference path="tree.component.ts"/>
 var Artemis;
 (function (Artemis) {
-    Artemis.log.info("loading status");
+    Artemis.log.debug("loading status");
     Artemis._module.component('artemisStatus', {
         template:
                `<h1>Current Status
@@ -62,7 +62,7 @@ var Artemis;
         controller: StatusController
     })
     .name;
-    Artemis.log.info("loaded address " + Artemis.addressModule);
+    Artemis.log.debug("loaded address " + Artemis.addressModule);
 
     function StatusController($scope, workspace, jolokia, localStorage, $interval) {
         var ctrl = this;
diff --git a/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/services/sendMessageService.js b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/services/sendMessageService.js
new file mode 100644
index 0000000..bc4eea6
--- /dev/null
+++ b/artemis-hawtio/artemis-plugin/src/main/webapp/plugin/js/services/sendMessageService.js
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+var Artemis;
+(function (Artemis) {
+
+    Artemis._module.factory('messageCreator',
+        function () {
+            return {
+                createNewMessage: function (scope, location, route, localStorage, artemisMessage, workspace, element, timeout, jolokia) {
+                    return new message(scope, location, route, localStorage, artemisMessage, workspace, element, timeout, jolokia);
+                }
+            }
+        })
+
+
+        function message(scope, location, route, localStorage, artemisMessage, workspace, element, timeout, jolokia) {
+            this.noCredentials = false,
+            this.durable = true,
+            this.message = "",
+            this.headers = [],
+            this.scope = scope;
+            this.element = element;
+            this.timeout = timeout;
+            this.workspace = workspace;
+            this.jolokia = jolokia;
+            this.artemisMessage = artemisMessage;
+            // bind model values to search params...
+            Core.bindModelToSearchParam(scope, location, "tab", "subtab", "compose");
+            Core.bindModelToSearchParam(scope, location, "searchText", "q", "");
+            // only reload the page if certain search parameters change
+            Core.reloadWhenParametersChange(route, scope, location, localStorage);
+            if (location.path().indexOf('artemis') > -1) {
+                this.localStorage = localStorage;
+                scope.$watch('localStorage.artemisUserName', this.checkCredentials);
+                scope.$watch('localStorage.artemisPassword', this.checkCredentials);
+                //prefill if it's a resend
+                if (artemisMessage.message !== null) {
+                    this.message = artemisMessage.message.bodyText;
+                    if (artemisMessage.message.PropertiesText !== null) {
+                        for (var p in artemisMessage.message.StringProperties) {
+                            this.headers.push({name: p, value: artemisMessage.message.StringProperties[p]});
+                        }
+                    }
+                }
+                // always reset at the end
+
+                artemisMessage.message = null;
+            }
+            var LANGUAGE_FORMAT_PREFERENCE = "defaultLanguageFormat";
+            var sourceFormat = workspace.getLocalStorage(LANGUAGE_FORMAT_PREFERENCE) || "javascript";
+
+            scope.codeMirrorOptions = CodeEditor.createEditorSettings({
+                mode: {
+                    name: sourceFormat
+                }
+            });
+
+            scope.$on('hawtioEditor_default_instance', function (event, codeMirror) {
+                scope.codeMirror = codeMirror;
+            });
+
+            checkCredentials = function () {
+                this.noCredentials = (Core.isBlank(localStorage['artemisUserName']) || Core.isBlank(localStorage['artemisPassword']));
+            };
+            this.openPrefs = function (location) {
+                Artemis.log.debug("opening prefs");
+                location.path('/preferences').search({'pref': 'Artemis'});
+            };
+            this.addHeader = function  () {
+                this.headers.push({name: "", value: ""});
+                // lets set the focus to the last header
+                var element = this.element;
+                if (element) {
+                    this.timeout(function () {
+                        var lastHeader = element.find("input.headerName").last();
+                        lastHeader.focus();
+                    }, 100);
+                }
+            };
+            this.removeHeader = function (header) {
+                var index = this.headers.indexOf(header);
+                this.headers.splice(index, 1);
+            };
+            this.defaultHeaderNames = function () {
+                var answer = [];
+
+                function addHeaderSchema(schema) {
+                    angular.forEach(schema.definitions.headers.properties, function (value, name) {
+                        answer.push(name);
+                    });
+                }
+
+                addHeaderSchema(Artemis.jmsHeaderSchema);
+                return answer;
+            };
+            this.operationSuccess = function () {
+                Core.notification("success", "Message sent!");
+                this.headers = [];
+                this.message = "";
+            };
+            this.onError = function (response) {
+               Core.notification("error", "Could not send message: " + response.error);
+            };
+            this.formatMessage = function () {
+                CodeEditor.autoFormatEditor(this.scope.codeMirror);
+            };
+            this.sendMessage = function (durable) {
+                var body = this.message;
+                Artemis.log.debug(body);
+                this.doSendMessage(this.durable, body);
+            };
+            this.doSendMessage = function(durable, body) {
+                var selection = this.workspace.selection;
+                if (selection) {
+                    var mbean = selection.objectName;
+                    if (mbean) {
+                        var headers = null;
+                        if (this.headers.length) {
+                            headers = {};
+                            angular.forEach(this.headers, function (object) {
+                                var key = object.name;
+                                if (key) {
+                                    headers[key] = object.value;
+                                }
+                            });
+                            Artemis.log.debug("About to send headers: " + JSON.stringify(headers));
+                        }
+
+                        var user = this.localStorage["artemisUserName"];
+                        var pwd = this.localStorage["artemisPassword"];
+
+                        if (!headers) {
+                            headers = {};
+                        }
+                        var type = 3;
+                        Artemis.log.debug(headers);
+                        Artemis.log.debug(type);
+                        Artemis.log.debug(body);
+                        Artemis.log.debug(durable);
+                        this.jolokia.execute(mbean, "sendMessage(java.util.Map, int, java.lang.String, boolean, java.lang.String, java.lang.String)", headers, type, body, durable, user, pwd,  Core.onSuccess(this.operationSuccess(), { error: this.onError }));
+                        Core.$apply(this.scope);
+                    }
+                }
+            };
+        }
+})(Artemis || (Artemis = {}));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+