4 Replies Latest reply on Jul 9, 2012 3:27 AM by werrenmi

    Inheritance issue in Errai CDI?

    werrenmi

      Hello together

       

      I plan to develop a gwt application with dynamic loading of gui parts. I try to load bean instance with the IOCBeanManager against interfaces with a simple inheritance:

       

      public interface A

      {

      }

      public interface B extends A

      {

      }

       

      @ApplicationScoped

      public class AImpl implements A

      {

      }

       

      @ApplicationScoped

      public class BImpl implements B

      {

      }

       

      Now, when i try to lockup this beans against their interfaces, the bean manager seems to ignore the inheritance after one step:

       

      beanManager.lookupBeans(A.class).size() == 1

      beanManager.lookupBeans(B.class).size() == 1

       

      I found nothing about a definition of this behavior in the documentation and took a look in the source of the IOCBeanManager. There the lookup is done through a Map with one class typing .. thats the answer.

       

      A further problem in this relation is the resolving of injection points:

       

      A Qualifier

       

      @Qualifier

      @Retention( RetentionPolicy.RUNTIME )

      @Target({ElementType.FIELD, ElementType.TYPE})

      public @interface Q

      {

      }

       

      and append it to class B:

       

      @Q

      @ApplicationScoped

      public class BImpl implements B

      {

      }

       

      My entry point class:

       

      @EntryPoint

      public class EntryPoint{

       

           @Inject

           @Q

           private B b;

      }

       

      Then i get the follow compiler error:

       

      [INFO] org.jboss.errai.ioc.rebind.ioc.exception.UnsatisfiedDependenciesException:  @> ch.apkern.ui.client.view.ClientApplication

      [INFO]  - field org.jboss.errai.codegen.meta.MetaField:ch.apkern.ui.client.view.ClientApplication.loginPresenter could not be satisfied for type: ch.apkern.ui.client.view.defaults.presenter.DefaultPresenter

      [ERROR]           at com.google.gwt.dev.Compiler.run(Compiler.java:198)

      [INFO]   Message: ambiguous injection type (multiple injectors resolved): ch.apkern.ui.client.view.defaults.presenter.DefaultPresenter  @Login :

      [INFO]      matching> org.jboss.errai.ioc.rebind.ioc.injector.TypeInjector:ch.apkern.ui.client.view.auth.LoginPresenter  @Login

      [INFO]      matching> org.jboss.errai.ioc.rebind.ioc.injector.TypeInjector:ch.apkern.ui.client.view.patient.PatientListPresenter  @Any

      [INFO]   Note: configure an alternative to take precedence or remove all but one matching bean.

       

       

      But when i append also on class A its own qualifier then it works well.

       

      Is this behavior as expect?