Skip to content

Commit

Permalink
Document that AtlasMap user classes may need to be registered for ref…
Browse files Browse the repository at this point in the history
…lection fixes #2319
  • Loading branch information
zbendhiba committed Mar 15, 2021
1 parent e4adcc2 commit 2fd98f6
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 94 deletions.
2 changes: 2 additions & 0 deletions docs/modules/ROOT/pages/reference/extensions/atlasmap.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,7 @@ In native mode, include this file for native build. Example:
quarkus.native.resources.includes = mapping/atlas-mapping.json
----

When mapping Java documents, you may need to register the corresponding Java classes for reflection.

You may want to check the https://github.com/apache/camel-quarkus/tree/master/integration-tests/atlasmap[integration test] in our source tree as an example.

2 changes: 2 additions & 0 deletions extensions/atlasmap/runtime/src/main/doc/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ In native mode, include this file for native build. Example:
quarkus.native.resources.includes = mapping/atlas-mapping.json
----

When mapping Java documents, you may need to register the corresponding Java classes for reflection.

You may want to check the https://github.com/apache/camel-quarkus/tree/master/integration-tests/atlasmap[integration test] in our source tree as an example.
34 changes: 34 additions & 0 deletions integration-tests/atlasmap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-platform-http</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jackson</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
Expand Down Expand Up @@ -78,6 +86,32 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jackson-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-platform-http-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,12 @@ public String convertCsv2JsonWithJson(String csv) {
return producerTemplate.requestBody("atlasmap:mapping/json/atlasmapping-csv-to-json.json", csv, String.class);
}

@GET
@Path("json/csv2java")
public Person convertCsv2JavaWithJson(String csv) {
return producerTemplate.requestBody("atlasmap:mapping/json/atlasmapping-csv-to-java.json", csv, Person.class);
}

@GET
@Path("json/csv2xml")
public String convertCsv2XmlWithJson(String csv) {
return producerTemplate.requestBody("atlasmap:mapping/json/atlasmapping-csv-to-xml.json", csv, String.class);
}

@GET
@Path("json/java2csv")
public String convertJava2CsvWithJson(Person person) {
return producerTemplate.requestBody("atlasmap:mapping/json/atlasmapping-java-to-csv.json", person, String.class);
}

@GET
@Path("json/xml2csv")
public String convertXml2CsvWithJson(String xml) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.atlasmap.it;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.quarkus.component.atlasmap.it.model.Account;

public class Route extends RouteBuilder {
@Override
public void configure() throws Exception {

// example of Routes that need the class Account to be registred for reflection
from("platform-http:/atlasmap/json/java2csv?httpMethodRestrict=POST")
.unmarshal().json(Account.class)
.to("atlasmap:mapping/json/atlasmapping-java-to-csv.json");

from("platform-http:/atlasmap/json/csv2java?httpMethodRestrict=POST")
.to("atlasmap:mapping/json/atlasmapping-csv-to-java.json")
.marshal().json(Account.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.camel.quarkus.component.atlasmap.it.model;

import io.quarkus.runtime.annotations.RegisterForReflection;

@RegisterForReflection
public class Account {

String id;
String userName;

public Account() {
}

public Account(String id, String userName) {
this.id = id;
this.userName = userName;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
{
"jsonType": "io.atlasmap.v2.DataSource",
"id": "Person",
"uri": "atlas:java?className=org.apache.camel.quarkus.component.atlasmap.it.model.Person",
"id": "Account",
"uri": "atlas:java?className=org.apache.camel.quarkus.component.atlasmap.it.model.Account",
"dataSourceType": "TARGET"
}
],
Expand All @@ -23,19 +23,19 @@
"inputField": [
{
"jsonType": "io.atlasmap.csv.v2.CsvField",
"name": "firstName",
"path": "/<>/firstName",
"name": "id",
"path": "/<>/id",
"fieldType": "STRING",
"docId": "target-csv"
}
],
"outputField": [
{
"jsonType": "io.atlasmap.java.v2.JavaField",
"name": "firstName",
"path": "/firstName",
"name": "id",
"path": "/id",
"fieldType": "STRING",
"docId": "Person"
"docId": "Account"
}
]
},
Expand All @@ -45,41 +45,19 @@
"inputField": [
{
"jsonType": "io.atlasmap.csv.v2.CsvField",
"name": "lastName",
"path": "/<>/lastName",
"name": "userName",
"path": "/<>/userName",
"fieldType": "STRING",
"docId": "target-csv"
}
],
"outputField": [
{
"jsonType": "io.atlasmap.java.v2.JavaField",
"name": "lastName",
"path": "/lastName",
"name": "userName",
"path": "/userName",
"fieldType": "STRING",
"docId": "Person"
}
]
},
{
"jsonType": "io.atlasmap.v2.Mapping",
"mappingType": "MAP",
"inputField": [
{
"jsonType": "io.atlasmap.csv.v2.CsvField",
"name": "age",
"path": "/<>/age",
"fieldType": "STRING",
"docId": "target-csv"
}
],
"outputField": [
{
"jsonType": "io.atlasmap.java.v2.JavaField",
"name": "age",
"path": "/age",
"fieldType": "INTEGER",
"docId": "Person"
"docId": "Account"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"dataSource": [
{
"jsonType": "io.atlasmap.v2.DataSource",
"id": "org.apache.camel.quarkus.component.atlasmap.it.model.Person",
"uri": "atlas:java?className=org.apache.camel.quarkus.component.atlasmap.it.model.Person",
"id": "org.apache.camel.quarkus.component.atlasmap.it.model.Account",
"uri": "atlas:java?className=org.apache.camel.quarkus.component.atlasmap.it.model.Account",
"dataSourceType": "SOURCE"
},
{
"jsonType": "io.atlasmap.csv.v2.CsvDataSource",
"id": "Person",
"uri": "atlas:csv:Person",
"id": "Account",
"uri": "atlas:csv:Account",
"dataSourceType": "TARGET"
}
],
Expand All @@ -23,19 +23,19 @@
"inputField": [
{
"jsonType": "io.atlasmap.java.v2.JavaField",
"name": "firstName",
"path": "/firstName",
"name": "id",
"path": "/id",
"fieldType": "STRING",
"docId": "org.apache.camel.quarkus.component.atlasmap.it.model.Person"
"docId": "org.apache.camel.quarkus.component.atlasmap.it.model.Account"
}
],
"outputField": [
{
"jsonType": "io.atlasmap.csv.v2.CsvField",
"name": "firstName",
"path": "/firstName",
"name": "id",
"path": "/id",
"fieldType": "STRING",
"docId": "Person"
"docId": "Account"
}
]
},
Expand All @@ -45,41 +45,19 @@
"inputField": [
{
"jsonType": "io.atlasmap.java.v2.JavaField",
"name": "lastName",
"path": "/lastName",
"name": "userName",
"path": "/userName",
"fieldType": "STRING",
"docId": "org.apache.camel.quarkus.component.atlasmap.it.model.Person"
"docId": "org.apache.camel.quarkus.component.atlasmap.it.model.Account"
}
],
"outputField": [
{
"jsonType": "io.atlasmap.csv.v2.CsvField",
"name": "lastName",
"path": "/lastName",
"name": "userName",
"path": "/userName",
"fieldType": "STRING",
"docId": "Person"
}
]
},
{
"jsonType": "io.atlasmap.v2.Mapping",
"mappingType": "MAP",
"inputField": [
{
"jsonType": "io.atlasmap.java.v2.JavaField",
"name": "age",
"path": "/age",
"fieldType": "INTEGER",
"docId": "org.apache.camel.quarkus.component.atlasmap.it.model.Person"
}
],
"outputField": [
{
"jsonType": "io.atlasmap.csv.v2.CsvField",
"name": "age",
"path": "/age",
"fieldType": "STRING",
"docId": "Person"
"docId": "Account"
}
]
}
Expand Down

0 comments on commit 2fd98f6

Please sign in to comment.