Most EJB servers use what are called Intra-VM remote calls. An oxymoron, that
means method calls between beans are optimized to avoid using a distributed
object protocol. Intra-VM remote calls will copy parameters and return values
rather then marshal them across the wire. According to the EJB specification
even Intra-VM remote calls must, however, adhere to the copy semantics of the
Java RMI-IIOP, which means objects must be copied not passed by reference.
EJB servers will, however, make optimizations to the copy operation in Intra-VM
remote calls in order to make them as fast as possible. For example,
java.lang.Number and java.lang.String are immutable, so they can be passed by
reference -- application objects, on the other hand, should always be copied.
Some EJB servers will use Java Serialization to copy objects while others may
use some other mechanism -- I think a couple EJB servers use IIOP marshaling
because they claim it's faster than Java serialization. Java primitives are
always passed by copy so they're not a problem.
Some EJB servers offer a switch that allows deployer to turn of the copy
semantics in Intra-VM remote calls. This means that all objects are passed by
reference, which is very fast compared to coping, but also dangerous since a
bean no longer has sole control over an object's state. I don't recommend using
these switches unless you are absolutely sure of what your doing.
Richard
--
Richard Monson-Haefel
Author of Enterprise JavaBeans, 2nd Edition (O'Reilly 2000)
Co-Author of Java Message Service (O'Reilly 2000)
http://www.EjbNow.com
Peter Delahunty wrote:
> Hi
>
> I realize this will be application server specific but does anyone know if
> local/remote method calls from EJB to EJB are optimized. For example if
> Entity Bean A calls Entity Bean B and they are both located in the same app
> server (e.g. now a local call) then does the app server optimize this call.
> What I mean is does the app server know that the call is local and so does
> not go through all the remote call overheads.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".