wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Local Interfaces in EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Local Interfaces in EJB" Watch "Local Interfaces in EJB" New topic
Author

Local Interfaces in EJB

PN Kumar
Ranch Hand

Joined: Sep 08, 2001
Posts: 38
The EJBLocalHome and EJBLocalObject interfaces in EJB refer to home and remote interfaces running in the same JVM as the bean. Does this mean that when ever an application client (end-user) is trying to access this EJB - there needs to be another remote object(some sort of facading pattern) ? If so, what specific advantage do these local interfaces offer - if we need to have a remote interface anyhow why need local interfaces also?
sanjeev mehra
Ranch Hand

Joined: Feb 12, 2001
Posts: 93
1.If client connects to EJB through local interface then n/w, marshaling protocols would not come in to picture. (Parameter passing - by ref)
2.If client connects to EJB through remote interface then n/w, marshaling protocols would be used. (Parameter passing - by value)
1st case use less resource compare to 2nd case. That's why local interface was introduced.
Thanks.
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by PN Kumar:
if we need to have a remote interface anyhow why need local interfaces also?

You may not use both interfaces for the same object. You can use a Value Object Assembler to create a Value Object using the local interfaces of the entity beans involved. You could then provide a session facade that uses the VOA and provides the VO via its remote interface. By doing so, you incur only one network (remote) call from the client to facade and several less-expensive local calls from the facade's VOA to the entity beans.
If you expose the remote interfaces of your entity beans instead, you'll be making an expensive remote call for each attribute you need from the entity.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
A large majority of the time the client is packaged with the EJBs in a J2EE Applications. This means that the client can indeed use the local interfaces instead of the remote interfaces.
However, it is important to note that most J2EE Application Servers do indeed optimize away the remote call if the client is in the same VM. Therefore, it is questionable what performance, if any, local interfaces would provide over remote interfaces to clients in the same VM. However, performance aside, local interfaces always make sense in those cases where you definitely don't want remote access to the component.
Generally speaking, you should use local interfaces by default and in those few cases where you really do want to allow distributed calls then you should apply a Remote Facade. The important thing to remember is that you need to approach remote calls from a much different viewpoints then you do for local calls. The inherent overhead in remote calls is just too high to ignore. Remote calls should be very coarse-grained to allow for acceptable performance while local calls should be fine-grained to allow for greater flexibility.
Regardless of the choices, you can technically apply both local and remote interfaces to the same EJB. However, as I alluded above, this is hardly ever a good idea because what works well for a local call would kill performance in a remote setting and what works well for a remote call is just not fine-grained enough for local clients.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Local Interfaces in EJB
 
Similar Threads
Does wL support Remote AND local interfaces for EJB?
Can a Bean have local and remote interface together?
doubt
CMP serialializable error, need your help!
Passing Reference