views:

23

answers:

1

I wonder, if I can inject a list of (stateless) beans, that all implementing a special interface.

For example I've a module contract

public interface ResetService {
  void reset(MyContext context);
}

Than I've two modules, that are implementing this interface. And one module, that should call all implementations:

@EJBs
private List<ResetService> resetServices;

void resetAllModules(MyContext context) {
  for (ResetService resetService : resetServices)
    resetService.reset(context);
}

It's important that all calls are in the main transaction and the reset caller must be know, if the reset call is complete. So I can't use JMS and topics.

I think, it's not possible, or?

+1  A: 

Not possible with annotations. Your best option here is to loop over an array of JNDI names1 and to do a JNDI lookup for each to feed your List. Just in case, maybe have a look at previous questions like this one if you want to try to make things more dynamic (I'm not convinced it would be a good idea).

Pascal Thivent