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!
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
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:
posted 17 years ago
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:
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.