3 Replies Latest reply on May 6, 2009 9:22 AM by Nicklas Karlsson

    multiple @Produces for same return type

    Arbi Sookazian Master

      Ok, so I'm a newbie here (I wish there was a Seam --> Web Beans transition book).

      Consider the following from the Web Beans spec:

      @SessionScoped @Model
      public class Login {
      @Produces @LoggedIn User getCurrentUser() {
      if (user==null) {
      throw new NotLoggedInException();
      else {
      return user;

      public class DocumentEditor {
      @Current Document document;
      @LoggedIn User user;
      @PersistenceContext EntityManager docDatabase;

      Ok, so what happens if there is another Web Bean component, that has the following method:

      @Produces @LoggedIn User getMyUser() {...}

      So which method will get called by the Web Beans manager?

      As per spec:

      The method annotated @Produces is a producer method, which
      will be called whenever another Web Bean in the system needs the currently logged-in user.