I am new in Java and JavaRMI so a have some doubts about how its works, see below:
public interface Something implements Remote {...}
public SomeStub extends UnicastRemoteObject implements Something {...}
Every time when I create and bind (registry.rebind(...)
) one object of SomeStub
I am creating a new ServerSocket
to listen calls only for this object?
Example:
registry.rebind("...", new obj1);
registry.rebind("...", new obj2);
registry.rebind("...", new obj3).
2) So if the question 1 is true, is better use just only one stub of this object and threads to avoid create lots of serversockets?
PS: I am using the default serversocket and socket factories provided by the JavaRMI.
Every time when I create and bind (
registry.rebind(...)
) one object ofSomeStub
I am creating a newServerSocket
to listen calls only for this object?
No. Every time you export a new remote object RMI attempts to do port sharing, and creates a new ServerSocket
only if it doesn't already have one it can share with the new object.
Binding has nothing to do with it.
NB This is not a stub. It is a remote object, and it has its own stub created by RMI. Don't misuse standard naming. Call it something else.
So if the question 1 is true
It isn't.
is better use just only one stub of this object and threads to avoid create lots of serversockets
No.