Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Why two interfaces ( home and component ) ?

 
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello friends,
After going through the various types of beans, I get a very basic doubt, why do we have a home interface and a component interface. Why cant there be just one interface that does the work of both.
Like I have so many doubts. Why cant the client get the EJBObject directly rather than going through the EJBHome. I know it works that way but I want to know * WHY ? * What is the need of EJBHome ? Is it just to create a EJBObject and for the finder methods ?
What is the reason that it has been implemented as two interfaces rather than one? Again may seem a silly doubt but I am not able to see the reasoning behind it.
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Stateful session beans can take different parameters in its create method.
For example
RemotInt it1=homeint.create();
RemotInt it2=homeint.create(1,2);
RemotInt it3=homeint.create(1,2,5);

If we had a single interface for the home and remote we would have to bind them to 3 different JDNI name for the example above.
[ December 10, 2003: Message edited by: Pradeep Bhat ]
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also had this question, a few months ago...
The way I understand is...
J2EE has most of the ideas borrowed from CORBA. With Corba, first you retrieve the server object and then start calling the business methods.
These are 2 different activities one followed by the other...
I guess for modularity reasons, SUN came out with this idea of having 2 different interfaces to be implemented by 2 different Objects on the server side. It is easy thing to say, that we could combine both the functionality into 1 server side object, but I guess it may not be easy at all, for the Vendor to provide such an EJB Container implementation...
If anybody has something else to add, please do...
 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reghu,
It will become more clear when you read about entity beans. Entity beans have more stuff in their Home interface. Also don't forget that for every bean interface class there is only one Home interface object on server (and it always stays in memory). But for every bean class there might be many EJBObjects..
You pass now EJBObject when you want to give someone access to bean. If you would pass EJBHome+EJBObject, that would certainly be overheat.
Then think about server:
a) If instead of EJBObject would be EJBHome+EJBObject.. It's memory waste again. Server always needs only 1 instance of Home interface object.
b) You have to have something on container which is able to create that particular bean for you. Since there might be many EJBObjects for the same bean class.. which one will stay always on server to serve your request to create another one?
From design approach I believe this is correct to separate what belongs to your bean class with what belongs to it's instance. Home belongs to your bean class and Object Interface belongs to particular bean instance.
So keep reading, it will clear up later.
 
Reghu Ram Thanumalayan
Ranch Hand
Posts: 193
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,
I knew that two interfaces are really required in case of Stateful session beans and entity beans.

Then think about server:
a) If instead of EJBObject would be EJBHome+EJBObject.. It's memory waste again. Server always needs only 1 instance of Home interface object.
b) You have to have something on container which is able to create that particular bean for you. Since there might be many EJBObjects for the same bean class.. which one will stay always on server to serve your request to create another one?


But i guess Vladas's explanation answers most of my questions.
Thanks for making it clear guys.
 
Pradeep bhatt
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://forum.java.sun.com/thread.jsp?forum=13&thread=20971
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic