Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-930

Producer is made an alternative if the declaring bean class is an alternative

    XMLWordPrintable

Details

    Description

      I'm looking at examples from https://github.com/pmuir/jboss-as-developer-guide/tree/master/quickstarts

      There is org.jboss.as.quickstarts.login.EJBUserManager:

      org.jboss.as.quickstarts.login.EJBUserManager
      ...
      @Named("userManager")
      @RequestScoped
      @Alternative
      @Stateful
      public class EJBUserManager implements UserManager {
      ...
          @Produces
          @Named
          @RequestScoped
          public List<User> getUsers() throws Exception {
              ...
          }
      ...
      }
      

      And there is also another bean org.jboss.as.quickstarts.login.ManagedBeanUserManager:

      org.jboss.as.quickstarts.login.ManagedBeanUserManager
      ...
      @Named("userManager")
      @RequestScoped
      public class ManagedBeanUserManager implements UserManager {
      
         @SuppressWarnings("unchecked")
         @Produces
         @Named
         @RequestScoped
         public List<User> getUsers() throws Exception {
             ...
         }
      ...
      }
      

      This code works in Weld even if EJBUserManager.getUsers() is not annotated @Alternative. But regarding the spec such a method has an ambiguous EL name "users":

      5.3.1. Ambiguous EL names
      An ambiguous EL name exists in an EL expression when an EL name resolves to multiple beans. When an ambiguous EL
      name exists, the container attempts to resolve the ambiguity. If any of the beans are alternatives, the container eliminates
      all beans that are not alternatives, except for producer methods and fields of beans that are alternatives. If there is exactly
      one bean remaining, the container will select this bean, and the ambiguous EL name is called resolvable.

      There is a comment from Pete Muir:

      This looks to me like a bug in Weld (one that crept in from a pre-final spec revision) - that it checks if the declaring bean class is an alternative, and if it is, makes the producer an alternative. Can you file a WELD issue for this? I'll update the quickstart to explicitly make the producer an alternative.

      Pete

      Attachments

        Issue Links

          Activity

            People

              marko.luksa@gmail.com Marko Luksa (Inactive)
              alexeykazakov Alexey Kazakov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: