wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Home Interface Return Type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Home Interface Return Type" Watch "Home Interface Return Type" New topic
Author

Home Interface Return Type

Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi,
i have a doubt when we write a Home Interface we call a create() method
whic returns an EJBObject.
But return type of create() is RemoteInterface WHY??
as in below example which is a HomeInterface why return type is RemoteInterface


SCJP 1.2
vikasids sharma
Ranch Hand

Joined: Aug 01, 2003
Posts: 157
Well because your created EJBObject is implementation of Remote interface
Originally posted by Anurag M:
Hi,
i have a doubt when we write a Home Interface we call a create() method
whic returns an EJBObject.
But return type of create() is RemoteInterface WHY??
as in below example which is a HomeInterface why return type is RemoteInterface


Thanks
Vikas Sharma
SCJP(1.4)
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Can u pls tell me in Detail so that i can Understand..
thanks in advance.....
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
"Anurag M",
I'm sorry that I missed it in the previous thread but your display name still doesn't comply. The naming policy allows initials only for first name, not last name. We'd really appreciate it if you could change it (again).
Thanks, and sorry for the hassle.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Anurag, the bean implementation class that the EJB container generates based on the implementation class you wrote implements the remote interface you wrote. The client is only interested in having access to an object providing that "business" interface, he's not interested in having an EJBObject. That's why the home interface's create methods' signatures return the remote interface.
vikasids sharma
Ranch Hand

Joined: Aug 01, 2003
Posts: 157
Lasse
Can we say other way..
As the Implementation class for EJBObject is generated by Container glue tools automatically .Client is concerned with the Interface(Remote) only that he has created as its implemetation is vendor specific. That's why the home interface's create methods' signatures return the remote interface
Originally posted by Lasse Koskela:
Anurag, the bean implementation class that the EJB container generates based on the implementation class you wrote implements the remote interface you wrote. The client is only interested in having access to an object providing that "business" interface, he's not interested in having an EJBObject. That's why the home interface's create methods' signatures return the remote interface.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Yes. Or even more compact: "The client is interested in the interface, not the implementation."
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
thanks a lot vikasids and Lasse for ur message.
i understood the point.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"Anurag",
Sorry to pester you, but your display name is still not valid and this is one of few rules we are strict about.
Your display name must be two words, your first name, a space, then your last name. It should be your real name.
Check the Naming Policy page if you need more information.
thanks,
Dave.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Home Interface Return Type