• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

LocalHomes

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
How do you create the session context ctx?
 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Is this the real life? Is this just fantasy? Is this a tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic