camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1333772 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/api/management/mbean/ main/java/org/apache/camel/management/mbean/ test/java/org/apache/camel/management/
Date Fri, 04 May 2012 06:57:28 GMT
Author: davsclaus
Date: Fri May  4 06:57:27 2012
New Revision: 1333772

URL: http://svn.apache.org/viewvc?rev=1333772&view=rev
Log:
CAMEL-5245: Expose management name in camel context mbean.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java?rev=1333772&r1=1333771&r2=1333772&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java
Fri May  4 06:57:27 2012
@@ -27,6 +27,9 @@ public interface ManagedCamelContextMBea
     @ManagedAttribute(description = "Camel ID")
     String getCamelId();
 
+    @ManagedAttribute(description = "Camel Management Name")
+    String getManagementName();
+
     @ManagedAttribute(description = "Camel Version")
     String getCamelVersion();
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java?rev=1333772&r1=1333771&r2=1333772&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
Fri May  4 06:57:27 2012
@@ -66,6 +66,10 @@ public class ManagedCamelContext impleme
         return context.getName();
     }
 
+    public String getManagementName() {
+        return context.getManagementName();
+    }
+
     public String getCamelVersion() {
         return context.getVersion();
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java?rev=1333772&r1=1333771&r2=1333772&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextTest.java
Fri May  4 06:57:27 2012
@@ -21,6 +21,7 @@ import java.util.Map;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
@@ -29,15 +30,26 @@ import org.apache.camel.component.mock.M
  */
 public class ManagedCamelContextTest extends ManagementTestSupport {
 
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        // to force a different management name than the camel id
+        context.getManagementNameStrategy().setNamePattern("19-#name#");
+        return context;
+    }
+
     public void testManagedCamelContext() throws Exception {
         MBeanServer mbeanServer = getMBeanServer();
 
-        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=context,name=\"camel-1\"");
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/19-camel-1,type=context,name=\"camel-1\"");
 
         assertTrue("Should be registered", mbeanServer.isRegistered(on));
         String name = (String) mbeanServer.getAttribute(on, "CamelId");
         assertEquals("camel-1", name);
 
+        String managementName = (String) mbeanServer.getAttribute(on, "ManagementName");
+        assertEquals("19-camel-1", managementName);
+
         String uptime = (String) mbeanServer.getAttribute(on, "Uptime");
         assertNotNull(uptime);
 
@@ -85,7 +97,7 @@ public class ManagedCamelContextTest ext
     public void testManagedCamelContextCreateEndpoint() throws Exception {
         MBeanServer mbeanServer = getMBeanServer();
 
-        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=context,name=\"camel-1\"");
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/19-camel-1,type=context,name=\"camel-1\"");
 
         assertNull(context.hasEndpoint("seda:bar"));
 
@@ -95,7 +107,7 @@ public class ManagedCamelContextTest ext
 
         assertNotNull(context.hasEndpoint("seda:bar"));
 
-        ObjectName seda = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"seda://bar\"");
+        ObjectName seda = ObjectName.getInstance("org.apache.camel:context=localhost/19-camel-1,type=endpoints,name=\"seda://bar\"");
         boolean registered = mbeanServer.isRegistered(seda);
         assertTrue("Should be registered " + seda, registered);
 
@@ -110,7 +122,7 @@ public class ManagedCamelContextTest ext
     public void testManagedCamelContextRemoveEndpoint() throws Exception {
         MBeanServer mbeanServer = getMBeanServer();
 
-        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=context,name=\"camel-1\"");
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/19-camel-1,type=context,name=\"camel-1\"");
 
         assertNull(context.hasEndpoint("seda:bar"));
 
@@ -120,7 +132,7 @@ public class ManagedCamelContextTest ext
 
         assertNotNull(context.hasEndpoint("seda:bar"));
 
-        ObjectName seda = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"seda://bar\"");
+        ObjectName seda = ObjectName.getInstance("org.apache.camel:context=localhost/19-camel-1,type=endpoints,name=\"seda://bar\"");
         boolean registered = mbeanServer.isRegistered(seda);
         assertTrue("Should be registered " + seda, registered);
 



Mime
View raw message