• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why two interfaces in EJB?.......help needed  RSS feed

 
whizkid
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I have started reading ejb from Oreilly and i am wondering on one question why there are seperate 2 interfaces Home and Remote why not there can be only one combined interfaces.
Also can any one give me good faq and answers on ejb so that i can prepareit interview point of view also
by....
 
Rick Salsa
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
The two interfaces are there for specific reasons. When using EJB, all clients make requests through a remote interface (the ones you create). The remote interface has the same method signatures as your Enterprise Bean class.
The Home interface serves as a factory for creating EJB objects. EJB objects are basically request interceptors. The EJB object is created by the EJB container and implements your remote interface.
When the client invokes a business method on your bean, they are actually making a call on the remote interface, which is passed to the EJB Object. The EJB object takes care of all the middleware issues, like transactions, security, etc. It then delegates the request to your bean class which does its job and sends back a response.
Allowing clients to interact directly on your beans is not a good thing. This is the reason for all these interfaces. Without them, you'd be left to take care of thread safety, transactions, etc....
Hope that helps,
/rick
P.S. It's probably not my place, but you should change your user name to comply with the ranch's policy. That is, your user name is: "FirstName LastName"
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
whizkid,
JavaRanch has a required naming standard. You must use your real first name - space - your real last name. Please update your display name. Thanks.
 
Guennadiy VANIN
Ranch Hand
Posts: 898
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rick Silva:
EJB objects are basically request interceptors.
.....................
The EJB object takes care of all the middleware issues, like transactions, security, etc.

Is it EJB object(s)' or container's job?
This question is rather FAQ (cf. here but I do not think it was answered: why two? They could be combined in one.? The presence of interface is not the synonym of possibility to intercept requests...
[ January 21, 2003: Message edited by: yidanneuG ninaV - just fixed the broken link]
[ January 22, 2003: Message edited by: Guennadiy VANIN ]
 
Robert Troshynski
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I believe that EJBs use RMI-IIOP as the underlying protocol to communicate with the remote computer.
If you skim over the material on RMI-IIOP, you will note that they use the concepts of 'remote' and 'home' as part of the protocol.
Robert Troshynski
 
anupa oru
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
sorry for interrupting so much,if you still find answer for your question I will tell you as far as I know/
There are two parts 1 is container other is bean.
Home interface allows you to interact with container where as remote interface allow u to invoke business methods on beans.Since there are 2 components to deal with there are 2 interfaces as well
Thansk
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!