8 Replies Latest reply on Oct 25, 2010 2:10 AM by B Bozhanov

    Inject a List of objects in CDI (Weld)

    B Bozhanov Newbie

      Let's say I have an interface called SocialNetworkService, and three implementations - TwitterService, FacebookService and FriendFeedService.

      Now I want, whenever my managed bean (or whatever web component) receives a message, to share it in all social networks. I tried:

      private List<SocialNetworkService> socialNetworkServices;

      But it didn't work. (Also tried to the @Any qualifier - same result)

      So, is there a way to inject a list of all (or some) implementations of an interface?

      I know the rule that a given injection point should not have more than one possible bean.
      I guess I can achieve that by making a producer that produces the list, and using Instance<SocialNetworkService>, but that seems like too much for this task.