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/de71c172 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/de71c172 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/de71c172 Branch: refs/heads/master Commit: de71c172523e8b100aa33d139873641e3f6b7271 Parents: 0a6be48 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Aug 11 14:40:03 2015 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Aug 11 15:30:41 2015 +0200 ---------------------------------------------------------------------- .../jms/JmsEndpointConfigurationTest.java | 2 +- .../twitter/TwitterEndpointPolling.java | 29 +------------- .../component/zookeeper/ZooKeeperEndpoint.java | 41 -------------------- .../zookeeper/ZooKeeperManagedEndpointTest.java | 19 ++++----- 4 files changed, 9 insertions(+), 82 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/de71c172/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java ---------------------------------------------------------------------- diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java index e4d0d7b..b504e62 100644 --- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java +++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsEndpointConfigurationTest.java @@ -310,7 +310,7 @@ public class JmsEndpointConfigurationTest extends CamelTestSupport { assertEquals(1000L, endpoint.getRequestTimeoutCheckerInterval()); assertEquals(0, endpoint.getRunningMessageListeners()); assertNull(endpoint.getSelector()); - assertEquals(ServiceStatus.Started.toString(), endpoint.getStatus()); + assertEquals(ServiceStatus.Started, endpoint.getStatus()); assertEquals(-1, endpoint.getTimeToLive()); assertNull(endpoint.getTransactionName()); assertEquals(-1, endpoint.getTransactionTimeout()); http://git-wip-us.apache.org/repos/asf/camel/blob/de71c172/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java ---------------------------------------------------------------------- diff --git a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java index e1e8309..2d42b93 100644 --- a/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java +++ b/components/camel-twitter/src/main/java/org/apache/camel/component/twitter/TwitterEndpointPolling.java @@ -19,7 +19,6 @@ package org.apache.camel.component.twitter; import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; -import org.apache.camel.ServiceStatus; import org.apache.camel.api.management.ManagedAttribute; import org.apache.camel.api.management.ManagedResource; import org.apache.camel.component.twitter.consumer.Twitter4JConsumer; @@ -59,7 +58,7 @@ public class TwitterEndpointPolling extends DefaultPollingEndpoint implements Tw return Twitter4JFactory.getProducer(this, getEndpointUri()); } - @ManagedAttribute + @Override public boolean isSingleton() { return true; } @@ -72,32 +71,6 @@ public class TwitterEndpointPolling extends DefaultPollingEndpoint implements Tw this.properties = properties; } - @ManagedAttribute(description = "Camel ID") - public String getCamelId() { - return getCamelContext().getName(); - } - - @ManagedAttribute(description = "Camel ManagementName") - public String getCamelManagementName() { - return getCamelContext().getManagementName(); - } - - @ManagedAttribute(description = "Endpoint Uri", mask = true) - @Override - public String getEndpointUri() { - return super.getEndpointUri(); - } - - @ManagedAttribute(description = "Service State") - public String getState() { - ServiceStatus status = this.getStatus(); - // if no status exists then its stopped - if (status == null) { - status = ServiceStatus.Stopped; - } - return status.name(); - } - @ManagedAttribute public String getKeywords() { return getProperties().getKeywords(); http://git-wip-us.apache.org/repos/asf/camel/blob/de71c172/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperEndpoint.java b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperEndpoint.java index 64272ca..0cc2036 100644 --- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperEndpoint.java +++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperEndpoint.java @@ -21,7 +21,6 @@ import java.util.List; import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; -import org.apache.camel.ServiceStatus; import org.apache.camel.api.management.ManagedAttribute; import org.apache.camel.api.management.ManagedOperation; import org.apache.camel.api.management.ManagedResource; @@ -71,33 +70,6 @@ public class ZooKeeperEndpoint extends DefaultEndpoint { return connectionManager; } - @ManagedAttribute(description = "Camel ID") - public String getCamelId() { - return getCamelContext().getName(); - } - - @ManagedAttribute(description = "Camel ManagementName") - public String getCamelManagementName() { - return getCamelContext().getManagementName(); - } - - @ManagedAttribute(description = "Endpoint Uri", mask = true) - @Override - public String getEndpointUri() { - return super.getEndpointUri(); - } - - @ManagedAttribute(description = "Service State") - public String getState() { - ServiceStatus status = this.getStatus(); - // if no status exists then its stopped - if (status == null) { - status = ServiceStatus.Stopped; - } - return status.name(); - } - - @ManagedAttribute public void setPath(String path) { getConfiguration().setPath(path); } @@ -112,7 +84,6 @@ public class ZooKeeperEndpoint extends DefaultEndpoint { return getConfiguration().getTimeout(); } - @ManagedAttribute public void setTimeout(int timeout) { getConfiguration().setTimeout(timeout); } @@ -122,7 +93,6 @@ public class ZooKeeperEndpoint extends DefaultEndpoint { return getConfiguration().isRepeat(); } - @ManagedAttribute public void setRepeat(boolean shouldRepeat) { getConfiguration().setRepeat(shouldRepeat); } @@ -132,7 +102,6 @@ public class ZooKeeperEndpoint extends DefaultEndpoint { return getConfiguration().getServers(); } - @ManagedAttribute public void setServers(List<String> servers) { getConfiguration().setServers(servers); } @@ -142,7 +111,6 @@ public class ZooKeeperEndpoint extends DefaultEndpoint { return getConfiguration().isListChildren(); } - @ManagedAttribute public void setListChildren(boolean listChildren) { getConfiguration().setListChildren(listChildren); } @@ -152,7 +120,6 @@ public class ZooKeeperEndpoint extends DefaultEndpoint { return getConfiguration().isCreate(); } - @ManagedAttribute public void setCreate(boolean shouldCreate) { getConfiguration().setCreate(shouldCreate); } @@ -162,7 +129,6 @@ public class ZooKeeperEndpoint extends DefaultEndpoint { return getConfiguration().getBackoff(); } - @ManagedAttribute public void setBackoff(long backoff) { getConfiguration().setBackoff(backoff); } @@ -171,7 +137,6 @@ public class ZooKeeperEndpoint extends DefaultEndpoint { * @deprecated The usage of this property has no effect at all. */ @Deprecated - @ManagedAttribute public boolean getAwaitExistence() { return getConfiguration().shouldAwaitExistence(); } @@ -180,7 +145,6 @@ public class ZooKeeperEndpoint extends DefaultEndpoint { * @deprecated The usage of this property has no effect at all. */ @Deprecated - @ManagedAttribute public void setAwaitExistence(boolean awaitExistence) { getConfiguration().setAwaitExistence(awaitExistence); } @@ -195,16 +159,11 @@ public class ZooKeeperEndpoint extends DefaultEndpoint { getConfiguration().getServers().clear(); } - public Object getManagedObject(ZooKeeperEndpoint arg0) { - return this; - } - @ManagedAttribute public boolean isSendEmptyMessageOnDelete() { return getConfiguration().isSendEmptyMessageOnDelete(); } - @ManagedAttribute public void setSendEmptyMessageOnDelete(boolean sendEmptyMessageOnDelete) { getConfiguration().setSendEmptyMessageOnDelete(sendEmptyMessageOnDelete); } http://git-wip-us.apache.org/repos/asf/camel/blob/de71c172/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperManagedEndpointTest.java ---------------------------------------------------------------------- diff --git a/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperManagedEndpointTest.java b/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperManagedEndpointTest.java index ae67866..c8c9e5b 100644 --- a/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperManagedEndpointTest.java +++ b/components/camel-zookeeper/src/test/java/org/apache/camel/component/zookeeper/ZooKeeperManagedEndpointTest.java @@ -64,13 +64,12 @@ public class ZooKeeperManagedEndpointTest extends CamelTestSupport { assertEquals("Could not find zookeper endpoint: " + s, 1, s.size()); ObjectName zepName = new ArrayList<ObjectName>(s).get(0); - verifyManagedAttribute(zepName, "Path", "/someotherpath"); - verifyManagedAttribute(zepName, "Create", true); - verifyManagedAttribute(zepName, "Repeat", true); - verifyManagedAttribute(zepName, "ListChildren", true); - verifyManagedAttribute(zepName, "AwaitExistence", true); - verifyManagedAttribute(zepName, "Timeout", 12345); - verifyManagedAttribute(zepName, "Backoff", 12345L); + verifyManagedAttribute(zepName, "Path", "/node"); + verifyManagedAttribute(zepName, "Create", false); + verifyManagedAttribute(zepName, "Repeat", false); + verifyManagedAttribute(zepName, "ListChildren", false); + verifyManagedAttribute(zepName, "Timeout", 1000); + verifyManagedAttribute(zepName, "Backoff", 2000L); getMBeanServer().invoke(zepName, "clearServers", null, JmxUtils.getMethodSignature(ZooKeeperEndpoint.class.getMethod("clearServers", null))); getMBeanServer().invoke(zepName, "addServer", new Object[]{"someserver:12345"}, @@ -78,29 +77,25 @@ public class ZooKeeperManagedEndpointTest extends CamelTestSupport { } private void verifyManagedAttribute(ObjectName zepName, String attributeName, String attributeValue) throws Exception { - getMBeanServer().setAttribute(zepName, new Attribute(attributeName, attributeValue)); assertEquals(attributeValue, getMBeanServer().getAttribute(zepName, attributeName)); } private void verifyManagedAttribute(ObjectName zepName, String attributeName, Integer attributeValue) throws Exception { - getMBeanServer().setAttribute(zepName, new Attribute(attributeName, attributeValue)); assertEquals(attributeValue, getMBeanServer().getAttribute(zepName, attributeName)); } private void verifyManagedAttribute(ObjectName zepName, String attributeName, Boolean attributeValue) throws Exception { - getMBeanServer().setAttribute(zepName, new Attribute(attributeName, attributeValue)); assertEquals(attributeValue, getMBeanServer().getAttribute(zepName, attributeName)); } private void verifyManagedAttribute(ObjectName zepName, String attributeName, Long attributeValue) throws Exception { - getMBeanServer().setAttribute(zepName, new Attribute(attributeName, attributeValue)); assertEquals(attributeValue, getMBeanServer().getAttribute(zepName, attributeName)); } protected RouteBuilder createRouteBuilder() { return new RouteBuilder() { public void configure() { - from("zookeeper://localhost:" + ZooKeeperTestSupport.getServerPort() + "/node").to("mock:test"); + from("zookeeper://localhost:" + ZooKeeperTestSupport.getServerPort() + "/node?timeout=1000&backoff=2000").to("mock:test"); } }; }