You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "davsclaus (via GitHub)" <gi...@apache.org> on 2023/06/06 12:58:55 UTC

[GitHub] [camel] davsclaus commented on a diff in pull request #10268: [CAMEL-18189] Read from XML files (camel-xml-io) and p…

davsclaus commented on code in PR #10268:
URL: https://github.com/apache/camel/pull/10268#discussion_r1219601027


##########
dsl/camel-xml-io-dsl/src/main/java/org/apache/camel/dsl/xml/io/XmlRoutesBuilderLoader.java:
##########
@@ -236,4 +215,93 @@ private void addConfigurations(RouteConfigurationsDefinition configurations) {
             }
         };
     }
+
+    @Override
+    protected void doStop() throws Exception {
+        resourceCache.clear();
+        xmlInfoCache.clear();
+    }
+
+    private Resource resource(Resource resource) {
+        return resourceCache.computeIfAbsent(resource.getLocation(), l -> new CachedResource(resource));
+    }
+
+    private XmlStreamInfo xmlInfo(Resource resource) {
+        return xmlInfoCache.computeIfAbsent(resource.getLocation(), l -> {
+            try {
+                // instead of parsing the document NxM times (for each namespace x root element combination),
+                // we preparse it using XmlStreamDetector and then parse it fully knowing what's inside.
+                // we could even do better, by passing already preparsed information through config file, but
+                // it's getting complicated when using multiple files.
+                XmlStreamDetector detector = new XmlStreamDetector(resource.getInputStream());
+                return detector.information();
+            } catch (IOException e) {
+                XmlStreamInfo invalid = new XmlStreamInfo();
+                invalid.setProblem(e);
+                return invalid;
+            }
+        });
+    }
+
+    private void registerBeans(Resource resource, BeansDefinition app) {
+        // <component-scan> - discover and register beans directly with Camel injection
+        List<String> packagesToScan = new ArrayList<>();

Review Comment:
   I wonder if this should be a Set to avoid potential duplicate package names 



##########
core/camel-core-model/src/main/java/org/apache/camel/model/app/BeansDefinition.java:
##########
@@ -75,7 +75,8 @@ public class BeansDefinition {
 
     // this is the only way I found to generate usable Schema without imports, while allowing elements
     // from different namespaces
-    @ExternalSchemaElement(names = { "bean", "alias" }, namespace = "http://www.springframework.org/schema/beans",
+    @ExternalSchemaElement(names = { "beans", "bean", "alias" },

Review Comment:
   What does alias do here?



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org