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/04/02 08:57:42 UTC
[camel] branch master updated: CAMEL-14830: camel-rest in xml
binding mode should use camel-jaxb for setting this up to avoid direct JAXB
dependency
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
The following commit(s) were added to refs/heads/master by this push:
new 7a37f4d CAMEL-14830: camel-rest in xml binding mode should use camel-jaxb for setting this up to avoid direct JAXB dependency
7a37f4d is described below
commit 7a37f4db152e4e2f873b8efbb11151a5bf0af496
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Apr 2 10:56:59 2020 +0200
CAMEL-14830: camel-rest in xml binding mode should use camel-jaxb for setting this up to avoid direct JAXB dependency
---
components/camel-rest/pom.xml | 7 -----
.../apache/camel/component/rest/RestProducer.java | 30 +++-------------------
2 files changed, 3 insertions(+), 34 deletions(-)
diff --git a/components/camel-rest/pom.xml b/components/camel-rest/pom.xml
index 286c6aa..aa0c8b0 100644
--- a/components/camel-rest/pom.xml
+++ b/components/camel-rest/pom.xml
@@ -33,13 +33,6 @@
<name>Camel :: REST</name>
<description>Camel REST component</description>
- <properties>
- <camel.osgi.import>
- javax.xml.bind*;version="[2.2,3.0)",
- *
- </camel.osgi.import>
- </properties>
-
<dependencies>
<dependency>
diff --git a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
index e80a8ce..0957a43 100644
--- a/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
+++ b/components/camel-rest/src/main/java/org/apache/camel/component/rest/RestProducer.java
@@ -24,8 +24,6 @@ import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
-import javax.xml.bind.JAXBContext;
-
import org.apache.camel.AsyncCallback;
import org.apache.camel.AsyncProcessor;
import org.apache.camel.CamelContext;
@@ -347,31 +345,9 @@ public class RestProducer extends DefaultAsyncProducer {
}
if (jaxb != null) {
- Class<?> clazz = null;
- if (type != null) {
- String typeName = type.endsWith("[]") ? type.substring(0, type.length() - 2) : type;
- clazz = camelContext.getClassResolver().resolveMandatoryClass(typeName);
- }
- if (clazz != null) {
- JAXBContext jc = JAXBContext.newInstance(clazz);
- beanIntrospection.setProperty(camelContext, jaxb, "context", jc);
- }
- setAdditionalConfiguration(configuration, camelContext, jaxb, "xml.in.");
-
- Class<?> outClazz = null;
- if (outType != null) {
- String typeName = outType.endsWith("[]") ? outType.substring(0, outType.length() - 2) : outType;
- outClazz = camelContext.getClassResolver().resolveMandatoryClass(typeName);
- }
- if (outClazz != null) {
- JAXBContext jc = JAXBContext.newInstance(outClazz);
- beanIntrospection.setProperty(camelContext, outJaxb, "context", jc);
- } else if (clazz != null) {
- // fallback and use the context from the input
- JAXBContext jc = JAXBContext.newInstance(clazz);
- beanIntrospection.setProperty(camelContext, outJaxb, "context", jc);
- }
- setAdditionalConfiguration(configuration, camelContext, outJaxb, "xml.out.");
+ // to setup JAXB we need to use camel-xml-jaxb
+ camelContext.adapt(ExtendedCamelContext.class).getRestBindingJaxbDataFormatFactory()
+ .setupJaxb(camelContext, configuration, type, outType, jaxb, outJaxb);
}
return new RestProducerBindingProcessor(producer, camelContext, json, jaxb, outJson, outJaxb, mode, skip, outType);