You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/12/04 14:53:41 UTC
[camel-quarkus] branch master updated: Automatically register dozer
mapping classes for reflection
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new 2db85bc Automatically register dozer mapping classes for reflection
2db85bc is described below
commit 2db85bc896a83a385a664afeac157125db348744
Author: James Netherton <ja...@gmail.com>
AuthorDate: Wed Dec 4 07:49:34 2019 +0000
Automatically register dozer mapping classes for reflection
---
.../component/dozer/deployment/DozerProcessor.java | 25 +++++++++++++++-------
.../component/dozer/it/model/CustomerA.java | 3 ---
.../component/dozer/it/model/CustomerB.java | 3 ---
3 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/extensions/dozer/deployment/src/main/java/org/apache/camel/quarkus/component/dozer/deployment/DozerProcessor.java b/extensions/dozer/deployment/src/main/java/org/apache/camel/quarkus/component/dozer/deployment/DozerProcessor.java
index 97551a7..5b37179 100644
--- a/extensions/dozer/deployment/src/main/java/org/apache/camel/quarkus/component/dozer/deployment/DozerProcessor.java
+++ b/extensions/dozer/deployment/src/main/java/org/apache/camel/quarkus/component/dozer/deployment/DozerProcessor.java
@@ -35,6 +35,8 @@ import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
+import com.github.dozermapper.core.DozerBeanMapperBuilder;
+import com.github.dozermapper.core.Mapper;
import com.github.dozermapper.core.builder.model.jaxb.AllowedExceptionsDefinition;
import com.github.dozermapper.core.builder.model.jaxb.ClassDefinition;
import com.github.dozermapper.core.builder.model.jaxb.ConfigurationDefinition;
@@ -53,10 +55,7 @@ import com.github.dozermapper.core.builder.model.jaxb.VariableDefinition;
import com.github.dozermapper.core.builder.model.jaxb.VariablesDefinition;
import com.sun.el.ExpressionFactoryImpl;
-import org.apache.camel.component.dozer.CustomMapper;
import org.apache.camel.component.dozer.DozerConfiguration;
-import org.apache.camel.component.dozer.ExpressionMapper;
-import org.apache.camel.component.dozer.VariableMapper;
import org.apache.camel.converter.dozer.DozerBeanMapperConfiguration;
import org.apache.camel.converter.dozer.DozerThreadContextClassLoader;
import org.apache.camel.quarkus.component.dozer.CamelDozerConfig;
@@ -126,11 +125,7 @@ class DozerProcessor {
"com.github.dozermapper.core.builder.model.jaxb.package-info",
"com.sun.org.apache.xerces.internal.impl.dv.xs.SchemaDVFactoryImpl"));
- reflectiveClass.produce(new ReflectiveClassBuildItem(true, false,
- CustomMapper.class,
- DozerConfiguration.class,
- ExpressionMapper.class,
- VariableMapper.class));
+ reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, DozerConfiguration.class));
reflectiveClass.produce(new ReflectiveClassBuildItem(true, true,
AllowedExceptionsDefinition.class,
@@ -149,6 +144,20 @@ class DozerProcessor {
Type.class,
VariableDefinition.class,
VariablesDefinition.class));
+
+ if (!camelDozerConfig.mappingFiles.isEmpty()) {
+ // Register for reflection any classes participating in Dozer mapping
+ Mapper mapper = DozerBeanMapperBuilder.create()
+ .withMappingFiles(camelDozerConfig.mappingFiles)
+ .build();
+
+ mapper.getMappingMetadata()
+ .getClassMappings()
+ .stream()
+ .map(metadata -> new ReflectiveClassBuildItem(true, false, metadata.getSourceClassName(),
+ metadata.getDestinationClassName()))
+ .forEach(reflectiveClass::produce);
+ }
}
@Record(ExecutionTime.STATIC_INIT)
diff --git a/integration-tests/dozer/src/main/java/org/apache/camel/quarkus/component/dozer/it/model/CustomerA.java b/integration-tests/dozer/src/main/java/org/apache/camel/quarkus/component/dozer/it/model/CustomerA.java
index 139fb56..3f85f79 100644
--- a/integration-tests/dozer/src/main/java/org/apache/camel/quarkus/component/dozer/it/model/CustomerA.java
+++ b/integration-tests/dozer/src/main/java/org/apache/camel/quarkus/component/dozer/it/model/CustomerA.java
@@ -16,9 +16,6 @@
*/
package org.apache.camel.quarkus.component.dozer.it.model;
-import io.quarkus.runtime.annotations.RegisterForReflection;
-
-@RegisterForReflection
public class CustomerA {
private String firstName;
diff --git a/integration-tests/dozer/src/main/java/org/apache/camel/quarkus/component/dozer/it/model/CustomerB.java b/integration-tests/dozer/src/main/java/org/apache/camel/quarkus/component/dozer/it/model/CustomerB.java
index bb1da97..dc69c6a 100644
--- a/integration-tests/dozer/src/main/java/org/apache/camel/quarkus/component/dozer/it/model/CustomerB.java
+++ b/integration-tests/dozer/src/main/java/org/apache/camel/quarkus/component/dozer/it/model/CustomerB.java
@@ -16,9 +16,6 @@
*/
package org.apache.camel.quarkus.component.dozer.it.model;
-import io.quarkus.runtime.annotations.RegisterForReflection;
-
-@RegisterForReflection
public class CustomerB {
private String firstName;