ppalaga commented on a change in pull request #2560:
URL: https://github.com/apache/camel-quarkus/pull/2560#discussion_r629430440



##########
File path: 
extensions-core/core/runtime/src/main/java/org/apache/camel/quarkus/core/StaticAnnotationTypeConverterLoader.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.core;
+
+import java.util.Set;
+
+import org.apache.camel.impl.converter.AnnotationTypeConverterLoader;
+import org.apache.camel.spi.TypeConverterRegistry;
+
+public class StaticAnnotationTypeConverterLoader extends 
AnnotationTypeConverterLoader {
+
+    private static StaticAnnotationTypeConverterLoader INSTANCE = new 
StaticAnnotationTypeConverterLoader();
+
+    public static StaticAnnotationTypeConverterLoader getInstance() {
+        return INSTANCE;
+    }

Review comment:
       Another nitpick: Do we really need the singleton? It seems to be used 
only once. I mean we could replace 
`StaticAnnotationTypeConverterLoader.getInstance()` with simply `new 
StaticAnnotationTypeConverterLoader()`. It would be less code doing the same 
thing.

##########
File path: 
extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java
##########
@@ -248,6 +251,28 @@ CamelTypeConverterRegistryBuildItem typeConverterRegistry(
             }
         }
 
+        Set<String> internalConverters = new HashSet<>();
+        //ignore all @converters from org.apache.camel:camel-* dependencies
+        for (ApplicationArchive archive : 
applicationArchives.getAllApplicationArchives()) {
+            if (archive.getArtifactKey() != null && 
"org.apache.camel".equals(archive.getArtifactKey().getGroupId())
+                    && 
archive.getArtifactKey().getArtifactId().startsWith("camel-")) {
+                
internalConverters.addAll(archive.getIndex().getAnnotations(DotName.createSimple(Converter.class.getName()))
+                        .stream().filter(a -> a.target().kind() == 
AnnotationTarget.Kind.CLASS)
+                        .map(a -> a.target().asClass().name().toString())
+                        .collect(Collectors.toSet()));
+            }
+        }
+
+        Set<Class> convertersClasses = index

Review comment:
       ```suggestion
           Set<Class<?>> convertersClasses = index
   ```
   would eliminate some compiler warnings

##########
File path: 
extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelProcessor.java
##########
@@ -248,6 +251,28 @@ CamelTypeConverterRegistryBuildItem typeConverterRegistry(
             }
         }
 
+        Set<String> internalConverters = new HashSet<>();
+        //ignore all @converters from org.apache.camel:camel-* dependencies
+        for (ApplicationArchive archive : 
applicationArchives.getAllApplicationArchives()) {
+            if (archive.getArtifactKey() != null && 
"org.apache.camel".equals(archive.getArtifactKey().getGroupId())
+                    && 
archive.getArtifactKey().getArtifactId().startsWith("camel-")) {
+                
internalConverters.addAll(archive.getIndex().getAnnotations(DotName.createSimple(Converter.class.getName()))
+                        .stream().filter(a -> a.target().kind() == 
AnnotationTarget.Kind.CLASS)
+                        .map(a -> a.target().asClass().name().toString())
+                        .collect(Collectors.toSet()));

Review comment:
       Nitpick: this would eliminate creating as many sets as there are app 
archives:
   ```suggestion
                   
archive.getIndex().getAnnotations(DotName.createSimple(Converter.class.getName()))
                           .stream().filter(a -> a.target().kind() == 
AnnotationTarget.Kind.CLASS)
                           .map(a -> a.target().asClass().name().toString())
                           .forEach(internalConverters::add);
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to