camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/3] camel git commit: CAMEL-7999: More components include documentation
Date Sun, 04 Jan 2015 14:22:26 GMT
CAMEL-7999: More components include documentation


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

Branch: refs/heads/master
Commit: d726ae00250641175e14a64f05c16abe2c35123f
Parents: 64b4bab
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Jan 4 15:12:36 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Jan 4 15:12:36 2015 +0100

----------------------------------------------------------------------
 .../camel/component/mqtt/MQTTComponent.java     | 47 +++++++++++++++-
 .../camel/component/mqtt/MQTTConfiguration.java | 56 +++++++++++++++++++-
 .../camel/component/mqtt/MQTTEndpoint.java      | 15 ++++++
 3 files changed, 114 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d726ae00/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTComponent.java
b/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTComponent.java
index 3e3444a..e798662 100644
--- a/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTComponent.java
+++ b/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTComponent.java
@@ -19,20 +19,63 @@ package org.apache.camel.component.mqtt;
 import java.util.Map;
 
 import org.apache.camel.Endpoint;
-import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.impl.UriEndpointComponent;
 
 /**
  * MQTT Component
  */
-public class MQTTComponent extends DefaultComponent {
+public class MQTTComponent extends UriEndpointComponent {
+
+    public MQTTComponent() {
+        super(MQTTEndpoint.class);
+    }
+
+    private String host;
+    private String userName;
+    private String password;
 
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
         MQTTConfiguration configuration = new MQTTConfiguration();
 
+        if (host != null) {
+            configuration.setHost(host);
+        }
+        if (userName != null) {
+            configuration.setUserName(userName);
+        }
+        if (password != null) {
+            configuration.setPassword(password);
+        }
+
         // and then override from parameters
         setProperties(configuration, parameters);
 
         MQTTEndpoint endpoint = new MQTTEndpoint(uri, this, configuration);
+        endpoint.setName(remaining);
         return endpoint;
     }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d726ae00/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTConfiguration.java
b/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTConfiguration.java
index 7c7233a..4526102 100644
--- a/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTConfiguration.java
+++ b/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTConfiguration.java
@@ -16,9 +16,19 @@
  */
 package org.apache.camel.component.mqtt;
 
+import java.net.URI;
+import java.util.concurrent.Executor;
+import javax.net.ssl.SSLContext;
+
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+import org.fusesource.hawtdispatch.DispatchQueue;
+import org.fusesource.hawtdispatch.transport.TcpTransport;
 import org.fusesource.mqtt.client.MQTT;
 import org.fusesource.mqtt.client.QoS;
+import org.fusesource.mqtt.client.Tracer;
 
+@UriParams
 public class MQTTConfiguration extends MQTT {
     public static final String MQTT_SUBSCRIBE_TOPIC = "CamelMQTTSubscribeTopic";
     public static final String MQTT_PUBLISH_TOPIC = "CamelMQTTPublishTopic";
@@ -33,15 +43,57 @@ public class MQTTConfiguration extends MQTT {
     /**
      * These are set on the Endpoint - together with properties inherited from MQTT
      */
+    @UriParam
     private String subscribeTopicName = "";
+    @UriParam(defaultValue = "camel/mqtt/test")
     private String publishTopicName = "camel/mqtt/test";
-    private String qualityOfService = QoS.AT_LEAST_ONCE.name();
-
+    @UriParam(defaultValue = "10")
     private int connectWaitInSeconds = 10;
+    @UriParam(defaultValue = "5")
     private int disconnectWaitInSeconds = 5;
+    @UriParam(defaultValue = "5")
     private int sendWaitInSeconds = 5;
+    @UriParam(defaultValue = "false")
     private boolean byDefaultRetain;
+    @UriParam
     private QoS qos = QoS.AT_LEAST_ONCE;
+    private String qualityOfService = QoS.AT_LEAST_ONCE.name();
+
+    // inherited options from MQTT
+    @UriParam
+    URI host;
+    @UriParam
+    URI localAddress;
+    @UriParam
+    SSLContext sslContext;
+    @UriParam
+    DispatchQueue dispatchQueue;
+    @UriParam
+    Executor blockingExecutor;
+    @UriParam
+    int maxReadRate;
+    @UriParam
+    int maxWriteRate;
+    @UriParam(defaultValue = "" + TcpTransport.IPTOS_THROUGHPUT)
+    int trafficClass = TcpTransport.IPTOS_THROUGHPUT;
+    @UriParam(defaultValue = "" + 1024*64)
+    int receiveBufferSize = 1024*64;
+    @UriParam(defaultValue = "" + 1024*64)
+    int sendBufferSize = 1024*64;
+    @UriParam(defaultValue = "true")
+    boolean useLocalHost = true;
+    @UriParam(defaultValue = "10")
+    long reconnectDelay = 10;
+    @UriParam(defaultValue = "" + 30*1000)
+    long reconnectDelayMax = 30*1000;
+    @UriParam(defaultValue =  "2.0")
+    double reconnectBackOffMultiplier = 2.0f;
+    @UriParam(defaultValue = "-1")
+    long reconnectAttemptsMax = -1;
+    @UriParam(defaultValue = "-1")
+    long connectAttemptsMax = -1;
+    @UriParam
+    Tracer tracer;
 
     public String getQualityOfService() {
         return qualityOfService;

http://git-wip-us.apache.org/repos/asf/camel/blob/d726ae00/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java
b/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java
index da9e668..7e1737b 100644
--- a/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java
+++ b/components/camel-mqtt/src/main/java/org/apache/camel/component/mqtt/MQTTEndpoint.java
@@ -25,6 +25,9 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
 import org.fusesource.hawtbuf.Buffer;
 import org.fusesource.hawtbuf.UTF8Buffer;
 import org.fusesource.hawtdispatch.Task;
@@ -40,10 +43,14 @@ import org.slf4j.LoggerFactory;
 /**
  * MQTT endpoint
  */
+@UriEndpoint(scheme = "mqtt", consumerClass = MQTTConsumer.class, label = "messaging")
 public class MQTTEndpoint extends DefaultEndpoint {
     private static final Logger LOG = LoggerFactory.getLogger(MQTTEndpoint.class);
 
     private CallbackConnection connection;
+    @UriPath
+    private String name;
+    @UriParam
     private final MQTTConfiguration configuration;
     private volatile boolean connected;
     private final List<MQTTConsumer> consumers = new CopyOnWriteArrayList<MQTTConsumer>();
@@ -69,6 +76,14 @@ public class MQTTEndpoint extends DefaultEndpoint {
         return configuration;
     }
 
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
     @Override
     protected void doStart() throws Exception {
         super.doStart();


Mime
View raw message