Why does EJB needs two interfaces(Home and Remote Interface)

Showing Answers 1 - 9 of 9 Answers

Nirdosh

  • Mar 29th, 2005
 

Home is to provide Lookup from JNDI while Remote is to provide Object Instantiated

  Was this answer useful?  Yes

Vani

  • Mar 30th, 2005
 

The client cant deal with the bean diirectly. All the client calls are intercepted by the container. This layer of interception is EJBObject. For the container to create EJBObjects , it should know all the business methods of the bean. So the bean provider will have to write a REMOTE INTERFACE with all the beans business methods. 
In distributed envt,we will not know where the EJBObjects are located. So we need HomeObjects which implement the Home Interface to get a handle for EJBObjects

Anbarasan

  • Apr 4th, 2005
 

An indirection can solve almost all the problems in computer science. This is also such a type of problem. In case of only one interface (as in the case of RMI), the client has to maintain all the references of the EJB objects (i.e. remote objects) which will be cumbersome in large distributed environment and requires lot of overhead. Hence to look up the references, a home interface is introduced as an indirection. Each and every client first looks up for the remote object reference in the JNDI tree and then gets the reference. The EJBObject reference is returned to the requesting clilent. And also, in J2EE, we can use the EJBObject reference once created to serve n number of clients.

  Was this answer useful?  Yes

Hari

  • May 9th, 2005
 

Two interfaces are required to seggregate the business methods to be exposed to client and to maintain the life cycle of the bean. 
 
Remote - to expose the business methods to clients 
Home - to maintain the life cycle of the bean.

  Was this answer useful?  Yes

RajeshRokkam

  • Jun 15th, 2005
 

Home Interface--To locate the bean. 
Remote Interface--To expose the business methods of the bean.

  Was this answer useful?  Yes

Priti

  • Sep 3rd, 2005
 

Home interface for the client and the Remote Interface for the container.

  Was this answer useful?  Yes

abhi

  • Nov 12th, 2005
 

Actually Home interface are used as a Factory to get Bean reference. However since the Bean class/object is not available to the client it uses the remote interface to hold the bean reference

  Was this answer useful?  Yes

Viresh

  • Apr 18th, 2006
 

read Mastering EJB3 book An excellent refrence for all ejb enthusiasts but with limited knowledge. its available free at theserverside.com.

  Was this answer useful?  Yes

Nandikonda Laxman

  • Aug 22nd, 2006
 

I would say that the main reason is because there is a clear division of roles and responsibilities between the home and remote interfaces of an EJB.

The home interface allows the client to communicate with the container which is responsible for creating, finding and removing beans. Whereas the remote interface is the way to communicate with the bean that will allow to remotely access to all its methods. Therefore you need two interfaces for two different purposes i.e) home interface to communicate with the container and remote interface to communicate with the bean.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions