Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / August 2004

Tip: Looking for answers? Try searching our database.

How do I reference a Local Home interface?

Thread view: 
David - 02 Aug 2004 17:21 GMT
I am struggling to understand EJBs, basically I have got an EJB called
Stateless2 and the following source files...

Stateless2Bean.java (the actual EJB)
Stateless2.java (EJBObject)
Stateless2Home.java (EJBHome)
Stateless2Local.java (EJBLocalObject)
Stateless2LocalHome.java (EJBLocalHome)

...now I understand I can just do a JNDI lookup for the EJBHome
(ejb/Stateless2Home) and I get the (remote) home interface and then
call the create() to get the (remote) object interface (ie with the
business logic methods)

This all works fine, but if my understanding is correct then all calls
to these objects go to the network layer (even if the EJB and servlet
are in the same JVM) and so are relatively inefficient.

...thats where the (local) Home and (local) object interfaces comes
in, they work in the same way, but make local calls and so are more
efficient.

The problem is that I cant figure out how to call them! Do I just do a
JNDI lookup for it, if so then what is the reference?

I have lauched the Universal Test client (in WSAD) and can browse the
JNDI tree and see ejb/Stateless2Home etc, I can also so a section
called [local EJB Beans] which expands to ejb/Stateless2Home which if
a look into it this is actually the (local) Home, but I cant figure
out what the JNDI name is?

Any help grately appreciated.

David Bevan

http://www.davidbevan.co.uk
http://www.websphereusergroup.org.uk
John C. Bollinger - 03 Aug 2004 15:19 GMT
> I am struggling to understand EJBs, basically I have got an EJB called
> Stateless2 and the following source files...
[quoted text clipped - 13 lines]
> to these objects go to the network layer (even if the EJB and servlet
> are in the same JVM) and so are relatively inefficient.

They may or may not actually go to the network layer, but they do obey
the semantics for remote method invocations.  Among other things, those
semantics involve creating copies of all the outbound arguments and the
inbound return values.

> ...thats where the (local) Home and (local) object interfaces comes
> in, they work in the same way, but make local calls and so are more
> efficient.

As you say, local method invocations are more efficient in every J2EE
implementation I have any knowledge of.  This is in part because they
have standard Java method invocation semantics (specifically, reference
passing semantics).

> The problem is that I cant figure out how to call them! Do I just do a
> JNDI lookup for it, if so then what is the reference?

You do a JNDI lookup for the EJBLocalHome object, and use it to obtain
an EJBLocalObject instance.  This works very much the same as a remote
EJB lookup, although you are not required to use
PortableRemoteObject.narrow() on the EJB instance (but you may do if you
want to).  The JNDI name to which the local home object is bound is
configured with the rest of the bean's deployment information, much the
same way that the name of the [remote] home object is configured.

John Bollinger
jobollin@indiana.edu
Henrik Sjostrand - 03 Aug 2004 21:53 GMT
> > I am struggling to understand EJBs, basically I have got an EJB called
> > Stateless2 and the following source files...

[snip]

> > The problem is that I cant figure out how to call them! Do I just do a
> > JNDI lookup for it, if so then what is the reference?
[quoted text clipped - 9 lines]
> John Bollinger
> jobollin@indiana.edu

You need to set up an EJB reference to find your EJB's Local Home
Interfaces. Take a look in the EJB 2.0 Redbook for details on how to
do it (it's easy!):
http://publib-b.boulder.ibm.com/Redbooks.nsf/RedbookAbstracts/sg246819.html?Open

/Henrik Sjöstrand


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.