• Post Reply Bookmark Topic Watch Topic
  • New Topic

Injecting all EJB implementations of an interface?  RSS feed

Lars Clausen
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a couple places in our code where we want to EJB inject all beans that implement a specific interface. So far, we've done a horrible post-processing hack using byte-code manipulation to add the EJBs after compilation, but it fails when we try to use JRebel - and is pretty nasty to begin with. The only alternative we've found so far is to inject each implementation explicitly, but that means that anybody who implements it will have to remember to update that list.

In terms of code, what we would like to do (and currently hack around to do) is:

@Stateless(name = "AsyncEventTask")
public class AsyncEventTask extends AbstractScheduledTask implements ScheduledTask {

@EJBCollection(beanInterface = AsyncEventHandler.class)
private Collection<AsyncEventHandler> handlers;


Here, the handlers field should be populated with all implementations of AsyncEventHandler.

Is there any way within the EJB3 spec to do this?

Thanks in advance,
-Lars Clausen
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!