camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1292137 - in /camel/trunk/components/camel-mongodb: ./ src/main/java/org/apache/camel/component/mongodb/ src/main/java/org/apache/camel/component/mongodb/converters/
Date Wed, 22 Feb 2012 06:37:12 GMT
Author: davsclaus
Date: Wed Feb 22 06:37:11 2012
New Revision: 1292137

URL: http://svn.apache.org/viewvc?rev=1292137&view=rev
Log:
CAMEL-4878: Applied mongodb adjustment patch. Thanks to Raul for the patch.

Modified:
    camel/trunk/components/camel-mongodb/pom.xml
    camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java
    camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java
    camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java

Modified: camel/trunk/components/camel-mongodb/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mongodb/pom.xml?rev=1292137&r1=1292136&r2=1292137&view=diff
==============================================================================
--- camel/trunk/components/camel-mongodb/pom.xml (original)
+++ camel/trunk/components/camel-mongodb/pom.xml Wed Feb 22 06:37:11 2012
@@ -46,6 +46,12 @@
       <artifactId>camel-core</artifactId>
     </dependency>
 
+	<!-- JSON is vital to MongoDB, so we absolutely require camel-jackson -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jackson</artifactId>
+    </dependency>
+
     <!-- MongoDB driver dependency -->
     <dependency>
       <groupId>org.mongodb</groupId>
@@ -53,13 +59,6 @@
       <version>${mongo-java-driver-version}</version>
     </dependency>
 
-    <dependency>
-      <groupId>org.codehaus.jackson</groupId>
-      <artifactId>jackson-mapper-asl</artifactId>
-      <version>${jackson-version}</version>
-      <optional>true</optional>
-    </dependency>
-
     <!-- testing -->
     <dependency>
       <groupId>org.apache.camel</groupId>

Modified: camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java?rev=1292137&r1=1292136&r2=1292137&view=diff
==============================================================================
--- camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java
(original)
+++ camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbProducer.java
Wed Feb 22 06:37:11 2012
@@ -61,18 +61,14 @@ public class MongoDbProducer extends Def
                     operation = MongoDbOperation.valueOf(exchange.getIn().getHeader(MongoDbConstants.OPERATION_HEADER,
String.class));
                 }
             } catch (Exception e) {
-                LOG.error("Operation not supported: {}", header);
-                exchange.setException(new CamelMongoDbException("Operation specified on header
is not supported. Value: " + header, e));
-                return;
+                throw new CamelMongoDbException("Operation specified on header is not supported.
Value: " + header, e);
             }
         }
         
         try {
             invokeOperation(operation, exchange);
         } catch (Exception e) {
-            CamelMongoDbException partEx = MongoDbComponent.wrapInCamelMongoDbException(e);
-            LOG.error("Breaking MongoDB operation due to exception", partEx);
-            exchange.setException(partEx);
+            throw MongoDbComponent.wrapInCamelMongoDbException(e);
         }
         
     }
@@ -126,9 +122,7 @@ public class MongoDbProducer extends Def
             break;
 
         default:
-            LOG.error("Unexpected operation found: {}", operation);
-            exchange.setException(new CamelMongoDbException("Operation not supported. Value:
" + operation));
-            break;
+            throw new CamelMongoDbException("Operation not supported. Value: " + operation);
         }
     }
 

Modified: camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java?rev=1292137&r1=1292136&r2=1292137&view=diff
==============================================================================
--- camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java
(original)
+++ camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/MongoDbTailingProcess.java
Wed Feb 22 06:37:11 2012
@@ -150,10 +150,7 @@ public class MongoDbTailingProcess imple
                     }
                     consumer.getProcessor().process(exchange);
                 } catch (Exception e) {
-                    LOG.warn("Exception ocurred while processing exchange with ID " + exchange.getExchangeId(),
e);
-                    if (exchange.getException() != e) {
-                        exchange.setException(e);
-                    }
+                    // do nothing
                 }
                 tailTracking.setLastVal(dbObj);
             }

Modified: camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java?rev=1292137&r1=1292136&r2=1292137&view=diff
==============================================================================
--- camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java
(original)
+++ camel/trunk/components/camel-mongodb/src/main/java/org/apache/camel/component/mongodb/converters/MongoDbBasicConverters.java
Wed Feb 22 06:37:11 2012
@@ -27,25 +27,14 @@ import org.codehaus.jackson.map.ObjectMa
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@SuppressWarnings({"unchecked", "rawtypes"})
+@SuppressWarnings({"rawtypes"})
 @Converter
 public final class MongoDbBasicConverters {
     
     private static final transient Logger LOG = LoggerFactory.getLogger(MongoDbBasicConverters.class);
 
     // Jackson's ObjectMapper is thread-safe, so no need to create a pool nor synchronize
access to it
-    private static ObjectMapper objectMapper;
-    
-    // will attempt to load the Jackson ObjectMapper class using the class loader of MongoDbBasicConverters
-    // in an OSGi environment, if Jackson is present it would have already been wired since
Jackson is an optional dependency (Import-Package)
-    static {
-        try {
-            Class<ObjectMapper> objectMapperC = (Class<ObjectMapper>) MongoDbBasicConverters.class.getClassLoader().loadClass("org.codehaus.jackson.map.ObjectMapper");
-            MongoDbBasicConverters.objectMapper = objectMapperC.newInstance();
-        } catch (Exception e) {
-            // do nothing, Jackson not found
-        }
-    }
+    private static ObjectMapper objectMapper = new ObjectMapper();
 
     private MongoDbBasicConverters() { }
     
@@ -73,12 +62,6 @@ public final class MongoDbBasicConverter
    
     @Converter
     public static DBObject fromAnyObjectToDBObject(Object value) {
-        if (MongoDbBasicConverters.objectMapper == null) {
-            LOG.warn("Conversion has fallen back to generic Object -> DBObject, but Jackson
" 
-                         + "was not available on the classpath during initialization. Returning
null.");
-            return null;
-        }
-        
         BasicDBObject answer;
         try {
             Map m = MongoDbBasicConverters.objectMapper.convertValue(value, Map.class);



Mime
View raw message