mkhudyakov commented on issue #1205:
URL: 
https://github.com/apache/camel-kamelets/issues/1205#issuecomment-1351568973

   I can imagine the mechanism like
   ```
       public static void main(String[] args) throws Exception {
           final KameletMain main = new KameletMain();
           main.configure().setBasePackageScan("com.apache.kamelet.poc");
   
           Map<String, Class> configurations = new HashMap<>();
           main.setDownloadListener(new DownloadListener() {
   
               @Override
               public void onDownloadDependency(String groupId, String 
artifactId, String version) {
                   System.out.println("Downloaded, " + groupId + ":" + 
artifactId + ":" + version);
   
                   Reflections reflections = new 
Reflections("com.apache.kamelet.poc");
                   Set<Class<?>> classes = 
reflections.getTypesAnnotatedWith(Configuration.class);
   
                   for (Class clazz: classes) {
                       addConfiguration(configurations, clazz, main);
                   }
               }
   
               @Override
               public void onAlreadyDownloadedDependency(String groupId, String 
artifactId, String version) {
                   System.out.println("Already downloaded, " + groupId + ":" + 
artifactId + ":" + version);
   
                   Reflections reflections = new 
Reflections("com.apache.kamelet.poc");
                   Set<Class<?>> classes = 
reflections.getTypesAnnotatedWith(Configuration.class);
   
                   for (Class clazz: classes) {
                       addConfiguration(configurations, clazz, main);
                   }
               }
           });
   
           main.run(args);
       }
   
       private static void addConfiguration(Map<String, Class> configurations, 
Class clazz, KameletMain main) {
           if (configurations.get(clazz.getCanonicalName()) != null) {
               System.out.println(clazz.getCanonicalName() + " already 
registered");
               return;
           } else {
               configurations.put(clazz.getCanonicalName(), clazz);
           }
   
           try {
               main.configure().addConfiguration((CamelConfiguration) 
clazz.newInstance());
           } catch (Exception e) {
               e.printStackTrace();
           }
       }
   ```
   as the downloading happens before the Kametet runs, but the question is how 
to force `KameletMain` start accounting for configurations?
   
   The line
   ```
               main.configure().addConfiguration((CamelConfiguration) 
clazz.newInstance());
   ```
   doesn't have an effect


-- 
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-unsubscr...@camel.apache.org

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

Reply via email to