Skip to content

Commit d9e5475

Browse files
committed
CAMEL-22361: camel-groovy-xml - Add data format that uses groovy xml that is easy to use and no need for POJOs
1 parent e77b80e commit d9e5475

12 files changed

Lines changed: 460 additions & 0 deletions

File tree

catalog/camel-catalog-provider-springboot/src/main/resources/org/apache/camel/springboot/catalog/dataformats.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fhirXml
1717
flatpack
1818
fory
1919
grok
20+
groovyXml
2021
gson
2122
gzipDeflater
2223
hl7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"dataformat": {
3+
"kind": "dataformat",
4+
"name": "groovyXml",
5+
"title": "Groovy XML",
6+
"description": "Transform between XML and Java Map via Groovy",
7+
"deprecated": false,
8+
"firstVersion": "4.15.0",
9+
"label": "dataformat,transformation,xml",
10+
"javaType": "org.apache.camel.groovy.xml.GroovyXmlDataFormat",
11+
"supportLevel": "Preview",
12+
"groupId": "org.apache.camel.springboot",
13+
"artifactId": "camel-groovy-xml-starter",
14+
"version": "4.15.0-SNAPSHOT",
15+
"modelName": "groovyXml",
16+
"modelJavaType": "org.apache.camel.model.dataformat.GroovyXmlDataFormat"
17+
},
18+
"properties": {
19+
"id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" }
20+
}
21+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<parent>
23+
<groupId>org.apache.camel.springboot</groupId>
24+
<artifactId>components-starter</artifactId>
25+
<version>4.15.0-SNAPSHOT</version>
26+
</parent>
27+
<artifactId>camel-groovy-xml-starter</artifactId>
28+
<packaging>jar</packaging>
29+
<name>Camel SB Starters :: groovy-xml</name>
30+
<dependencies>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter</artifactId>
34+
<version>${spring-boot-version}</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.apache.camel</groupId>
38+
<artifactId>camel-groovy-xml</artifactId>
39+
<version>${camel-version}</version>
40+
</dependency>
41+
<!--START OF GENERATED CODE-->
42+
<dependency>
43+
<groupId>org.apache.camel.springboot</groupId>
44+
<artifactId>camel-core-starter</artifactId>
45+
</dependency>
46+
<!--END OF GENERATED CODE-->
47+
</dependencies>
48+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"groups": [
3+
{
4+
"name": "camel.dataformat.groovy-xml",
5+
"type": "org.apache.camel.groovy.xml.springboot.GroovyXmlDataFormatConfiguration",
6+
"sourceType": "org.apache.camel.groovy.xml.springboot.GroovyXmlDataFormatConfiguration"
7+
},
8+
{
9+
"name": "camel.dataformat.groovy-xml.customizer",
10+
"type": "org.apache.camel.spring.boot.DataFormatConfigurationPropertiesCommon$CustomizerProperties",
11+
"sourceType": "org.apache.camel.groovy.xml.springboot.GroovyXmlDataFormatConfiguration",
12+
"sourceMethod": "getCustomizer()"
13+
}
14+
],
15+
"properties": [
16+
{
17+
"name": "camel.dataformat.groovy-xml.customizer.enabled",
18+
"type": "java.lang.Boolean",
19+
"sourceType": "org.apache.camel.spring.boot.DataFormatConfigurationPropertiesCommon$CustomizerProperties"
20+
},
21+
{
22+
"name": "camel.dataformat.groovy-xml.enabled",
23+
"type": "java.lang.Boolean",
24+
"description": "Whether to enable auto configuration of the groovyXml data format. This is enabled by default.",
25+
"sourceType": "org.apache.camel.groovy.xml.springboot.GroovyXmlDataFormatConfiguration"
26+
}
27+
],
28+
"hints": [],
29+
"ignored": {
30+
"properties": []
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.groovy.xml.springboot;
18+
19+
import org.apache.camel.CamelContext;
20+
import org.apache.camel.groovy.xml.GroovyXmlDataFormat;
21+
import org.apache.camel.spi.DataFormat;
22+
import org.apache.camel.spi.DataFormatCustomizer;
23+
import org.apache.camel.spring.boot.CamelAutoConfiguration;
24+
import org.apache.camel.spring.boot.DataFormatConfigurationProperties;
25+
import org.apache.camel.spring.boot.util.CamelPropertiesHelper;
26+
import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans;
27+
import org.apache.camel.spring.boot.util.ConditionalOnHierarchicalProperties;
28+
import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator;
29+
import org.springframework.beans.factory.annotation.Autowired;
30+
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
31+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
32+
import org.springframework.boot.convert.ApplicationConversionService;
33+
import org.springframework.context.ApplicationContext;
34+
import org.springframework.context.annotation.Bean;
35+
import org.springframework.context.annotation.Conditional;
36+
import org.springframework.context.annotation.Configuration;
37+
import org.springframework.context.annotation.Lazy;
38+
39+
/**
40+
* Generated by camel-package-maven-plugin - do not edit this file!
41+
*/
42+
@Configuration(proxyBeanMethods = false)
43+
@AutoConfigureAfter(CamelAutoConfiguration.class)
44+
@Conditional(ConditionalOnCamelContextAndAutoConfigurationBeans.class)
45+
@EnableConfigurationProperties({DataFormatConfigurationProperties.class,GroovyXmlDataFormatConfiguration.class})
46+
@ConditionalOnHierarchicalProperties({"camel.dataformat", "camel.dataformat.groovy-xml"})
47+
public class GroovyXmlDataFormatAutoConfiguration {
48+
49+
@Autowired
50+
private ApplicationContext applicationContext;
51+
private final CamelContext camelContext;
52+
@Autowired
53+
private GroovyXmlDataFormatConfiguration configuration;
54+
55+
public GroovyXmlDataFormatAutoConfiguration(
56+
org.apache.camel.CamelContext camelContext) {
57+
this.camelContext = camelContext;
58+
}
59+
60+
@Lazy
61+
@Bean
62+
public DataFormatCustomizer configureGroovyXmlDataFormatFactory() {
63+
return new DataFormatCustomizer() {
64+
@Override
65+
public void configure(String name, DataFormat target) {
66+
CamelPropertiesHelper.copyProperties(camelContext, configuration, target);
67+
}
68+
@Override
69+
public boolean isEnabled(String name, DataFormat target) {
70+
return HierarchicalPropertiesEvaluator.evaluate(
71+
applicationContext,
72+
"camel.dataformat.customizer",
73+
"camel.dataformat.groovy-xml.customizer")
74+
&& target instanceof GroovyXmlDataFormat;
75+
}
76+
};
77+
}
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.camel.groovy.xml.springboot;
18+
19+
import org.apache.camel.spring.boot.DataFormatConfigurationPropertiesCommon;
20+
import org.springframework.boot.context.properties.ConfigurationProperties;
21+
22+
/**
23+
* Transform between XML and Java Map via Groovy
24+
*
25+
* Generated by camel-package-maven-plugin - do not edit this file!
26+
*/
27+
@ConfigurationProperties(prefix = "camel.dataformat.groovy-xml")
28+
public class GroovyXmlDataFormatConfiguration
29+
extends
30+
DataFormatConfigurationPropertiesCommon {
31+
32+
/**
33+
* Whether to enable auto configuration of the groovyXml data format. This
34+
* is enabled by default.
35+
*/
36+
private Boolean enabled;
37+
}

0 commit comments

Comments
 (0)