camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [01/10] camel git commit: Component docs
Date Wed, 06 Jan 2016 16:46:07 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.16.x a9cee89a5 -> b027b7b07
  refs/heads/master 4c597b887 -> e5a094d32


Component docs


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

Branch: refs/heads/master
Commit: eecc47ba28d32d3eff55bb6fc04700c385ac48e0
Parents: 4c597b8
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Jan 6 13:48:37 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Jan 6 13:48:37 2016 +0100

----------------------------------------------------------------------
 .../camel/component/jmx/JMXComponent.java       | 21 ++++----------------
 .../apache/camel/component/jmx/JMXEndpoint.java | 14 ++++++++-----
 .../camel/component/jmx/JMXComponentTest.java   |  6 +++---
 3 files changed, 16 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/eecc47ba/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXComponent.java
b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXComponent.java
index 8822ed9..b5da6cb 100644
--- a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXComponent.java
+++ b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXComponent.java
@@ -16,14 +16,12 @@
  */
 package org.apache.camel.component.jmx;
 
-import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.Map;
-import java.util.Map.Entry;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.UriEndpointComponent;
 import org.apache.camel.util.EndpointHelper;
+import org.apache.camel.util.IntrospectionSupport;
 
 /**
  * Component for connecting JMX Notification events to a camel route.
@@ -38,6 +36,7 @@ public class JMXComponent extends UriEndpointComponent {
     }
 
     @Override
+    @SuppressWarnings("unchecked")
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
         JMXEndpoint endpoint = new JMXEndpoint(uri, this);
         // use the helper class to set all of the properties
@@ -46,20 +45,8 @@ public class JMXComponent extends UriEndpointComponent {
 
         endpoint.setServerURL(remaining);
 
-        // we may have some extra params left over for the object properties hashtable
-        // these properties need to be consumed or the framework will throw an exception
-        // for unused params
-        if (!parameters.isEmpty()) {
-            Hashtable<String, String> objectProperties = new Hashtable<String, String>();
-
-            for (Iterator<Entry<String, Object>> it = parameters.entrySet().iterator();
it.hasNext();) {
-                Entry<String, Object> entry = it.next();
-                if (entry.getKey().startsWith("key.")) {
-                    objectProperties.put(entry.getKey().substring("key.".length()), entry.getValue().toString());
-                    it.remove();
-                }
-            }
-
+        Map objectProperties = IntrospectionSupport.extractProperties(parameters, "key.");
+        if (objectProperties != null && !objectProperties.isEmpty()) {
             endpoint.setObjectProperties(objectProperties);
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/eecc47ba/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
index 20fadc7..04ca715 100644
--- a/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
+++ b/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXEndpoint.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.jmx;
 
 import java.util.Hashtable;
+import java.util.Map;
 import javax.management.MalformedObjectNameException;
 import javax.management.NotificationFilter;
 import javax.management.ObjectName;
@@ -214,7 +215,8 @@ public class JMXEndpoint extends DefaultEndpoint {
     /**
      * URI Property: properties for the object name. These values will be used if the objectName
param is not set
      */
-    private Hashtable<String, String> objectProperties;
+    @UriParam(label = "advanced", prefix = "key.", multiValue = true)
+    private Map<String, String> objectProperties;
 
     /**
      * cached object name that was built from the objectName param or the hashtable
@@ -348,7 +350,7 @@ public class JMXEndpoint extends DefaultEndpoint {
         handback = aHandback;
     }
 
-    public Hashtable<String, String> getObjectProperties() {
+    public Map<String, String> getObjectProperties() {
         return objectProperties;
     }
 
@@ -362,11 +364,11 @@ public class JMXEndpoint extends DefaultEndpoint {
      * If there are extra properties that begin with "key." then the component will
      * create a Hashtable with these values after removing the "key." prefix.
      */
-    public void setObjectProperties(Hashtable<String, String> aObjectProperties) {
+    public void setObjectProperties(Map<String, String> objectProperties) {
         if (getObjectName() != null) {
             throw new IllegalArgumentException("Cannot set both objectName and objectProperties");
         }
-        objectProperties = aObjectProperties;
+        this.objectProperties = objectProperties;
     }
 
     protected ObjectName getJMXObjectName() throws MalformedObjectNameException {
@@ -523,7 +525,9 @@ public class JMXEndpoint extends DefaultEndpoint {
             StringBuilder sb = new StringBuilder(getObjectDomain()).append(':').append("name=").append(getObjectName());
             objectName = new ObjectName(sb.toString());
         } else {
-            objectName = new ObjectName(getObjectDomain(), getObjectProperties());
+            Hashtable<String, String> ht = new Hashtable<String, String>();
+            ht.putAll(getObjectProperties());
+            objectName = new ObjectName(getObjectDomain(), ht);
         }
         return objectName;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/eecc47ba/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
index c37174a..b9d63e4 100644
--- a/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
+++ b/components/camel-jmx/src/test/java/org/apache/camel/component/jmx/JMXComponentTest.java
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.component.jmx;
 
-import java.util.Hashtable;
+import java.util.Map;
 
 import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.impl.DefaultCamelContext;
@@ -41,7 +41,7 @@ public class JMXComponentTest {
         JMXEndpoint ep = context.getEndpoint("jmx:platform?objectDomain=FooDomain&key.propOne=prop1&key.propTwo=prop2",
JMXEndpoint.class);
         assertNotNull(ep);
 
-        Hashtable<String, String> props = ep.getObjectProperties();
+        Map<String, String> props = ep.getObjectProperties();
         assertEquals(2, props.size());
         assertEquals("prop1", props.get("propOne"));
         assertEquals("prop2", props.get("propTwo"));
@@ -56,7 +56,7 @@ public class JMXComponentTest {
 
         assertEquals("theObjectName", ep.getObjectName());
 
-        Hashtable<String, String> props = ep.getObjectProperties();
+        Map<String, String> props = ep.getObjectProperties();
         assertNull(props);
     }
 


Mime
View raw message