Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

CDI, several managed beans of the same type  RSS feed

 
Sergei Zhylinski
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm familiarizing myself with CDI. I've started with the standalone applications. I'm using Jboss Weld for this. I can't really create several beans of the same type. Spring framework in contrast allows to register several beans in XML configuration file of the same type but with different bean names/ids:



After that I'm able to retrieve a bean from the context by its name:



But all the tutorials found in the net devoted to CDI and Weld have similar code example:



Is it possible to create several performers and put them into CDI META-INF/beans.xml file?
 
Sergei Zhylinski
Ranch Hand
Posts: 89
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now I think that no. The beans.xml configuration file is not used to declare beans. It mainly indicates that the archive is a candidate for bean scan. The CDI implementations use only bean scan similar to component scan in Spring. It dosn't assume explicitely registering any of the beans in the config.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!