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
posted
0
You can say that EJBHome is service factory for EJB objects.
Raj Kumar Bindal
Ranch Hand
Joined: Apr 15, 2006
Posts: 409
posted
0
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
posted
0
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: 2906
posted
0
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 ]
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