|Oracle8i Enterprise JavaBeans and CORBA Developer's Guide
When you implement an EJB, or write the client code that calls EJB methods, you have to be aware of the parameter-passing conventions used with EJBs.
A parameter that you pass to a bean method, or a return value from a bean method, can be any Java type that is serializable. Java primitive types (int, double) are serializable. Any non-remote object that implements the
java.io.Serializable interface can also be passed.
A non-remote object passed as a parameter to a bean, or returned from a bean, is passed by copy, not by reference. So, for example, if you call a bean method as follows:
method1() in the bean gets a copy of
theNumber. If the bean changes the value of
theNumber object on the server, this change is not reflected back to the client, because of the pass-by-copy semantics.
If the non-remote object is complex, for example a class containing several fields, only the non-static and non-transient fields are copied.
When passing a remote object as a parameter, the stub for the remote object is passed. A remote object passed as a parameter must extend remote interfaces.
The next section demonstrates parameter passing to a bean and remote objects as return values.