• Post Reply Bookmark Topic Watch Topic
  • New Topic

Home and Remote interface

 
ALaxmi Shankaran
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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.
 
Dogra
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • 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...
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • 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.
 
Mag Hoehme
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • 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.
 
Malli Raman
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • 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
 
Dan Johnsson
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!