Serialization
Serialization
is a mechanism used to convert any object into a sequence of bytes that
can be later reconstructed. The ability to store and retrieve objects
is essential for building a network application. RMI heavily depends
on the object serialization mechanism to transmit data from one machine
to another. When sending messages to remote objects, object serialization
is necessary to transport the arguments and return values. When a remote
object is passed to a client, the client receives a stub. The actual
object stays on the server. If you pass non-remote objects, the client
gets a copy of the object. RMI system can make copies of an object,
if that object implements the Serializable
interface. This chapter shows an example of implementing the Serializable
interface and passing custom objects across a network.
The source code needed for this example is stored in the examples\Customobjects
directory. The "Customobjects"
directory contains the following files:
- CustomInterface.java
- CustomServerImpl.java
- CustomClient.java
- Customer.java
- Compile.bat
- Rmicompile.bat
- RunServer.bat
- RunClient.bat
|