users@glassfish.java.net

Getting one EJB within another EJB

From: Thorsten Jungblut <ulli_at_netcorner.org>
Date: Tue, 5 Jun 2007 12:59:35 +0200 (CEST)

Hi,

i got a simple problem:

I got an interface:

public interface SomeInterface {
        public void doIt();
}


and two beans with local interfaces:


@Local
public interface SomeBean1Local extends SomeInterface {
}

@Local
public interface SomeBean2Local extends SomeInterface {
}

@Stateful
public SomeBean1 implements SomeBean1Local {
...
}

@Stateful
public SomeBean2 implements SomeBean2Local {
...
}


Within the same application, i got a third bean that has to use one of the
other beans but i do want to use polymorphism.

Simply using a field annotated with @EJB is no option here since i would
have to decide what concrete class to use.

Is there a way to get an instance of a bean by using JNDI?

Best regards
T.Jungblut