You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/08/11 15:23:06 UTC

[2/6] camel git commit: CAMEL-8147: Camel JMX when using custom @ManagedResource should mixin the standard mbean operations/attributes so you get both worlds.

CAMEL-8147: Camel JMX when using custom @ManagedResource should mixin the standard mbean operations/attributes so you get both worlds.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0a6be48e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0a6be48e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0a6be48e

Branch: refs/heads/master
Commit: 0a6be48e46a1aac779e4c40c7257a680986a2065
Parents: c35c0e9
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Aug 11 14:36:06 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 11 15:30:40 2015 +0200

----------------------------------------------------------------------
 .../camel/component/jms/JmsQueueEndpoint.java   | 72 --------------------
 .../camel/component/jms/BrowsableQueueTest.java |  6 +-
 2 files changed, 3 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0a6be48e/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
index d415cb9..389e75f 100644
--- a/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
+++ b/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsQueueEndpoint.java
@@ -22,13 +22,9 @@ import javax.jms.JMSException;
 import javax.jms.Queue;
 
 import org.apache.camel.Exchange;
-import org.apache.camel.Message;
 import org.apache.camel.api.management.ManagedAttribute;
-import org.apache.camel.api.management.ManagedOperation;
 import org.apache.camel.api.management.ManagedResource;
 import org.apache.camel.spi.BrowsableEndpoint;
-import org.apache.camel.util.EndpointHelper;
-import org.apache.camel.util.MessageHelper;
 import org.springframework.jms.core.JmsOperations;
 
 /**
@@ -103,74 +99,6 @@ public class JmsQueueEndpoint extends JmsEndpoint implements BrowsableEndpoint {
         return queueBrowseStrategy.browse(template, queue, this);
     }
 
-    @ManagedOperation(description = "Current number of Exchanges in Queue")
-    public long queueSize() {
-        return getExchanges().size();
-    }
-
-    @ManagedOperation(description = "Get Exchange from queue by index")
-    public String browseExchange(Integer index) {
-        List<Exchange> exchanges = getExchanges();
-        if (index >= exchanges.size()) {
-            return null;
-        }
-        Exchange exchange = exchanges.get(index);
-        if (exchange == null) {
-            return null;
-        }
-        // must use java type with JMX such as java.lang.String
-        return exchange.toString();
-    }
-
-    @ManagedOperation(description = "Get message body from queue by index")
-    public String browseMessageBody(Integer index) {
-        List<Exchange> exchanges = getExchanges();
-        if (index >= exchanges.size()) {
-            return null;
-        }
-        Exchange exchange = exchanges.get(index);
-        if (exchange == null) {
-            return null;
-        }
-
-        // must use java type with JMX such as java.lang.String
-        String body;
-        if (exchange.hasOut()) {
-            body = exchange.getOut().getBody(String.class);
-        } else {
-            body = exchange.getIn().getBody(String.class);
-        }
-
-        return body;
-    }
-
-    @ManagedOperation(description = "Get message as XML from queue by index")
-    public String browseMessageAsXml(Integer index, Boolean includeBody) {
-        List<Exchange> exchanges = getExchanges();
-        if (index >= exchanges.size()) {
-            return null;
-        }
-        Exchange exchange = exchanges.get(index);
-        if (exchange == null) {
-            return null;
-        }
-
-        Message msg = exchange.hasOut() ? exchange.getOut() : exchange.getIn();
-        String xml = MessageHelper.dumpAsXml(msg, includeBody);
-
-        return xml;
-    }
-
-    @ManagedOperation(description = "Gets all the messages as XML from the queue")
-    public String browseAllMessagesAsXml(Boolean includeBody) {
-        return browseRangeMessagesAsXml(0, Integer.MAX_VALUE, includeBody);
-    }
-
-    @ManagedOperation(description = "Gets the range of messages as XML from the queue")
-    public String browseRangeMessagesAsXml(Integer fromIndex, Integer toIndex, Boolean includeBody) {
-        return EndpointHelper.browseRangeMessagesAsXml(this, fromIndex, toIndex, includeBody);
-    }
-
     protected QueueBrowseStrategy createQueueBrowseStrategy() {
         return new DefaultQueueBrowseStrategy();
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/0a6be48e/components/camel-jms/src/test/java/org/apache/camel/component/jms/BrowsableQueueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/BrowsableQueueTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/BrowsableQueueTest.java
index f0080c8..b30314f 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/BrowsableQueueTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/BrowsableQueueTest.java
@@ -52,7 +52,7 @@ public class BrowsableQueueTest extends CamelTestSupport {
         assertEquals(6, endpoint.getMaximumBrowseSize());
         List<Exchange> list = endpoint.getExchanges();
         LOG.debug("Received: " + list);
-        assertEquals("Size of list", 6, endpoint.queueSize());
+        assertEquals("Size of list", 6, endpoint.getExchanges().size());
 
         int index = -1;
         for (Exchange exchange : list) {
@@ -77,7 +77,7 @@ public class BrowsableQueueTest extends CamelTestSupport {
         assertEquals(10, endpoint.getMaximumBrowseSize());
         List<Exchange> list = endpoint.getExchanges();
         LOG.debug("Received: " + list);
-        assertEquals("Size of list", 8, endpoint.queueSize());
+        assertEquals("Size of list", 8, endpoint.getExchanges().size());
 
         int index = -1;
         for (Exchange exchange : list) {
@@ -102,7 +102,7 @@ public class BrowsableQueueTest extends CamelTestSupport {
         assertEquals(-1, endpoint.getMaximumBrowseSize());
         List<Exchange> list = endpoint.getExchanges();
         LOG.debug("Received: " + list);
-        assertEquals("Size of list", 8, endpoint.queueSize());
+        assertEquals("Size of list", 8, endpoint.getExchanges().size());
 
         int index = -1;
         for (Exchange exchange : list) {