This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Why two interfaces that is home and component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Why two interfaces that is home and component" Watch "Why two interfaces that is home and component" New topic
Author

Why two interfaces that is home and component

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
I don't understand why we have 2 to go through 2 interfaces(home and component) to access a bean class.
**Does this exists to make difference between different kind of beans.
or any other reason???
plz clarify it??
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
You can say that EJBHome is service factory for EJB objects.
Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
But,we are doing nothing through Home interface,just getting reference of component interface.
I am not clear why 2 interfaces???
Balaji Anand
Ranch Hand

Joined: Nov 03, 2004
Posts: 146
I had the same question... When i hit... say the AdviceBean Home i am going to ultimately ask for a session object... so y cant the first call itself do everything internally and give me an Component interface?(let us ignore the casting and stuff for a while).
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
I'm sure the answer you are looking for is here somewhere; search the forum or google the saloon.
Here's just one: What is purpose of homeObject?
(Of course these days I argue that the home interface has a Factory Method while EJBHome isn't an Abstract Factory: Patterns: Abstract Factory Vs Factory Method)
[ May 19, 2006: Message edited by: Peer Reynders ]
Patrick Williams
Ranch Hand

Joined: Apr 03, 2005
Posts: 213
EJB 2.0 does not want you to access the bean directly. If you could, you would not be able to take advantage of security (which is supplied by the container generated EJBObject) and object pooling. When you utilize the Home interface, you are essentially asking the container to create a new object or to grab one from the pool. This would be more difficult for the container (and container developers) if it allow for calling the bean itself. HTH


Patrick<br /> <br />SCJP/SCWCD/SCBCD/SCDJWS/SCEA<br /> <br />Currently working on:<br />SCJP 6
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why two interfaces that is home and component