Am Dienstag, 5. Juni 2007 12:59 schrieb Thorsten Jungblut:
> 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 {
> ...
> }
I would try it with an SomeInterface-Variable and a manual lookup. That's more
or less the way you would do it in EJB 2.1. I am not sure, but I think the
following should work if you put in the right JNDI name:
@Stateful
public Bean3 ... {
SomeInterface bean;
public void init() {
if (bean1_needed) {
try {
javax.naming.Context c = new javax.naming.InitialContext();
bean = (SomeInterface) c.lookup("SomeBean1Local");
} catch(javax.naming.NamingException ne) {
java.util.logging.Logger.getLogger(
getClass().getName()).log(java.util.logging.Level.SEVERE,
"exception caught" ,ne);
throw new RuntimeException(ne);
}
}
else {
try {
javax.naming.Context c = new javax.naming.InitialContext();
bean = (SomeInterface) c.lookup("SomeBean1Local");
} catch(javax.naming.NamingException ne) {
java.util.logging.Logger.getLogger(
getClass().getName()).log(java.util.logging.Level.SEVERE,
"exception caught" ,ne);
throw new RuntimeException(ne);
}
}
}
}
tschau
Sascha Effert
fermat_at_douglas2a.de
Tel.:(0177) 6266652
--
Being evil means it can be christmas every day.