camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/4] CAMEL-6938: Do not include hostname in JMX MBean names by default. Added option to turn it back on in case some people really need the old behavior.
Date Wed, 06 Nov 2013 09:40:26 GMT
Updated Branches:
  refs/heads/master 71758b5b1 -> 0e8aa70ab


http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringJmxRecipientListTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringJmxRecipientListTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringJmxRecipientListTest.java
index 16ab1b4..84ec19a 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringJmxRecipientListTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringJmxRecipientListTest.java
@@ -54,21 +54,21 @@ public class SpringJmxRecipientListTest extends SpringTestSupport {
         MBeanServer mbeanServer = getMBeanServer();
 
         // this endpoint is part of the route and should be registered
-        ObjectName name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"direct://a\"");
+        ObjectName name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"direct://a\"");
         assertTrue("Should be registered", mbeanServer.isRegistered(name));
 
         // endpoints added after routes has been started is by default not registered
-        name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"mock://x\"");
+        name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://x\"");
         assertFalse("Should not be registered", mbeanServer.isRegistered(name));
 
-        name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"mock://y\"");
+        name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://y\"");
         assertFalse("Should not be registered", mbeanServer.isRegistered(name));
 
-        name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"mock://z\"");
+        name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"mock://z\"");
         assertFalse("Should not be registered", mbeanServer.isRegistered(name));
 
         // however components is always registered
-        name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=components,name=\"mock\"");
+        name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=components,name=\"mock\"");
         assertTrue("Should be registered", mbeanServer.isRegistered(name));
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedCustomProcessorTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedCustomProcessorTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedCustomProcessorTest.java
index a436adb..b2c50a9 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedCustomProcessorTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedCustomProcessorTest.java
@@ -44,7 +44,7 @@ public class SpringManagedCustomProcessorTest extends SpringTestSupport
{
 
     public void testManageCustomProcessor() throws Exception {
         MBeanServer mbeanServer = getMBeanServer();
-        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=processors,name=\"custom\"");
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=processors,name=\"custom\"");
 
         getMockEndpoint("mock:result").expectedMessageCount(1);
         getMockEndpoint("mock:result").expectedHeaderReceived("foo", "hey");

http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedSedaEndpointTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedSedaEndpointTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedSedaEndpointTest.java
index c02c4ae..017c3fc 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedSedaEndpointTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/management/SpringManagedSedaEndpointTest.java
@@ -47,7 +47,7 @@ public class SpringManagedSedaEndpointTest extends SpringTestSupport {
 
         MBeanServer mbeanServer = getMBeanServer();
 
-        ObjectName name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"seda://start\"");
+        ObjectName name = ObjectName.getInstance("org.apache.camel:context=camel-1,type=endpoints,name=\"seda://start\"");
         String uri = (String) mbeanServer.getAttribute(name, "EndpointUri");
         assertEquals("seda://start", uri);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/DualSpringManagedThreadsThreadPoolTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/DualSpringManagedThreadsThreadPoolTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/DualSpringManagedThreadsThreadPoolTest.java
index 53ec700..17c2290 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/DualSpringManagedThreadsThreadPoolTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/DualSpringManagedThreadsThreadPoolTest.java
@@ -33,7 +33,7 @@ public class DualSpringManagedThreadsThreadPoolTest extends SpringTestSupport
{
     public void testDualManagedThreadPool() throws Exception {
         MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
 
-        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=threadpools,name=\"myPool\"");
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=threadpools,name=\"myPool\"");
 
         Integer corePoolSize = (Integer) mbeanServer.getAttribute(on, "CorePoolSize");
         assertEquals(2, corePoolSize.intValue());
@@ -57,7 +57,7 @@ public class DualSpringManagedThreadsThreadPoolTest extends SpringTestSupport
{
         String routeId = (String) mbeanServer.getAttribute(on, "RouteId");
         assertEquals(null, routeId);
 
-        on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=threadpools,name=\"myOtherPool\"");
+        on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=threadpools,name=\"myOtherPool\"");
 
         corePoolSize = (Integer) mbeanServer.getAttribute(on, "CorePoolSize");
         assertEquals(7, corePoolSize.intValue());

http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringManagedThreadsThreadPoolTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringManagedThreadsThreadPoolTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringManagedThreadsThreadPoolTest.java
index bd3960c..ac95d71 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringManagedThreadsThreadPoolTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringManagedThreadsThreadPoolTest.java
@@ -33,7 +33,7 @@ public class SpringManagedThreadsThreadPoolTest extends SpringTestSupport
{
     public void testManagedThreadPool() throws Exception {
         MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
 
-        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=threadpools,name=\"myPool\"");
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=threadpools,name=\"myPool\"");
 
         Integer corePoolSize = (Integer) mbeanServer.getAttribute(on, "CorePoolSize");
         assertEquals(2, corePoolSize.intValue());

http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringJmxDumpRouteAsXmlIncludeHostNameTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringJmxDumpRouteAsXmlIncludeHostNameTest.xml
b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringJmxDumpRouteAsXmlIncludeHostNameTest.xml
new file mode 100644
index 0000000..fc62528
--- /dev/null
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/SpringJmxDumpRouteAsXmlIncludeHostNameTest.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="naming" class="org.apache.camel.management.DefaultManagementNamingStrategy">
+        <property name="hostName" value="localhost"/>
+        <property name="domainName" value="org.apache.camel"/>
+    </bean>
+
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+        <!-- enable JMX -->
+        <jmxAgent id="agent" disabled="false" includeHostName="true"/>
+
+        <route id="myRoute">
+            <from uri="direct:start"/>
+            <log message="Got ${body}"/>
+            <to uri="mock:result"/>
+        </route>
+
+        <route id="myOtherRoute">
+            <from uri="seda:bar"/>
+            <filter>
+                <header>bar</header>
+                <to uri="mock:bar"/>
+            </filter>
+        </route>
+
+    </camelContext>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedNamePatternFixedIncludeHostNameTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedNamePatternFixedIncludeHostNameTest.java
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedNamePatternFixedIncludeHostNameTest.java
new file mode 100644
index 0000000..beb987d
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedNamePatternFixedIncludeHostNameTest.java
@@ -0,0 +1,57 @@
+/**
+ * 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.camel.test.blueprint.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.test.blueprint.CamelBlueprintTestSupport;
+import org.junit.Test;
+
+public class ManagedNamePatternFixedIncludeHostNameTest extends CamelBlueprintTestSupport
{
+
+    @Override
+    protected boolean useJmx() {
+        return true;
+    }
+
+    @Override
+    protected String getBlueprintDescriptor() {
+        return "org/apache/camel/test/blueprint/management/managedNamePatternFixedIncludeHostNameTest.xml";
+    }
+
+    @Override
+    protected String getBundleVersion() {
+        return "1.2.3";
+    }
+
+    @Test
+    public void testManagedNamePattern() throws Exception {
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+        template.sendBody("direct:start", "World");
+        assertMockEndpointsSatisfied();
+
+        MBeanServer mbeanServer = context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+        assertEquals("cool-1.2.3", context.getManagementName());
+
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/" + context.getManagementName()
+                + ",type=context,name=\"" + context.getName() + "\"");
+        assertTrue("Should be registered", mbeanServer.isRegistered(on));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedNamePatternFixedTest.java
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedNamePatternFixedTest.java
b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedNamePatternFixedTest.java
index 1a10189..1734b63 100644
--- a/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedNamePatternFixedTest.java
+++ b/components/camel-test-blueprint/src/test/java/org/apache/camel/test/blueprint/management/ManagedNamePatternFixedTest.java
@@ -49,7 +49,7 @@ public class ManagedNamePatternFixedTest extends CamelBlueprintTestSupport
{
 
         assertEquals("cool-1.2.3", context.getManagementName());
 
-        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/" + context.getManagementName()
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + context.getManagementName()
                 + ",type=context,name=\"" + context.getName() + "\"");
         assertTrue("Should be registered", mbeanServer.isRegistered(on));
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedNamePatternFixedIncludeHostNameTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedNamePatternFixedIncludeHostNameTest.xml
b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedNamePatternFixedIncludeHostNameTest.xml
new file mode 100644
index 0000000..7f64fbd
--- /dev/null
+++ b/components/camel-test-blueprint/src/test/resources/org/apache/camel/test/blueprint/management/managedNamePatternFixedIncludeHostNameTest.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xsi:schemaLocation="
+             http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+  <bean id="naming" class="org.apache.camel.management.DefaultManagementNamingStrategy">
+    <property name="hostName" value="localhost"/>
+    <property name="domainName" value="org.apache.camel"/>
+  </bean>
+
+  <!-- START SNIPPET: example -->
+  <camelContext id="cool" managementNamePattern="#name#-#version#" xmlns="http://camel.apache.org/schema/blueprint">
+    <jmxAgent id="agent" includeHostName="true"/>
+
+    <route>
+      <from uri="direct:start"/>
+      <to uri="mock:result"/>
+    </route>
+  </camelContext>
+
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintManagedNamePatternFixedTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintManagedNamePatternFixedTest.java
b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintManagedNamePatternFixedTest.java
index 3b41a9e..a4b914f 100644
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintManagedNamePatternFixedTest.java
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprintManagedNamePatternFixedTest.java
@@ -53,7 +53,7 @@ public class CamelBlueprintManagedNamePatternFixedTest extends OSGiBlueprintTest
 
         assertEquals("cool", ctx.getManagementName());
 
-        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/" + ctx.getManagementName()
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + ctx.getManagementName()
                 + ",type=context,name=\"" + ctx.getName() + "\"");
         assertTrue("Should be registered", mbeanServer.isRegistered(on));
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/0e8aa70a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/management/OSGiIntegrationManagedCamelContextTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/management/OSGiIntegrationManagedCamelContextTest.java
b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/management/OSGiIntegrationManagedCamelContextTest.java
index 5ae4304..04c3227 100644
--- a/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/management/OSGiIntegrationManagedCamelContextTest.java
+++ b/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/core/management/OSGiIntegrationManagedCamelContextTest.java
@@ -60,7 +60,7 @@ public class OSGiIntegrationManagedCamelContextTest extends OSGiIntegrationTestS
         assertEquals("There should have 2 camelcontext registed", 2, set.size());
         
         String camelContextName = context.getName();
-        ObjectName on = ObjectName.getInstance("org.apache.camel:context=localhost/" + camelContextName
+ ",type=context,name=\"" + camelContextName + "\"");
+        ObjectName on = ObjectName.getInstance("org.apache.camel:context=" + camelContextName
+ ",type=context,name=\"" + camelContextName + "\"");
 
         assertTrue("Should be registered", mbeanServer.isRegistered(on));
         String name = (String) mbeanServer.getAttribute(on, "CamelId");


Mime
View raw message