• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why we need to Interfaces

 
Rajesh Boddepalli
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why we need to Interfaces ie. HomeInterface and RemoteInterface?
any help appriciated.....Boddepalli
 
Naren Bhartiya
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interfaces are in general a blueprint, which represents the functionality of underneath object. Enterprise Java Beans have 3 interfaces �
Remote Interface � Represents the business functionality. Lists the business method implemented by the actual bean.
Home Interface - Represents the bean life cycle methods like create(), activate(), passivate(), these method are used by container in important operations to maintain the life cycle of the bean.
Local Interface � This new interface provide the business interface locally available to the client of the bean (other bean or object) available locally with in same JVM.
Thanks!!
Java - Make things beautiful!
 
vikasids sharma
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Home interfaces include methods controlling the life cycle of EJBs and remote interfaces are required for working with business logic of EJBs.
See when we talk of business oriented distributed object model, our code(EJBs) is distributed over the net. We work with interfaces(interface based programming)rather than writing directly to classes. Application Server tools generate(automatically) classes/objects for us. We provide information for generating classes through our above mentioned Remote and Home interfaces.
Originally posted by Rajesh Boddepalli:
Why we need to Interfaces ie. HomeInterface and RemoteInterface?
any help appriciated.....Boddepalli
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We do require the functionality in both the remote and home interfaces.
But why have 2 interfaces?....Why not only one interface containing the functionality of both the interfaces?....Why did Sun go for 2 different interfaces. :roll:
 
vikasids sharma
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sun could have provide you that way also.
We have two different interfaces just because of concept of classes in java.
A class may contain collection of similar objects/things. eg A library class should have books in it rather than patients are combined with books in same class.We should use different class for patients.
Similarly remote interface includes business logic and home interface contains logic for life cycle of EJB.
Originally posted by Vish Kumar:
We do require the functionality in both the remote and home interfaces.
But why have 2 interfaces?....Why not only one interface containing the functionality of both the interfaces?....Why did Sun go for 2 different interfaces. :roll:
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Local and Remote interface are have difference purpose.But bean can have both interface.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry in above answer.
I think, because EJB's architectures are design EJB that support all vendor.
 
Mathew Manoj
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why Two ?
Even i had the same question when i began studying?
Home Interface creates Remote Interfaces like a Factory and keeps in the Application Server Pool.
The clients use the stub generated by the container and call the methods in the remote interface which in turn call the bean instance.
Now you may ask why the home interface ? why not create the remote interface ourselves from the client.
If we didn't have a home interface we may have to do our own bean pooling and the concept of the Application Server is negated.
Also this solution has been decided by Sun after following the common Factory Pattern.
I hope i answered this.
 
vikasids sharma
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt
Either i understood question in wrong way or you......
I took it as "Why not we keep everything in 1 single interface? "
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic