You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2016/12/23 07:55:48 UTC

[1/3] camel git commit: CAMEL-10645: Camel-MongoDB3: component should not store state

Repository: camel
Updated Branches:
  refs/heads/master 5371913c4 -> 7ef99c17d


CAMEL-10645: Camel-MongoDB3: 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/8eeac79f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8eeac79f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8eeac79f

Branch: refs/heads/master
Commit: 8eeac79fa0c1e31b1b8d905651f3349b3b528c06
Parents: 5371913
Author: Andrea Cosentino <an...@gmail.com>
Authored: Fri Dec 23 08:48:32 2016 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Fri Dec 23 08:48:32 2016 +0100

----------------------------------------------------------------------
 .../camel/component/mongodb3/MongoDbComponent.java | 15 ---------------
 .../camel/component/mongodb3/MongoDbEndpoint.java  | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8eeac79f/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbComponent.java b/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbComponent.java
index c54ba71..807a80c 100644
--- a/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbComponent.java
+++ b/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbComponent.java
@@ -37,25 +37,15 @@ public class MongoDbComponent extends UriEndpointComponent {
     public static final Set<MongoDbOperation> WRITE_OPERATIONS = new HashSet<>(Arrays.asList(MongoDbOperation.insert, MongoDbOperation.save, MongoDbOperation.update,
                                                                                              MongoDbOperation.remove));
     private static final Logger LOG = LoggerFactory.getLogger(MongoDbComponent.class);
-    private volatile MongoClient db;
 
     public MongoDbComponent() {
         super(MongoDbEndpoint.class);
     }
 
-    /**
-     * Should access a singleton of type Mongo
-     */
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        // TODO: this only supports one mongodb
-        if (db == null) {
-            db = CamelContextHelper.mandatoryLookup(getCamelContext(), remaining, MongoClient.class);
-            LOG.debug("Resolved the connection with the name {} as {}", remaining, db);
-        }
 
         MongoDbEndpoint endpoint = new MongoDbEndpoint(uri, this);
         endpoint.setConnectionBean(remaining);
-        endpoint.setMongoConnection(db);
         setProperties(endpoint, parameters);
 
         return endpoint;
@@ -63,11 +53,6 @@ public class MongoDbComponent extends UriEndpointComponent {
 
     @Override
     protected void doShutdown() throws Exception {
-        if (db != null) {
-            // properly close the underlying physical connection to MongoDB
-            LOG.debug("Closing the connection {} on {}", db, this);
-            db.close();
-        }
 
         super.doShutdown();
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/8eeac79f/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbEndpoint.java b/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbEndpoint.java
index 8105cf0..51d0cbc 100644
--- a/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbEndpoint.java
+++ b/components/camel-mongodb3/src/main/java/org/apache/camel/component/mongodb3/MongoDbEndpoint.java
@@ -41,6 +41,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.apache.camel.util.ObjectHelper;
 import org.bson.Document;
 import org.bson.conversions.Bson;
@@ -293,6 +294,22 @@ public class MongoDbEndpoint extends DefaultEndpoint {
         message.setBody(dbObj);
         return exchange;
     }
+    
+    @Override
+    protected void doStart() throws Exception {
+        mongoConnection = CamelContextHelper.mandatoryLookup(getCamelContext(), connectionBean, MongoClient.class);
+        LOG.debug("Resolved the connection with the name {} as {}", connectionBean, mongoConnection);
+        super.doStart();
+    }
+    
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (mongoConnection != null) {
+            LOG.debug("Closing connection");
+            mongoConnection.close();
+        }
+    }
 
     // ======= Getters and setters
     // ===============================================


[2/3] camel git commit: Fixed CS

Posted by ac...@apache.org.
Fixed CS


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

Branch: refs/heads/master
Commit: a56afad9cd070b05e0cb42da6ef5a37e13c9957f
Parents: 8eeac79
Author: Andrea Cosentino <an...@gmail.com>
Authored: Fri Dec 23 08:50:26 2016 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Fri Dec 23 08:50:26 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/camel/component/mongodb/MongoDbEndpoint.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a56afad9/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java
index c2f94bd..4ce84c7 100644
--- a/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java
+++ b/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbEndpoint.java
@@ -295,8 +295,8 @@ public class MongoDbEndpoint extends DefaultEndpoint {
     protected void doStop() throws Exception {
         super.doStop();
         if (mongoConnection != null) {
-        	LOG.debug("Closing connection");
-        	mongoConnection.close();
+            LOG.debug("Closing connection");
+            mongoConnection.close();
         }
     }
 


[3/3] camel git commit: CAMEL-10635 - camel-mongodb-gridfs - The component should not store state

Posted by ac...@apache.org.
CAMEL-10635 - camel-mongodb-gridfs - 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/7ef99c17
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7ef99c17
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7ef99c17

Branch: refs/heads/master
Commit: 7ef99c17d082c4e2302f215f2f1374f912b24af8
Parents: a56afad
Author: Andrea Cosentino <an...@gmail.com>
Authored: Fri Dec 23 08:54:54 2016 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Fri Dec 23 08:54:54 2016 +0100

----------------------------------------------------------------------
 .../camel/component/gridfs/GridFsComponent.java  | 19 -------------------
 .../camel/component/gridfs/GridFsEndpoint.java   | 15 ++++++++++++++-
 2 files changed, 14 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7ef99c17/components/camel-mongodb-gridfs/src/main/java/org/apache/camel/component/gridfs/GridFsComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb-gridfs/src/main/java/org/apache/camel/component/gridfs/GridFsComponent.java b/components/camel-mongodb-gridfs/src/main/java/org/apache/camel/component/gridfs/GridFsComponent.java
index 62701a0..5b91313 100644
--- a/components/camel-mongodb-gridfs/src/main/java/org/apache/camel/component/gridfs/GridFsComponent.java
+++ b/components/camel-mongodb-gridfs/src/main/java/org/apache/camel/component/gridfs/GridFsComponent.java
@@ -18,35 +18,20 @@ package org.apache.camel.component.gridfs;
 
 import java.util.Map;
 
-import com.mongodb.Mongo;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.UriEndpointComponent;
-import org.apache.camel.util.CamelContextHelper;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 public class GridFsComponent extends UriEndpointComponent {
 
-    private static final Logger LOG = LoggerFactory.getLogger(GridFsComponent.class);
-
-    private volatile Mongo db;
-
     public GridFsComponent() {
         super(GridFsEndpoint.class);
     }
     
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        if (db == null) {
-            db = CamelContextHelper.mandatoryLookup(getCamelContext(), remaining, Mongo.class);
-            LOG.debug("Resolved the connection with the name {} as {}", remaining, db);
-        }
 
         GridFsEndpoint endpoint = new GridFsEndpoint(uri, this);
-        parameters.put("mongoConnection", db);
         endpoint.setConnectionBean(remaining);
-        endpoint.setMongoConnection(db);
         setProperties(endpoint, parameters);
         
         return endpoint;
@@ -54,10 +39,6 @@ public class GridFsComponent extends UriEndpointComponent {
 
     @Override
     protected void doShutdown() throws Exception {
-        if (db != null) {
-            LOG.debug("Closing the connection {} on {}", db, this);
-            db.close();
-        }
         super.doShutdown();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7ef99c17/components/camel-mongodb-gridfs/src/main/java/org/apache/camel/component/gridfs/GridFsEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-mongodb-gridfs/src/main/java/org/apache/camel/component/gridfs/GridFsEndpoint.java b/components/camel-mongodb-gridfs/src/main/java/org/apache/camel/component/gridfs/GridFsEndpoint.java
index f4d5d65..da5a064 100644
--- a/components/camel-mongodb-gridfs/src/main/java/org/apache/camel/component/gridfs/GridFsEndpoint.java
+++ b/components/camel-mongodb-gridfs/src/main/java/org/apache/camel/component/gridfs/GridFsEndpoint.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.gridfs;
 import com.mongodb.DB;
 import com.mongodb.DBCollection;
 import com.mongodb.Mongo;
+import com.mongodb.MongoClient;
 import com.mongodb.ReadPreference;
 import com.mongodb.WriteConcern;
 import com.mongodb.gridfs.GridFS;
@@ -30,6 +31,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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -129,10 +131,21 @@ public class GridFsEndpoint extends DefaultEndpoint {
                     + ", " + writeConcernRef + ". Aborting initialization.";
             throw new IllegalArgumentException(msg);
         }
-
+        mongoConnection = CamelContextHelper.mandatoryLookup(getCamelContext(), connectionBean, MongoClient.class);
+        LOG.debug("Resolved the connection with the name {} as {}", connectionBean, mongoConnection);
         setWriteReadOptionsOnConnection();
         super.doStart();
     }
+    
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (mongoConnection != null) {
+            LOG.debug("Closing connection");
+            mongoConnection.close();
+        }
+    }
+    
     private void setWriteReadOptionsOnConnection() {
         // Set the WriteConcern
         if (writeConcern != null) {