Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why we need home interface in EJB 2.0  RSS feed

 
ajse ruku
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I cant understand why we need a home interface?

As we receive home interface using JNDI and then get EJBObject and then call our business methods......Can we get EJBObject using JNDI and then call business the method?

regards,
Ajse
 
Sandeep Deb
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The home interface is something behind which the container can plug in the barricade of features by creating stubs. When you get a reference to the home interface, in effect you are getting a reference to a container generated stub which in turn delegates your call to the EJBObject implementation.

By calling the EJBObject directly you loose on two major features a)location transparency (although EJB2.0 helps you avoid that) b) Feature overlap, like transaction, security etc that is transparently provided by the container.

Regards,
Sandeep Deb
 
Rajesh Agarwal
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJBObject exists on the server side
 
Sunil Dixit
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roy,

we can't do that coz if you try to bind EJBObject as a JNDI object how you acheive following things :

1. Multiple client request handling
2. Method invocation on that object i.e. who will pass and reterive all passed parameters to your method.
3. How you handle Tx.

and many more... So its better to bind EJBHome which is nothing but it is factory class which know how to do all this stuff for you.
hope that this make more clear picture

Cheers,
Sunil Dixit
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!