Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why we need home and remote interfaces in EJB?

 
Kunaal A Trehan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I would like to know why we have home and remote interfaces in EJB.
Can't we achieve the same functionality with a single class?

Is there a particular reason why these interfaces were introduced in EJB.

Cheers
Kunal
 
Claude Moore
Ranch Hand
Posts: 832
7
IBM DB2 Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

you're right. If you go and visit SUN web site, you'll see that EJB 3.0 specification (next to come..) will reduce a lot the complexity in creation, lookup, and deploy of EJBs.

Best regards,

Claude.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kunal,


I would like to know why we have home and remote interfaces in EJB.
Can't we achieve the same functionality with a single class?

A short fast answer would be �because J2EE is silly� or maybe �because J2EE specifications were written by people that are brilliant technical minds but they lack simplicity, flexibility and easy marketing going�. However the reason, the original idea was that the home interface is kind of object creation factory. Imagine the container that needs to pool all these bean instances. Now you have to connect your clients to one of them. Obviously your client needs a way to identify an instance in the pool. A single unique RMI interface won�t going to help. Look at the RMI for example: there is the server and the client that implements the same interface, the server listens at a specified port number, etc. No instance pooling in this case, just a many-to-one relationship between the clients and the server component. Well ejb wants to improve this concept and therefore introduced the instance pooling and home interfaces. The real question actually is: did it improve that much by using bean instance pooling? A closer look, deeper analyzes and basic profiling tools might show and prove that it actually didn�t.
Regards.
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Kunal Verma:
Can't we achieve the same functionality with a single class?


Ofcourse, you can. You can also, go ahead and write a complex application with a single class. But isn't it better to split up things based on their responsibilities?
The home interface, is used to interact with the container (creating bean, locating etc), where as the remote interface is used to interact with the bean . As you can see, the roles they play are different, and hence they are seperate.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!