• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Home and Remote interface

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In one interview ,interviewer asked me one question as....
Why we require two seperate interfaces as home and remote?
Can't we declare the methods (we do in remote) in the home interface only?
I answered that to hide the business methods from the client,
as the client has direct access only to the home interface..
Is it correct?
Please guide me.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your are right to some extent..
Simple answer is ITS EJB Specification.
if we shift all mehtod to home.. then we are losing the extensibily of the framework.
We are making this more complex desing if we put this in Home interface.
This is debatable...
 
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ALaxmi Shankaran:
In one interview ,interviewer asked me one question as....
Why we require two seperate interfaces as home and remote?
Can't we declare the methods (we do in remote) in the home interface only?
I answered that to hide the business methods from the client,
as the client has direct access only to the home interface..
Is it correct?
Please guide me.

But through the remote interface you are actually exposing your business methods. I'm new to EJB, but at this point in my learning I would answer that question something like this: The home stub basically fulfils the role of a factory, responsible for handing out references to the remote component. Remotes are tied to a specific bean whereas the home is not. Since business methods need to be run against a specific bean instance (excluding home business methods), they must be in the remote component interface.

Does that make sense? I'm sure there is a better answer.
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

EJB is about separating concerns, hence the role concept, which is an inherent part of EJB.
This is emphasized by separating a bean's methods into life cylcle methods defined in the
home interface, and business methods defined in the component interface.

The home interface is used by the container to manage the bean's life cycle.
It is the container that provides factory classes for creating EJBs according to the
methods declared in the home interface.

Hope this helps.
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ALaxmi Shankaran:
In one interview ,interviewer asked me one question as....
Why we require two seperate interfaces as home and remote?
Can't we declare the methods (we do in remote) in the home interface only?
I answered that to hide the business methods from the client,
as the client has direct access only to the home interface..
Is it correct?
Please guide me.




Hi,

a) The Home Interface methods are implemented in the Container and EJB Container will control the Bean Life cycle methods.

b) The Remote Interface methods are implemented in the Beans Stub object (i.e EJB Object), EJB Container uses this ejbObject to service the client request (i.e to service the business methods).

I am not 100% sure about my answer. If wrong, I hope someone will correct it.

Regards,
M.S.Raman
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Both the home and the "remote" interfaces are for business methods. The difference is in the level of scope.

I write "remote" as I rather refer to them as "home interface" and "component interface". They can be either remote (exending EJBHome and EJBObject respectivly, which both extend Remote) or local (the local versions).

The difference is

Component interface is for methods *on* your component, e g Car, Person, ShoppingSession or whatever your BL is. Still, you only operate on one specific object.

Home interface is for group operations, or meta operations. These include creation (create-methods) or searching (find-methods), which will give you a reference to a specific object you thereafter can operate upon (using the component interface). Home methods can also be group operations such as the total pagecount of all out-lent books (in a library) or average age of a car in a city.



Home in
 
reply
    Bookmark Topic Watch Topic
  • New Topic