As I understand it, as soon as I established an RMI connection between two systems, I can transfer an object that implements "Remote" to one of the remote methods that take an object of this type, and the far end just gets the remote interface for the new object (in other words, it will become the new remote connection, not just serializing the object.)
It is right?
If so, I suppose this has something to do with the method signatures, but I would like to know exactly how it determines that it should create a new remote object instead of simply serializing the entire object.
It is very difficult to put into words. Let me try:
Say I have a client and a server system. In the server system, I create and publish the RMI object, in the client system I retrieve the interface and can interact with the server system.
Client Server
Object1 RemoteIface ---- Object1 Implementation
So far so good. On the client, Object1.remoteMethod () will be executed on the server (after serialization by parameters).
Now, here is the question, on the client I execute the code as follows:
Object2 object2=new object2();
object1.send(object2);
As I understand it, at this moment my system will have a new communication mechanism:
Client Server
Object1 RemoteIface ----- Object1 Implementation
Object2 Implementation ----- Object2 RemoteIface
At this point, if the server calls the Object2 method, this method will actually be executed on the client.
I wonder at what point the system decides to do this, and not just serializes it (as for any non-remote object).
Or am I completely wrong and it just serializes it and I need some kind of getRemoteInterface () method to actually create the remote call?