Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

LocalHomes

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
richard marais
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
How do you create the session context ctx?
 
Manjunath Subramanian
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!