camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] git commit: CAMEL-7514: Dozer should not initialize the same DozerBeanMapperConfiguration twice
Date Tue, 17 Jun 2014 08:06:36 GMT
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 <davsclaus@apache.org>
Authored: Tue Jun 17 09:58:03 2014 +0200
Committer: Claus Ibsen <davsclaus@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">


Mime
View raw message