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 2020/02/12 09:26:14 UTC
[camel] 01/02: CAMEL-14538: camel-core - Do not load type
converters via package scanning by default
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit efc4d0c5da83598fc4adc7d3f3a85251a172491e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Feb 12 10:03:04 2020 +0100
CAMEL-14538: camel-core - Do not load type converters via package scanning by default
---
.../camel/impl/engine/AbstractCamelContext.java | 2 +-
.../camel/main/DefaultConfigurationProperties.java | 2 +-
.../modules/ROOT/pages/camel-3x-upgrade-guide.adoc | 26 ++++++++++++++++++++++
.../modules/ROOT/pages/type-converter.adoc | 26 +++++++++++++++++++++-
4 files changed, 53 insertions(+), 3 deletions(-)
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 71959a0..1387bad 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -212,7 +212,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
private Boolean logExhaustedMessageBody = Boolean.FALSE;
private Boolean streamCache = Boolean.FALSE;
private Boolean disableJMX = Boolean.FALSE;
- private Boolean loadTypeConverters = Boolean.TRUE;
+ private Boolean loadTypeConverters = Boolean.FALSE;
private Boolean typeConverterStatisticsEnabled = Boolean.FALSE;
private Boolean useMDCLogging = Boolean.FALSE;
private String mdcLoggingKeysPattern;
diff --git a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
index 1a26864..35135e7 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/DefaultConfigurationProperties.java
@@ -39,7 +39,7 @@ public abstract class DefaultConfigurationProperties<T> {
private boolean jmxEnabled = true;
private int producerTemplateCacheSize = 1000;
private int consumerTemplateCacheSize = 1000;
- private boolean loadTypeConverters = true;
+ private boolean loadTypeConverters;
private int logDebugMaxChars;
private boolean streamCachingEnabled;
private String streamCachingSpoolDirectory;
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
index 52f398d..ad7fb1f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
@@ -147,6 +147,32 @@ of using XML for beans and Camel XML routes. And a few components such as `camel
But at general then Camel is now lighter in classpath dependency by not requiring to have JAXB present.
+=== Package scanning @TypeConverter
+
+Camel has now been configured to not package scan for custom `@Converter` classes on startup.
+Type converters are now loaded and registered in faster way via source code generated loader classes
+by having `@Converter(loader = true)` specified. If you have custom converters and have not migrated to use
+source code generated loaders, you can enable package scanning by setting
+
+[source,java]
+----
+camelContext.setLoadTypeConverters(true);
+----
+
+And in XML:
+[source,xml]
+----
+<camelContext loadTypeConverters="true">
+...
+</camelContext>
+----
+
+And in Spring Boot `application.properties`:
+[source,properties]
+----
+camel.loadTypeConverters=true
+----
+
=== Graceful Shutdown Timeout
When shutting down Camel, then the default timeout has changed from 300 seconds (5 minutes) to 45 seconds.
diff --git a/docs/user-manual/modules/ROOT/pages/type-converter.adoc b/docs/user-manual/modules/ROOT/pages/type-converter.adoc
index 9da6bdd..dbd1941 100644
--- a/docs/user-manual/modules/ROOT/pages/type-converter.adoc
+++ b/docs/user-manual/modules/ROOT/pages/type-converter.adoc
@@ -139,7 +139,31 @@ all type converter loader classes (they are automatic source code generated by t
These _loader_ classes will load the type converters into the Camel type converter registry
and invoking these type converters is done in a _fast way_ using standard java method calls.
-The discover will fallback and discover Camel 2.x compatible type converters by
+=== Discovering Camel 2.x based type converters (not loader)
+
+Camel will not perform additional package scanning for type conveters which has no source code generated loader classes.
+However this can be enabled by setting:
+
+[source,java]
+----
+camelContext.setLoadTypeConverters(true);
+----
+
+And in XML:
+[source,xml]
+----
+<camelContext loadTypeConverters="true">
+...
+</camelContext>
+----
+
+And in Spring Boot `application.properties`:
+[source,properties]
+----
+camel.loadTypeConverters=true
+----
+
+Then Camel will discover discover Camel 2.x compatible type converters by
search the classpath for a file called `META-INF/services/org/apache/camel/TypeConverter`,
which lists all the type converter classes. These classes will then automatic
be registered in the type converter registry. However invoking these type converters