If many clients are requesting updates on objects residing on the server, the number of object copies that travel on the network increases proportionally.
The point is that since Objects are passed by value, a copy of the object is sent to the requesting client
Thus any modification made on the passed object is not reflected on the server unless the modified object is passed back.
This increases network traffic and can have serious implications on the network band-width.
For more complex operations like querying a database located on the server the performance implications will be extremely high.
Another problem with this approach is that if the address of the server changes, the client needs to know the location of the new server before it can access the object. That is, the objects are not inherently location transparent.
In this context, a server is a class. In this class, we need a main method that creates an instance of the remote object, exports the remote object, and then binds that instance to a name in a Java RMI registry.
So we list the server jobs as follows:
Create an instance of the remote object
Export the remote object
Bind the instance to a name in RMI registry
How to create an instance of the remote object
We already create a remote object class -- PaymentImpl .
To instantiate it, just do it like any other class instantiation.
PaymentImpl robj = new PaymentImpl();
Here robj is an instance of the remote object PaymentImpl .
When the server starts, you are ready to start a client. Please issue the following command:
When the client starts, the LocateRegistry.getRegistry("localhost") sends information to the RMI registry which is held by the localhost(the Server command-line window) and asks to look for a remote object named "Mortgage".