Java Reference
In-Depth Information
er already know about it and it will not be downloaded. User-defined
classes are treated in the same wayif both the client and server have a
class installed, it will not be downloaded across the network.
Arguments and return values of remote methods are handled somewhat
differently from those of local methods. RMI passes arguments and re-
turn values by using object serialization (see page 549 ) . When a remote
reference is passed as an argument or return value, the receiver will
get a reference to the same remote object that was passed. This is how
local references act in local methodsan object reference refers to the
same object in both the invoking code and the invoked method. Prim-
itive types, too, are passed in the same way locally and remotely; the
receiver gets a copy of the value.
References to local objects must be passed differently. Local objects are
not designed to deal with partial failures, so it is not possible to pass
across the network a remote reference to a local object. Local objects
are instead passed by a deep copy made by serialization. Any remote
references contained within the object or in any part of the graph of ob-
jects it denotes will be passed as described earlier. All other parts of the
graph will be serialized on the sender's system and deserialized on the
receiver's. Changes made on one side will not be visible to the other
side, because each side has its own local copy of the object.
The RMI registry provides a simple naming system to store remote ref-
erences for bootstrapping your clients. This is not a full naming system,
but it will let you store objects that register or find top-level services.
The registry is accessed via the Naming class.
Server objects are governed by a "best effort" distributed garbage col-
lector. When no outstanding references to a remote object exist, that
object can be collected. This is similar in principle to garbage collec-
tion for local objects, but the failures of distributed computing make
surety impossible. If a client hasn't been in contact for a long time, it
is presumed to have gone away without notifying the server (possibly
the system crashed). If a long-lived network failure is actually at fault,
the client may find that the server has been garbage-collected when the
network reconnects. Every reasonable effort is made to preclude this
possibility. A server can ensure that it will never be garbage-collected
 
Search WWH ::




Custom Search