I have an RMI server export a single "Manager" class. The RMI client connects to the server, and retrieves the instance of the "Manager" class. Then, I call "Manager.createBox()", which creates a box, and then "Manager.getBox(0)" to retrieve the box.
Now, if I make any changes to that "Box" that I just retrieved, modify it, and then call "Manager.getBox(0)" again, I get the original box again without my changes.. How can I "commit" the changes I just made to Box on the client side? Or, do I need to add a method to the manager?
If the Box ia a simple serializable class, then its state is simply serialized, sent on the wire, and deserialized on the client when getBox is called. The client thus modifies a copy of the box, and not the original one.
If you want the modified box to be on the server, then either send it back to the server (manager.modifyBox(box)
), or make the Box a remote object (by making it a remote interface Box, implemented by a BoxImpl concrete class extending UnicastRemoteObject).