You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/06/17 10:06:35 UTC

[1/2] git commit: CAMEL-7514: Dozer should not initialize the same DozerBeanMapperConfiguration twice

Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x 70dcca5cb -> 516fe25ad
  refs/heads/master 377291cea -> 7c825d12e


CAMEL-7514: Dozer should not initialize the same DozerBeanMapperConfiguration twice


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

Branch: refs/heads/camel-2.13.x
Commit: 516fe25ad754ac14adb6b6bc0378b2146d3ea9dd
Parents: 70dcca5
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jun 17 09:58:03 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jun 17 10:06:18 2014 +0200

----------------------------------------------------------------------
 .../converter/dozer/DozerTypeConverterLoader.java  | 17 ++++++++++++++++-
 .../SpringDozerTypeConverterConfigurationTest.xml  |  6 +++++-
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/516fe25a/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/DozerTypeConverterLoader.java
----------------------------------------------------------------------
diff --git a/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/DozerTypeConverterLoader.java b/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/DozerTypeConverterLoader.java
index edad108..6118caf 100644
--- a/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/DozerTypeConverterLoader.java
+++ b/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/DozerTypeConverterLoader.java
@@ -64,7 +64,7 @@ public class DozerTypeConverterLoader extends ServiceSupport implements CamelCon
 
     private final Logger log = LoggerFactory.getLogger(getClass());
     private CamelContext camelContext;
-    private DozerBeanMapperConfiguration configuration;
+    private transient DozerBeanMapperConfiguration configuration;
     private transient DozerBeanMapper mapper;
 
     /**
@@ -120,6 +120,7 @@ public class DozerTypeConverterLoader extends ServiceSupport implements CamelCon
 
         this.camelContext = camelContext;
         this.mapper = mapper;
+        this.configuration = configuration;
 
         try {
             camelContext.addService(this);
@@ -174,6 +175,20 @@ public class DozerTypeConverterLoader extends ServiceSupport implements CamelCon
 
         // add any dozer bean mapper configurations
         Map<String, DozerBeanMapperConfiguration> configurations = lookupDozerBeanMapperConfigurations();
+        if (configurations != null && configuration != null) {
+            // filter out existing configuration, as we do not want to use it twice
+            String key = null;
+            for (Map.Entry<String, DozerBeanMapperConfiguration> entry : configurations.entrySet()) {
+                if (entry.getValue() == configuration) {
+                    key = entry.getKey();
+                    break;
+                }
+            }
+            if (key != null) {
+                configurations.remove(key);
+            }
+        }
+
         if (configurations != null) {
             if (configurations.size() > 1) {
                 log.warn("Loaded " + configurations.size() + " Dozer configurations from Camel registry."

http://git-wip-us.apache.org/repos/asf/camel/blob/516fe25a/components/camel-dozer/src/test/resources/SpringDozerTypeConverterConfigurationTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-dozer/src/test/resources/SpringDozerTypeConverterConfigurationTest.xml b/components/camel-dozer/src/test/resources/SpringDozerTypeConverterConfigurationTest.xml
index 8a51385..7490087 100644
--- a/components/camel-dozer/src/test/resources/SpringDozerTypeConverterConfigurationTest.xml
+++ b/components/camel-dozer/src/test/resources/SpringDozerTypeConverterConfigurationTest.xml
@@ -29,7 +29,11 @@
   </camelContext>
 
   <bean id="customer-processor" class="org.apache.camel.converter.dozer.CustomerProcessor"/>
-  <bean id="dozerConverterLoader" class="org.apache.camel.converter.dozer.DozerTypeConverterLoader"/>
+
+  <bean id="dozerConverterLoader" class="org.apache.camel.converter.dozer.DozerTypeConverterLoader">
+    <constructor-arg index="0" ref="camel"/>
+    <constructor-arg index="1" ref="mapper"/>
+  </bean>
 
   <!-- use bean mapping configuration -->
   <bean id="mapper" class="org.apache.camel.converter.dozer.DozerBeanMapperConfiguration">


[2/2] git commit: CAMEL-7514: Dozer should not initialize the same DozerBeanMapperConfiguration twice

Posted by da...@apache.org.
CAMEL-7514: Dozer should not initialize the same DozerBeanMapperConfiguration twice


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

Branch: refs/heads/master
Commit: 7c825d12ecbcd95a9a32feed6f41fa83cd3fc317
Parents: 377291c
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jun 17 09:58:03 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jun 17 10:06:26 2014 +0200

----------------------------------------------------------------------
 .../converter/dozer/DozerTypeConverterLoader.java  | 17 ++++++++++++++++-
 .../SpringDozerTypeConverterConfigurationTest.xml  |  6 +++++-
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7c825d12/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/DozerTypeConverterLoader.java
----------------------------------------------------------------------
diff --git a/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/DozerTypeConverterLoader.java b/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/DozerTypeConverterLoader.java
index edad108..6118caf 100644
--- a/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/DozerTypeConverterLoader.java
+++ b/components/camel-dozer/src/main/java/org/apache/camel/converter/dozer/DozerTypeConverterLoader.java
@@ -64,7 +64,7 @@ public class DozerTypeConverterLoader extends ServiceSupport implements CamelCon
 
     private final Logger log = LoggerFactory.getLogger(getClass());
     private CamelContext camelContext;
-    private DozerBeanMapperConfiguration configuration;
+    private transient DozerBeanMapperConfiguration configuration;
     private transient DozerBeanMapper mapper;
 
     /**
@@ -120,6 +120,7 @@ public class DozerTypeConverterLoader extends ServiceSupport implements CamelCon
 
         this.camelContext = camelContext;
         this.mapper = mapper;
+        this.configuration = configuration;
 
         try {
             camelContext.addService(this);
@@ -174,6 +175,20 @@ public class DozerTypeConverterLoader extends ServiceSupport implements CamelCon
 
         // add any dozer bean mapper configurations
         Map<String, DozerBeanMapperConfiguration> configurations = lookupDozerBeanMapperConfigurations();
+        if (configurations != null && configuration != null) {
+            // filter out existing configuration, as we do not want to use it twice
+            String key = null;
+            for (Map.Entry<String, DozerBeanMapperConfiguration> entry : configurations.entrySet()) {
+                if (entry.getValue() == configuration) {
+                    key = entry.getKey();
+                    break;
+                }
+            }
+            if (key != null) {
+                configurations.remove(key);
+            }
+        }
+
         if (configurations != null) {
             if (configurations.size() > 1) {
                 log.warn("Loaded " + configurations.size() + " Dozer configurations from Camel registry."

http://git-wip-us.apache.org/repos/asf/camel/blob/7c825d12/components/camel-dozer/src/test/resources/SpringDozerTypeConverterConfigurationTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-dozer/src/test/resources/SpringDozerTypeConverterConfigurationTest.xml b/components/camel-dozer/src/test/resources/SpringDozerTypeConverterConfigurationTest.xml
index 8a51385..7490087 100644
--- a/components/camel-dozer/src/test/resources/SpringDozerTypeConverterConfigurationTest.xml
+++ b/components/camel-dozer/src/test/resources/SpringDozerTypeConverterConfigurationTest.xml
@@ -29,7 +29,11 @@
   </camelContext>
 
   <bean id="customer-processor" class="org.apache.camel.converter.dozer.CustomerProcessor"/>
-  <bean id="dozerConverterLoader" class="org.apache.camel.converter.dozer.DozerTypeConverterLoader"/>
+
+  <bean id="dozerConverterLoader" class="org.apache.camel.converter.dozer.DozerTypeConverterLoader">
+    <constructor-arg index="0" ref="camel"/>
+    <constructor-arg index="1" ref="mapper"/>
+  </bean>
 
   <!-- use bean mapping configuration -->
   <bean id="mapper" class="org.apache.camel.converter.dozer.DozerBeanMapperConfiguration">