what are local interfaces?


what are local interfaces?

padma Supporter Asked on June 8, 2015 in Programmer.
Add Comment
3 Answer(s)

Local objects implement local interface rather than using remote interface. Just to have a comparison below are the steps how the local object works. JAVA client calls the local object. Local object does connection pooling, transactions and security. It then passes calls the bean and when bean completes its work it returns the data to the Local object who then passes the same to the end client. You can understand from the above steps we have by passed completely marshalling and de-marshalling. .


alex Reviewer Answered on June 8, 2015.
Add Comment
Local interfaces :
On of the biggest issues of creating objects using home interface is performance. Below
are the steps which follow when you call the EJB object:-
  • JAVA client calls the local stub.
  • Stub marshal the values in to some other form which the network understands and sends it to the skeleton.
  • Skeleton then de-marshals it back to a form which is suitable for JAVA.Skeleton then calls the EJB object and methods.
  • EJB object then does object creation, connection pooling, transaction etc.
  • Once EJB object calls the bean and the bean completes its functionalities. All the above steps must again be repeated to reach back to the JAVA client.
So you can easily guess from the above step that its lot of work. But this has been improved in EJB 2.0 using Local objects. Local objects implement local interface rather than using
remote interface. Just to have a comparison below are the steps how the local object
works.
  • JAVA client calls the local object.
  • Local object does connection pooling, transactions and security.
  • It then passes calls the bean and when bean completes its work it returns the data to the Local object who then passes the same to the end client.

You can understand from the above steps we have by passed completely marshalling and
de-marshalling.
Limitations of using Local object
Local object only work if you are calling beans in the same process. Second they marshal
data by ref rather than by Val. This may speed up your performance but you need to
change semantics for the same. So finally it’s a design and the requirement decision. If
you are expecting to call beans remotely then using local object will not work.


amit Reviewer Answered on June 8, 2015.
Add Comment

Local is designed to be used in a local environment, for example in a case if another EJB or even a POJO in your system is using that.Local interface is not local to JVM but local like an other POJO class.
Local client view cannot be accessed:

  • When an EJB or web component is packaged in a different application’s EAR packages.
  • When a web component is deployed in a web container, and EJBs are deployed in an EJB container, and these containers are separated (even if they are running on the same machine)

These are main factors in considering a Local or Remote interface:

  • Client: if your client is not a web component or another bean do not use Local
  • Beans & Beans: Are the beans loosely coupled? then it is a good idea to use Local
  • Scalability: Remote is always better for scalability
  • Local interfaces are recommended for entity beans, which helps with performance issue.


Rohit Reviewer Answered on June 8, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.