camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/5] camel git commit: CAMEL-11380: Optimise - Allow to turn DataType on or off on Message
Date Wed, 07 Jun 2017 10:48:19 GMT
CAMEL-11380: Optimise - Allow to turn DataType on or off on Message


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

Branch: refs/heads/master
Commit: 9df68139967f297c39d14424af6aac4b52e0a7a6
Parents: c3a28da
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Jun 7 12:29:52 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Jun 7 12:37:17 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/CamelContext.java     | 20 ++++++++++++++++++++
 .../mbean/ManagedCamelContextMBean.java         |  3 +++
 .../camel/builder/TransformerBuilder.java       | 14 ++------------
 .../apache/camel/impl/DefaultCamelContext.java  | 15 +++++++++++++++
 .../apache/camel/impl/DefaultRouteContext.java  |  2 ++
 .../org/apache/camel/impl/MessageSupport.java   | 15 ++++++++++-----
 .../management/mbean/ManagedCamelContext.java   |  4 ++++
 .../apache/camel/processor/ContractAdvice.java  |  6 +++---
 .../camel/processor/RestBindingAdvice.java      |  7 +++++--
 .../org/apache/camel/spi/DataTypeAware.java     | 17 +++++++++++++++--
 .../blueprint/CamelContextFactoryBean.java      | 10 ++++++++++
 .../camel/cdi/xml/CamelContextFactoryBean.java  | 11 +++++++++++
 .../xml/AbstractCamelContextFactoryBean.java    |  5 +++++
 .../AbstractCamelContextFactoryBeanTest.java    |  2 +-
 .../spring/boot/CamelAutoConfiguration.java     |  2 +-
 .../boot/CamelConfigurationProperties.java      | 16 ++++++++++++++++
 .../camel/spring/CamelContextFactoryBean.java   | 20 ++++++++++++++++++++
 17 files changed, 143 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/camel-core/src/main/java/org/apache/camel/CamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/CamelContext.java b/camel-core/src/main/java/org/apache/camel/CamelContext.java
index ff0eb9a..ed5081d 100644
--- a/camel-core/src/main/java/org/apache/camel/CamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/CamelContext.java
@@ -1752,6 +1752,26 @@ public interface CamelContext extends SuspendableService, RuntimeConfiguration
{
     void setUseMDCLogging(Boolean useMDCLogging);
 
     /**
+     * Whether to enable using data type on Camel messages.
+     * <p/>
+     * Data type are automatic turned on if one ore more routes has been explicit configured
with input and output types.
+     * Otherwise data type is default off.
+     *
+     * @return <tt>true</tt> if data type is enabled
+     */
+    Boolean isUseDataType();
+
+    /**
+     * Whether to enable using data type on Camel messages.
+     * <p/>
+     * Data type are automatic turned on if one ore more routes has been explicit configured
with input and output types.
+     * Otherwise data type is default off.
+     *
+     * @param  useDataType <tt>true</tt> to enable data type on Camel messages.
+     */
+    void setUseDataType(Boolean useDataType);
+
+    /**
      * Whether or not breadcrumb is enabled.
      *
      * @return <tt>true</tt> if breadcrumb is enabled

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java
b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java
index fb931d0..7cf41f6 100644
--- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java
+++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedCamelContextMBean.java
@@ -154,6 +154,9 @@ public interface ManagedCamelContextMBean extends ManagedPerformanceCounterMBean
     @ManagedAttribute(description = "Whether MDC logging is supported")
     boolean isUseMDCLogging();
 
+    @ManagedAttribute(description = "Whether Message DataType is enabled")
+    boolean isUseDataType();
+
     @ManagedOperation(description = "Start Camel")
     void start() throws Exception;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/camel-core/src/main/java/org/apache/camel/builder/TransformerBuilder.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/builder/TransformerBuilder.java b/camel-core/src/main/java/org/apache/camel/builder/TransformerBuilder.java
index 0f4b07e..4ce9243 100644
--- a/camel-core/src/main/java/org/apache/camel/builder/TransformerBuilder.java
+++ b/camel-core/src/main/java/org/apache/camel/builder/TransformerBuilder.java
@@ -70,7 +70,7 @@ public class TransformerBuilder {
     /**
      * Set the 'from' data type using Java class.
      *
-     * @param clazz 'from' Java class
+     * @param from 'from' Java class
      */
     public TransformerBuilder fromType(Class<?> from) {
         this.from = new DataType(from).toString();
@@ -102,8 +102,7 @@ public class TransformerBuilder {
 
     /**
      * Set the URI to be used for the endpoint {@code Transformer}.
-     * @see {@code EndpointTransformerDefinition}, {@code ProcessorTransformer}
-     * 
+     *
      * @param uri endpoint URI
      */
     public TransformerBuilder withUri(String uri) {
@@ -114,9 +113,6 @@ public class TransformerBuilder {
 
     /**
      * Set the {@code DataFormatDefinition} to be used for the {@code DataFormat} {@code
Transformer}.
-     * @see {@code DataFormatTransformerDefinition}, {@code DataFormatTransformer}
-     * 
-     * @param dataFormatDefinition {@code DataFormatDefinition}
      */
     public TransformerBuilder withDataFormat(DataFormatDefinition dataFormatDefinition) {
         resetType();
@@ -126,9 +122,6 @@ public class TransformerBuilder {
 
     /**
      * Set the Java {@code Class} represents a custom {@code Transformer} implementation
class.
-     * @see {@code CustomTransformerDefinition}
-     * 
-     * @param clazz {@code Class} object represents custom transformer implementation
      */
     public TransformerBuilder withJava(Class<? extends Transformer> clazz) {
         resetType();
@@ -138,9 +131,6 @@ public class TransformerBuilder {
 
     /**
      * Set the Java Bean name to be used for custom {@code Transformer}.
-     * @see {@code CustomTransformerDefinition}
-     * 
-     * @param ref bean name for the custom {@code Transformer}
      */
     public TransformerBuilder withBean(String ref) {
         resetType();

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index ea34a75..136c063 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -254,6 +254,7 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
     private Boolean lazyLoadTypeConverters = Boolean.FALSE;
     private Boolean typeConverterStatisticsEnabled = Boolean.FALSE;
     private Boolean useMDCLogging = Boolean.FALSE;
+    private Boolean useDataType = Boolean.FALSE;
     private Boolean useBreadcrumb = Boolean.TRUE;
     private Boolean allowUseOriginalMessage = Boolean.FALSE;
     private Long delay;
@@ -3308,6 +3309,11 @@ public class DefaultCamelContext extends ServiceSupport implements
ModelCamelCon
             }
         }
 
+        if (isUseDataType()) {
+            // log if DataType has been enabled
+            log.info("Message DataType is enabled on CamelContext: {}", getName());
+        }
+
         if (streamCachingInUse) {
             // stream caching is in use so enable the strategy
             getStreamCachingStrategy().setEnabled(true);
@@ -4246,6 +4252,15 @@ public class DefaultCamelContext extends ServiceSupport implements
ModelCamelCon
         this.useMDCLogging = useMDCLogging;
     }
 
+    public Boolean isUseDataType() {
+        return useDataType;
+    }
+
+    @Override
+    public void setUseDataType(Boolean useDataType) {
+        this.useDataType = useDataType;
+    }
+
     public Boolean isUseBreadcrumb() {
         return useBreadcrumb != null && useBreadcrumb;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
index 2d15015..89342b8 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
@@ -215,6 +215,8 @@ public class DefaultRouteContext implements RouteContext {
                     contract.setValidateOutput(route.getOutputType().isValidate());
                 }
                 internal.addAdvice(new ContractAdvice(contract));
+                // make sure to enable data type as its in use when using input/output types
on routes
+                camelContext.setUseDataType(true);
             }
 
             // and create the route that wraps the UoW

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java b/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
index 6b7c774..4c564b8 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/MessageSupport.java
@@ -118,7 +118,10 @@ public abstract class MessageSupport implements Message, CamelContextAware,
Data
 
     public void setBody(Object body) {
         this.body = body;
-        this.dataType = body != null ? new DataType(body.getClass()) : null;
+        // set data type if in use
+        if (body != null && camelContext.isUseDataType()) {
+            this.dataType = new DataType(body.getClass());
+        }
     }
 
     public <T> void setBody(Object value, Class<T> type) {
@@ -140,9 +143,6 @@ public abstract class MessageSupport implements Message, CamelContextAware,
Data
 
     @Override
     public DataType getDataType() {
-        if (this.dataType == null) {
-            this.dataType = body != null ? new DataType(body.getClass()) : null;
-        }
         return this.dataType;
     }
 
@@ -151,6 +151,11 @@ public abstract class MessageSupport implements Message, CamelContextAware,
Data
         this.dataType = type;
     }
 
+    @Override
+    public boolean hasDataType() {
+        return dataType != null;
+    }
+
     public Message copy() {
         Message answer = newInstance();
         // must copy over CamelContext
@@ -171,7 +176,7 @@ public abstract class MessageSupport implements Message, CamelContextAware,
Data
         if (that instanceof CamelContextAware) {
             setCamelContext(((CamelContextAware) that).getCamelContext());
         }
-        if (that instanceof DataTypeAware) {
+        if (that instanceof DataTypeAware && ((DataTypeAware) that).hasDataType())
{
             setDataType(((DataTypeAware)that).getDataType());
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
index 3d5d419..b062202 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
@@ -276,6 +276,10 @@ public class ManagedCamelContext extends ManagedPerformanceCounter implements
Ti
         return context.isUseMDCLogging();
     }
 
+    public boolean isUseDataType() {
+        return context.isUseDataType();
+    }
+
     public void onTimer() {
         load.update(getInflightExchanges());
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/camel-core/src/main/java/org/apache/camel/processor/ContractAdvice.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/ContractAdvice.java b/camel-core/src/main/java/org/apache/camel/processor/ContractAdvice.java
index 5ff0ff2..f2e792a 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/ContractAdvice.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/ContractAdvice.java
@@ -43,12 +43,12 @@ import org.slf4j.LoggerFactory;
  * from current OUT message (or IN message if no OUT), camel look for a Transformer and apply.
  * 
  * @see Transformer
- * @see Validator}
+ * @see Validator
  * @see InputTypeDefinition
  * @see OutputTypeDefinition
  */
 public class ContractAdvice implements CamelInternalProcessorAdvice {
-    private static final Logger LOG = LoggerFactory.getLogger(CamelInternalProcessor.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ContractAdvice.class);
 
     private Contract contract;
     
@@ -132,7 +132,7 @@ public class ContractAdvice implements CamelInternalProcessorAdvice {
     }
     
     private boolean convertIfRequired(Message message, DataType type) throws Exception {
-        // TODO for better performance it may be better to add TypeConveterTransformer
+        // TODO for better performance it may be better to add TypeConverterTransformer
         // into transformer registry automatically to avoid unnecessary scan in transformer
registry
         if (type != null && type.isJavaType() && type.getName() != null)
{
             CamelContext context = message.getExchange().getContext();

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java b/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java
index ee41ee4..61904e3 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/RestBindingAdvice.java
@@ -165,8 +165,11 @@ public class RestBindingAdvice implements CamelInternalProcessorAdvice<Map<Strin
             isJson = consumes != null && consumes.toLowerCase(Locale.ENGLISH).contains("json");
         }
 
-        if (exchange.getIn() instanceof DataTypeAware && (isJson || isXml)) {
-            ((DataTypeAware)exchange.getIn()).setDataType(new DataType(isJson ? "json" :
"xml"));
+        // set data type if in use
+        if (exchange.getContext().isUseDataType()) {
+            if (exchange.getIn() instanceof DataTypeAware && (isJson || isXml)) {
+                ((DataTypeAware) exchange.getIn()).setDataType(new DataType(isJson ? "json"
: "xml"));
+            }
         }
 
         // only allow xml/json if the binding mode allows that

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/camel-core/src/main/java/org/apache/camel/spi/DataTypeAware.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/spi/DataTypeAware.java b/camel-core/src/main/java/org/apache/camel/spi/DataTypeAware.java
index f979f74..d2b9417 100644
--- a/camel-core/src/main/java/org/apache/camel/spi/DataTypeAware.java
+++ b/camel-core/src/main/java/org/apache/camel/spi/DataTypeAware.java
@@ -24,25 +24,38 @@ package org.apache.camel.spi;
  * in a DataTypeAware message carries that missing data type information even if it's
  * marshaled, and whatever the Java class of the body is. This type information is used
  * to detect required {@link Transformer} and {@link Validator}.
- * 
- * @see {@link DataType} {@link Transformer} {@link Validator}
+ * <p/>
+ * Data type are automatic turned on if one ore more routes has been explicit configured
with input and output types.
+ * Otherwise data type is default off.
+ *
+ * @see DataType
+ * @see Transformer
+ * @see Validator
  */
 public interface DataTypeAware {
 
     /**
      * Set the data type of the message.
+     *
      * @param type data type
      */
     void setDataType(DataType type);
 
     /**
      * Get the data type of the message.
+     *
      * @return data type
      */
     DataType getDataType();
 
     /**
+     * Whether any data type has been configured
+     */
+    boolean hasDataType();
+
+    /**
      * Set the message body with data type.
+     *
      * @param body message body
      * @param type data type
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
index 3378eb9..3b870c5 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
@@ -109,6 +109,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
     @XmlAttribute
     private String useMDCLogging;
     @XmlAttribute
+    private String useDataType;
+    @XmlAttribute
     private String useBreadcrumb;
     @XmlAttribute
     private String allowUseOriginalMessage;
@@ -383,6 +385,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Blu
         this.useMDCLogging = useMDCLogging;
     }
 
+    public String getUseDataType() {
+        return useDataType;
+    }
+
+    public void setUseDataType(String useDataType) {
+        this.useDataType = useDataType;
+    }
+
     public String getUseBreadcrumb() {
         return useBreadcrumb;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
index f62c463..edff3ef 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/xml/CamelContextFactoryBean.java
@@ -108,6 +108,9 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Def
     private String useMDCLogging;
 
     @XmlAttribute
+    private String useDataType;
+
+    @XmlAttribute
     private String useBreadcrumb;
 
     @XmlAttribute
@@ -611,6 +614,14 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Def
         this.useMDCLogging = useMDCLogging;
     }
 
+    public String getUseDataType() {
+        return useDataType;
+    }
+
+    public void setUseDataType(String useDataType) {
+        this.useDataType = useDataType;
+    }
+
     public String getUseBreadcrumb() {
         return useBreadcrumb;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
index 32f53f8..fe24c55 100644
--- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
+++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
@@ -747,6 +747,8 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
 
     public abstract String getUseMDCLogging();
 
+    public abstract String getUseDataType();
+
     public abstract String getUseBreadcrumb();
 
     public abstract String getAllowUseOriginalMessage();
@@ -853,6 +855,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
         if (getUseMDCLogging() != null) {
             ctx.setUseMDCLogging(CamelContextHelper.parseBoolean(context, getUseMDCLogging()));
         }
+        if (getUseDataType() != null) {
+            ctx.setUseDataType(CamelContextHelper.parseBoolean(context, getUseDataType()));
+        }
         if (getUseBreadcrumb() != null) {
             ctx.setUseBreadcrumb(CamelContextHelper.parseBoolean(context, getUseBreadcrumb()));
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/components/camel-core-xml/src/test/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBeanTest.java
----------------------------------------------------------------------
diff --git a/components/camel-core-xml/src/test/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBeanTest.java
b/components/camel-core-xml/src/test/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBeanTest.java
index 98fe9a1..c374773 100644
--- a/components/camel-core-xml/src/test/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBeanTest.java
+++ b/components/camel-core-xml/src/test/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBeanTest.java
@@ -65,7 +65,7 @@ public class AbstractCamelContextFactoryBeanTest {
     // properties that should return value that can be converted to boolean
     Set<String> valuesThatReturnBoolean = new HashSet<>(asList("{{getStreamCache}}",
"{{getTrace}}",
         "{{getMessageHistory}}", "{{getLogMask}}", "{{getLogExhaustedMessageBody}}", "{{getHandleFault}}",
-        "{{getAutoStartup}}", "{{getUseMDCLogging}}", "{{getUseBreadcrumb}}", "{{getAllowUseOriginalMessage}}"));
+        "{{getAutoStartup}}", "{{getUseMDCLogging}}", "{{getUseDataType}}", "{{getUseBreadcrumb}}",
"{{getAllowUseOriginalMessage}}"));
 
     // properties that should return value that can be converted to long
     Set<String> valuesThatReturnLong = new HashSet<>(asList("{{getDelayer}}"));

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
index 6b8ab26..4da40b3 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelAutoConfiguration.java
@@ -29,7 +29,6 @@ import org.apache.camel.ProducerTemplate;
 import org.apache.camel.TypeConverters;
 import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.component.properties.PropertiesParser;
-import org.apache.camel.impl.DefaultRuntimeEndpointRegistry;
 import org.apache.camel.impl.FileWatcherReloadStrategy;
 import org.apache.camel.processor.interceptor.BacklogTracer;
 import org.apache.camel.processor.interceptor.DefaultTraceFormatter;
@@ -157,6 +156,7 @@ public class CamelAutoConfiguration {
         camelContext.setAutoStartup(config.isAutoStartup());
         camelContext.setAllowUseOriginalMessage(config.isAllowUseOriginalMessage());
         camelContext.setUseBreadcrumb(config.isUseBreadcrumb());
+        camelContext.setUseDataType(config.isUseDataType());
 
         if (camelContext.getManagementStrategy().getManagementAgent() != null) {
             camelContext.getManagementStrategy().getManagementAgent().setEndpointRuntimeStatisticsEnabled(config.isEndpointRuntimeStatisticsEnabled());

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
index 6393682..47417f3 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
@@ -301,6 +301,14 @@ public class CamelConfigurationProperties {
     private boolean endpointRuntimeStatisticsEnabled;
 
     /**
+     * Whether to enable using data type on Camel messages.
+     * <p/>
+     * Data type are automatic turned on if one ore more routes has been explicit configured
with input and output types.
+     * Otherwise data type is default off.
+     */
+    private boolean useDataType;
+
+    /**
      * Set whether breadcrumb is enabled.
      */
     private boolean useBreadcrumb = true;
@@ -697,6 +705,14 @@ public class CamelConfigurationProperties {
         this.endpointRuntimeStatisticsEnabled = endpointRuntimeStatisticsEnabled;
     }
 
+    public boolean isUseDataType() {
+        return useDataType;
+    }
+
+    public void setUseDataType(boolean useDataType) {
+        this.useDataType = useDataType;
+    }
+
     public boolean isUseBreadcrumb() {
         return useBreadcrumb;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/9df68139/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
index f0c115c..eb79196 100644
--- a/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
+++ b/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
@@ -123,6 +123,8 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
     private String shutdownEager;
     @XmlAttribute
     private String useMDCLogging;
+    @XmlAttribute
+    private String useDataType;
     @XmlAttribute @Metadata(defaultValue = "true")
     private String useBreadcrumb;
     @XmlAttribute
@@ -767,6 +769,24 @@ public class CamelContextFactoryBean extends AbstractCamelContextFactoryBean<Spr
         this.useMDCLogging = useMDCLogging;
     }
 
+    public String getUseDataType() {
+        return useDataType;
+    }
+
+    /**
+     * Whether to enable using data type on Camel messages.
+     * <p/>
+     * Data type are automatic turned on if:
+     * <ul>
+     *   <li>one ore more routes has been explicit configured with input and output
types</li>
+     *   <li>when using rest-dsl with binding turned on</li>
+     * </ul>
+     * Otherwise data type is default off.
+     */
+    public void setUseDataType(String useDataType) {
+        this.useDataType = useDataType;
+    }
+
     public String getUseBreadcrumb() {
         return useBreadcrumb;
     }


Mime
View raw message