Such simple question but I can't find the answer in google. I have two osgi bundles on glassfish4:
- Bundle1 - Servlet
- Bundle2 - MyEJB1, MyEJB2. Both EJB are local, stateless, implements the same interface (MyLocalInterface) and every has its own name.
In servlet I inject EJB like this:
@Inject @OSGiService (dynamic = true)
private MyLocalInterface ejb;
How can I distinguish via names these two EJB for injection? As I think I should use serviceCriteria in @OSGiService but how?
EDIT:
I have a lot of osgi services (not ejb, simple osgi services) with the same interface. To distinguish them I use
@Inject @OSGiService(dynamic=true, serviceCriteria = "(component.name=com.bla.bla)").
The same I need for ejb.
EDIT2:
Up to now the only way I've found is to use jndi-name as both cdi beans are EJB:
@Inject @OSGiService(dynamic=true, serviceCriteria = "(jndi-name=java:global/....)").
Be careful! It won't work without "()"! But this solution could be much better if we solve this question: Glassfish 4: how to set application or module name for JNDI