As I understand it, once I've set up an RMI communications link between two systems, I can pass an object that implements "Remote" into one of the remote methods that takes an object of that type and the far-end will just get the remote interface for the new object (in other words, it will become a new remote connection as opposed to just serializing the object over.)
Is this correct?
If so, I assume this has something to do with the method signatures--but I'd like to know exactly how it determines that it should create a new remote object instead of simply serializing the entire object.
This is really hard to put into words. Let me try this:
Let's say I have a client and a server system. On the server system I create and publish an RMI object, on 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 Client, Object1.remoteMethod() will execute on Server (after serializing over the parameters).
Now, here's the question, on the client I execute code like this:
Object2 object2=new object2(); // Also a remote object
object1.send(object2);
As I understand it, at that point, my system will have a new communications mechanism:
Client Server
Object1 RemoteIface ----- Object1 Implementation
Object2 Implementation ----- Object2 RemoteIface
At this point, if the server calls a method on Object2, that method will actually be executed on the client.
I'm wondering at what point the system decides to do this rather than just serializing it (as it would with any non-remote object).
Or am I completely wrong and it just serializes it over and I need some kind of "getRemoteInterface()" method call to actually create the remote call?