Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-9313

Resolution of injected beans should consider only beans eligible for injection.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 3.3.0.M3
    • 3.3.0.M2
    • cdi
    • None

    Description

      JSR-299:

      5.2. Typesafe resolution
      A bean is *eligible* for injection to a certain injection point if:
      • it is *available* for injection in the module that contains the class that declares the injection point, and
      • it is assignable to the injection point
      
      5.1.4. Inter-module injection
      A bean is *available* for injection in a certain module if:
      • the bean is not an interceptor or decorator,
      • the bean is enabled,
      • the bean is either not an alternative, or the module is a bean archive and the bean is a selected alternative of the bean
         archive, and
      • the bean class is required to be accessible to classes in the module, according to the class accessibility requirements of
         the module architecture.
      
      2.6. Alternatives
      An alternative is a bean that must be explicitly declared in the beans.xml file if it should be *available* for lookup, injection or EL resolution.
      
      5.1.2. Enabled and disabled beans
      A bean is said to be enabled if:
      • it is deployed in a bean archive, and
      • it is not a producer method or field of a disabled bean, and
      • it is not specialized by any other enabled bean, as defined in Section 4.3, "Specialization", and either
      • it is not an alternative, or it is a selected alternative of at least one bean archive.
      

      That means, that before we resolve ambiguousness, we have to remove from the set of beans, collected by matching type and qualifiers, all unavailable beans:
      (a) decorators and interceptors;
      (b) beans specialized by enabled beans;
      (c) alternatives, not selected in the bean archive that contains the class that declares the injection point;
      (d) producers declared in alternatives, not selected in at least one bean archive.

      For (a) we have a validation rule that warns if an injection is resolved to a decorator; to preserve it, we will have to make sure that injection is both unsatisfied and a decorator is matching it by type and qualifiers. However, now also validation is incorrectly warns about 'multiple beans' if there is one eligible bean plus one matching decorator. Since decorator is never eligible for injection, maybe that warning may be dropped and replaced by 'no eligible bean' in this case.
      In the same way, for (b), now validation incorrectly warns about 'multiple beans' if there is eligible specialized bean and its super class matches the injection; though super class bean is disabled and therefore is not eligible for injection.

      Attachments

        Activity

          People

            scabanovich Viacheslav Kabanovich (Inactive)
            scabanovich Viacheslav Kabanovich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: