camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [1/2] camel git commit: CAMEL-10688: Camel-influxdb - The component should not store state
Date Tue, 10 Jan 2017 13:52:58 GMT
Repository: camel
Updated Branches:
  refs/heads/master 6593cb72e -> 5508b51a0


CAMEL-10688: Camel-influxdb - The component should not store state


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

Branch: refs/heads/master
Commit: 4ac1b2355738cc9cd52fcae7c9f075f03ad04296
Parents: 6593cb7
Author: Andrea Cosentino <ancosen@gmail.com>
Authored: Tue Jan 10 14:44:14 2017 +0100
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Tue Jan 10 14:44:14 2017 +0100

----------------------------------------------------------------------
 .../component/influxdb/InfluxDbComponent.java   |  7 ++---
 .../component/influxdb/InfluxDbEndpoint.java    | 29 ++++++++++++--------
 2 files changed, 20 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4ac1b235/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbComponent.java
b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbComponent.java
index 9101a3f..fc950d9 100644
--- a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbComponent.java
+++ b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbComponent.java
@@ -20,8 +20,6 @@ import java.util.Map;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.UriEndpointComponent;
-import org.apache.camel.util.CamelContextHelper;
-import org.influxdb.InfluxDB;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,7 +33,8 @@ public class InfluxDbComponent extends UriEndpointComponent {
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
-        InfluxDB influxDbConnection = CamelContextHelper.mandatoryLookup(getCamelContext(),
remaining, InfluxDB.class);
-        return new InfluxDbEndpoint(uri, this, influxDbConnection);
+        InfluxDbEndpoint endpoint = new InfluxDbEndpoint(uri, this);
+        endpoint.setConnectionBean(remaining);
+        return endpoint;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/4ac1b235/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
index a1405b1..ee30ad3 100644
--- a/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
+++ b/components/camel-influxdb/src/main/java/org/apache/camel/component/influxdb/InfluxDbEndpoint.java
@@ -24,6 +24,7 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.CamelContextHelper;
 import org.influxdb.InfluxDB;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,18 +48,9 @@ public class InfluxDbEndpoint extends DefaultEndpoint {
     private String retentionPolicy = "default";
     @UriParam(defaultValue = "false")
     private boolean batch;
-
-    public InfluxDbEndpoint(String uri, InfluxDbComponent influxDbComponent, InfluxDB dbConn)
{
-        super(uri, influxDbComponent);
-
-        if (dbConn == null) {
-            throw new IllegalArgumentException("dbConn is null");
-        }
-
-        this.influxDB = dbConn;
-
-        LOG.debug("Preparing influxdb enpoint with uri {}", uri);
-        LOG.debug("Creating influx db producer connectionBean:{}, databaseName:{}, retentionPolicy:{}",
connectionBean, databaseName, retentionPolicy);
+    
+    public InfluxDbEndpoint(String uri, InfluxDbComponent component) {
+        super(uri, component);
     }
 
     @Override
@@ -70,6 +62,19 @@ public class InfluxDbEndpoint extends DefaultEndpoint {
     public Consumer createConsumer(Processor processor) throws Exception {
         throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
     }
+    
+    @Override
+    protected void doStart() throws Exception {
+    	influxDB = CamelContextHelper.mandatoryLookup(getCamelContext(), connectionBean, InfluxDB.class);
+    	LOG.debug("Resolved the connection with the name {} as {}", connectionBean, influxDB);
+        super.doStart();
+        
+    }
+    
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+    }
 
     @Override
     public boolean isSingleton() {


Mime
View raw message