users@glassfish.java.net

injecting the collection of EJBs, not the specific one, is that possible?

From: Witold Szczerba <pljosh.mail_at_gmail.com>
Date: Mon, 9 Jul 2007 13:30:47 +0200

Hi there,
I know this question is not Glassfish specific, but Java EE 5 in
general, but I do not know where to ask this: is this possible to use
something like @EJB to inject session bean, but I would like to inject
all the session beans implementing given interface? (not the only
one).
I would like to create session beans implementing something like:

public void process(Operation operation);

I could implement each operation type in separate session bean, then
inject all of them and use like this:
Collection<OperationLocal> operationBeans;
...
Operation someOperation = ....;
for (OperationLocal operationBean : operationBeans) {
   operationBean.process(someOperation);
}

Each implementation could internally check if it is interested in that
operation and ignore it if that is so.

So, is this possible to inject collection of session beans
implementing given interface instead of only one per @EJB annotation?

Thanks,
Witek