This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Doubt on EJB home Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Doubt on EJB home" Watch "Doubt on EJB home" New topic
Author

Doubt on EJB home

Ravi Bansal
Ranch Hand

Joined: Aug 18, 2008
Posts: 86
Hi Guys,
i have just stared to understand the EJB architecture. and what i gained is that whole idea of Home interface is to create/instantiate the bean(stateful) , EJBObject and give back the stub of EJBObject to the client , so that client can make a call on business methods using that stub.

My question is why we need home interface at all? why cant it be designed with just one interface(EJBObject) , we can register that object of interface with JNDI and client can look up ,get the stub of EJBObject from JNDI and then that stub can be used to create/instantiate the beans with the help of services from container???


SCJP 5.0 94%
OCE-EJBD 90%
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32507
    
214

Ravi,
This approach allows the container to do work for you like pooling. It also facilitates creating beans with different constructor params.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Ravi Bansal
Ranch Hand

Joined: Aug 18, 2008
Posts: 86
Jeanne , thanks for reply.......but i did not understand your point completely....can you elaborate a little more , why cant container still do the job of pooling and any other services(creating beans with different constructors)......what i want to understand if we remove the call to get the home(EJBHome) from JNDI and get the EJBObject from JNDI directly, how this will impact ??
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
The purpose of the home object is to create the bean object in the container.

The purpose of the interface object is to allow client objects to call the methods of the bean object (in the container.)

If you remove the call to the home object and never create the bean in the container, then you will not be able to get the interface object from the JNDI namespace because it will not exist.
[ December 25, 2008: Message edited by: James Clark ]
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Doubt on EJB home
 
It's not a secret anymore!