You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by fm...@apache.org on 2023/10/20 07:37:02 UTC
[camel] 01/02: auto generate META-INF content for DataTypeTransformer
This is an automated email from the ASF dual-hosted git repository.
fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 65ef40c3055aaae0d0a08442e6050c99e6f25327
Author: Croway <fe...@gmail.com>
AuthorDate: Thu Oct 19 15:57:07 2023 +0200
auto generate META-INF content for DataTypeTransformer
---
.../transformer/aws2-s3-application-cloudevents | 2 ++
.../transformer/aws2-s3-application-cloudevents | 18 --------------
.../transformer/application-cloudevents-json | 2 ++
.../transformer/http-application-cloudevents | 2 ++
.../transformer/application-cloudevents-json | 18 --------------
.../transformer/http-application-cloudevents | 18 --------------
.../org/apache/camel/spi/DataTypeTransformer.java | 3 +++
.../datatype/transformer/application-octet-stream | 2 ++
.../apache/camel/datatype/transformer/text-plain | 2 ++
.../datatype/transformer/application-octet-stream | 18 --------------
.../apache/camel/datatype/transformer/plain-text | 18 --------------
.../camel/maven/packaging/SpiGeneratorMojo.java | 28 ++++++++++++++++++----
12 files changed, 37 insertions(+), 94 deletions(-)
diff --git a/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/aws2-s3-application-cloudevents b/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/aws2-s3-application-cloudevents
new file mode 100644
index 00000000000..78f1be83b8c
--- /dev/null
+++ b/components/camel-aws/camel-aws2-s3/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/aws2-s3-application-cloudevents
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.aws2.s3.transform.AWS2S3CloudEventDataTypeTransformer
diff --git a/components/camel-aws/camel-aws2-s3/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/aws2-s3-application-cloudevents b/components/camel-aws/camel-aws2-s3/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/aws2-s3-application-cloudevents
deleted file mode 100644
index ec5793a97f6..00000000000
--- a/components/camel-aws/camel-aws2-s3/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/aws2-s3-application-cloudevents
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.
-#
-
-class=org.apache.camel.component.aws2.s3.transform.AWS2S3CloudEventDataTypeTransformer
diff --git a/components/camel-cloudevents/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/application-cloudevents-json b/components/camel-cloudevents/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/application-cloudevents-json
new file mode 100644
index 00000000000..ce4e00dc859
--- /dev/null
+++ b/components/camel-cloudevents/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/application-cloudevents-json
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.cloudevents.transformer.CloudEventJsonDataTypeTransformer
diff --git a/components/camel-cloudevents/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/http-application-cloudevents b/components/camel-cloudevents/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/http-application-cloudevents
new file mode 100644
index 00000000000..29210d5ee0b
--- /dev/null
+++ b/components/camel-cloudevents/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/http-application-cloudevents
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.cloudevents.transformer.CloudEventHttpDataTypeTransformer
diff --git a/components/camel-cloudevents/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/application-cloudevents-json b/components/camel-cloudevents/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/application-cloudevents-json
deleted file mode 100644
index d380ef770b9..00000000000
--- a/components/camel-cloudevents/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/application-cloudevents-json
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.
-#
-
-class=org.apache.camel.component.cloudevents.transformer.CloudEventJsonDataTypeTransformer
diff --git a/components/camel-cloudevents/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/http-application-cloudevents b/components/camel-cloudevents/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/http-application-cloudevents
deleted file mode 100644
index ca4580b0f73..00000000000
--- a/components/camel-cloudevents/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/http-application-cloudevents
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.
-#
-
-class=org.apache.camel.component.cloudevents.transformer.CloudEventHttpDataTypeTransformer
diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/DataTypeTransformer.java b/core/camel-api/src/main/java/org/apache/camel/spi/DataTypeTransformer.java
index b047ed367bd..062e6754543 100644
--- a/core/camel-api/src/main/java/org/apache/camel/spi/DataTypeTransformer.java
+++ b/core/camel-api/src/main/java/org/apache/camel/spi/DataTypeTransformer.java
@@ -23,6 +23,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.apache.camel.spi.annotations.ServiceFactory;
+
/**
* Annotation to configure a data type transformer with either specifying its name or from/to data types.
* <p/>
@@ -32,6 +34,7 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Target({ ElementType.TYPE })
+@ServiceFactory("transformer")
public @interface DataTypeTransformer {
/**
diff --git a/core/camel-core-processor/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/application-octet-stream b/core/camel-core-processor/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/application-octet-stream
new file mode 100644
index 00000000000..6fa92135ded
--- /dev/null
+++ b/core/camel-core-processor/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/application-octet-stream
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.processor.transformer.ByteArrayDataTypeTransformer
diff --git a/core/camel-core-processor/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/text-plain b/core/camel-core-processor/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/text-plain
new file mode 100644
index 00000000000..6cb700e9c21
--- /dev/null
+++ b/core/camel-core-processor/src/generated/resources/META-INF/services/org/apache/camel/datatype/transformer/text-plain
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.processor.transformer.StringDataTypeTransformer
diff --git a/core/camel-core-processor/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/application-octet-stream b/core/camel-core-processor/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/application-octet-stream
deleted file mode 100644
index 6d209870e44..00000000000
--- a/core/camel-core-processor/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/application-octet-stream
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.
-#
-
-class=org.apache.camel.processor.transformer.ByteArrayDataTypeTransformer
diff --git a/core/camel-core-processor/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/plain-text b/core/camel-core-processor/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/plain-text
deleted file mode 100644
index a2347583375..00000000000
--- a/core/camel-core-processor/src/main/resources/META-INF/services/org/apache/camel/datatype/transformer/plain-text
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# 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.
-#
-
-class=org.apache.camel.processor.transformer.StringDataTypeTransformer
diff --git a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java
index b53ce2b3cd0..085f09204b4 100644
--- a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java
+++ b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpiGeneratorMojo.java
@@ -134,15 +134,29 @@ public class SpiGeneratorMojo extends AbstractGeneratorMojo {
if (!isLocal(className)) {
continue;
}
- String pvals = annotation.value().asString();
+ String pvals;
+ // @DataTypeTransformer uses name instead of value
+ if (annotation.value() == null) {
+ pvals = annotation.values().stream()
+ .filter(annotationValue -> "name".equals(annotationValue.name()))
+ .map(name -> name.value().toString())
+ .findFirst().get();
+ } else {
+ pvals = annotation.value().asString();
+ }
for (String pval : pvals.split(",")) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("# ").append(GENERATED_MSG).append(NL).append("class=").append(className).append(NL);
if (ServiceFactory.JDK_SERVICE.equals(sfa.value().asString())) {
updateResource(resourcesOutputDir.toPath(),
"META-INF/services/org/apache/camel/" + pval,
- "# " + GENERATED_MSG + NL + "class=" + className + NL);
+ sb.toString());
+ } else if ("transformer".equals(sfa.value().asString())) {
+ pval = cleanUpValue(pval);
+ updateResource(resourcesOutputDir.toPath(),
+ "META-INF/services/org/apache/camel/datatype/" + sfa.value().asString() + "/" + pval,
+ sb.toString());
} else {
- StringBuilder sb = new StringBuilder();
- sb.append("# ").append(GENERATED_MSG).append(NL).append("class=").append(className).append(NL);
updateResource(resourcesOutputDir.toPath(),
"META-INF/services/org/apache/camel/" + sfa.value().asString() + "/" + pval,
sb.toString());
@@ -152,6 +166,12 @@ public class SpiGeneratorMojo extends AbstractGeneratorMojo {
}
}
+ private String cleanUpValue(String pval) {
+ return pval
+ .replace(":", "-")
+ .replace("+", "-");
+ }
+
private boolean isLocal(String className) {
Path output = Paths.get(project.getBuild().getOutputDirectory());
Path file = output.resolve(className.replace('.', '/') + ".class");