davsclaus commented on a change in pull request #5530:
URL: https://github.com/apache/camel/pull/5530#discussion_r630107165



##########
File path: 
components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletComponent.java
##########
@@ -348,19 +362,36 @@ public LifecycleHandler() {
             this.initialized = new AtomicBoolean();
         }
 
-        public static void createRouteForEndpoint(KameletEndpoint endpoint) 
throws Exception {
-            LOGGER.debug("Creating route from template={} and id={}", 
endpoint.getTemplateId(), endpoint.getRouteId());
+        public void createRouteForEndpoint(KameletEndpoint endpoint) throws 
Exception {
+            final ExtendedCamelContext ecc = 
getCamelContext().adapt(ExtendedCamelContext.class);
+            final ModelCamelContext context = 
getCamelContext().adapt(ModelCamelContext.class);
+            final String templateId = endpoint.getTemplateId();
+            final String routeId = endpoint.getRouteId();
+
+            if (context.getRouteTemplateDefinition(templateId) == null) {
+                LOGGER.debug("Loading route template={} from {}", templateId, 
getLocation());
+
+                String path = getLocation();
+                if (path != null) {
+                    if (!path.endsWith("/")) {
+                        path += "/";
+                    }
+
+                    ecc.getRoutesLoader().loadRoutes(
+                            ecc.getResourceLoader().resolveResource(path + 
templateId + ".kamelet.yaml"));

Review comment:
       I think we may need a blurb in the documentation (somewhere) about the 
convention to use templateId.kamelet.yaml as the default file pattern for 
loading kamelets.

##########
File path: 
components/camel-kamelet/src/main/java/org/apache/camel/component/kamelet/KameletComponent.java
##########
@@ -73,6 +74,8 @@
     private Map<String, Properties> templateProperties;
     @Metadata
     private Map<String, Properties> routeProperties;
+    @Metadata(defaultValue = "classpath:/kamelets")

Review comment:
       Maybe this should use the DEFAULT_LOCATION constant




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