Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt on EJB home

 
Ravi Bansal
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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???
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34071
331
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi,
This approach allows the container to do work for you like pooling. It also facilitates creating beans with different constructor params.
 
Ravi Bansal
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic