In that case just define two local EJB dependencies, one for each target bean. E.g., place
the following at the class-level of the component within which you need to do the lookup :
@EJBs( {
@EJB(name="bean1ref", beanName="SomeBean1", beanInterface=SomeBean1Local.class),
@EJB(name="bean2ref", beanName="SomeBean2", beanInterface=SomeBean2Local.class)
})
Then, just retrieve the appropriate dependency using a component environment lookup :
...
private SomeInterface someBean;
InitialContext ic = new InitialContext();
String targetBeanDepName = whichBean ? "bean1Ref" : "bean2Ref";
someBean = (SomeInterface) ic.lookup("java:comp/env/" + targetBeanDepName);
[Message sent by forum member 'ksak' (ksak)]
http://forums.java.net/jive/thread.jspa?messageID=220643