lburgazzoli opened a new issue #147: Initialization ordering
URL: https://github.com/apache/camel-quarkus/issues/147
 
 
   I have a component that tries to lookup a reference to a bean from the 
registry - thus from ArC - as following:
   
   ```java
   @Override
   protected void doInit() throws Exception {
       super.doInit();
   
       if (this.vertx == null) {
           Set<Vertx> instances = 
getCamelContext().getRegistry().findByType(Vertx.class);
           if (instances.size() == 1) {
               this.vertx = instances.iterator().next();
   
               if (this.vertx != null) {
                   LOGGER.info("Found Vert.x instance in registry: {}", 
this.vertx);
               }
           }
       }
   }
   ```
   
   and it turn out that ArC could find a bean of the given type but fails to 
resolve the reference so `findByType` returns a collection with a single 
element as expected but then the element is null.
   
   This happens because the lookup method inside the came registry happens 
before the Vertx producer is properly initialized. 
   
   As initializing components from bean auto-discovered from registry is quite 
a common an powerful feature we need a better way to deal with dependencies, 
maybe we should not automatically populate the registry with 
components/languages/dataformat  but we need to delegate this top actual 
component extension that can properly set-up dependencies on other extensions.
   
   //cc @gnodet @davsclaus 
   

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


With regards,
Apache Git Services

Reply via email to