I�m kinda new to EJB 2.0 and I�m trying to figure out what to do with my LocalHomes. I�m trying to implement the facade pattern. Should my SessionBean explicitly cast to LocalHome or is this sopposed to be done by the container ei Object o = ctx.lookup("MyBean"); Home aHome = (MyBeanHome)PortableRemoteObject.narrow(o, MyBeanHome.class); or: Object o = ctx.lookup("MyBean"); Home aHome = (MyBeanLocalHome)PortableRemoteObject.narrow(o, MyBeanLocalHome.class);
Hello Sven, Either you or the container does the job of casting, it ultimately has to be casted to the same home interface. I fail to see the difference here(Or maybe i am missing something here).Can you be a little more specific on what exactly you have in mind? thanks, Manjunath
Hi sven, great to see you around. Unlike the remote client view, the local client view of a bean is not location independent. Access to an enterprise bean through the local client view requires the collocation in the same JVM of both the local client and the enterprise bean that provides the local client view. The local client view therefore does not provide the location transparency provided by the remote client view. A local client accesses a session or an entity bean through the bean�s local interface and local home interface. The container provides classes that implement the bean�s local and local home interfaces. The objects that implement the local home interface and local interface are local Java objects. ex: remote: public interface CartHome extends javax.ejb.EJBHome local: public interface CartHome extends javax.ejb.EJBLocalHome remote client: Context initialContext = new InitialContext(); CartHome cartHome = (CartHome)javax.rmi.PortableRemoteObject.narrow( initialContext.lookup(�java:comp/env/ejb/cart�), CartHome.class); If CartHome were a local home interface instead of a remote home interface, this lookup might be as follows: Context initialContext = new InitialContext(); CartHome cartHome = (CartHome) initialContext.lookup(�java:comp/env/ejb/cart�);
You can find a lot more information about it at chapter 5 and 6 from the EJB2.0 specification. regards.
[This message has been edited by Marcos Maia (edited August 22, 2001).]
Run away! Run away! Here, take this tiny ad with you: