Let's suppose I have the following code:
class Foo implements FooRemote{
private String string;
}
class Boo implements BooRemote{
/**
* This method is directly called from RMI client only
*/
public Foo getMyFoo(){
Foo foo=new Foo();
UnicastRemoteObject.exportObject(foo,somePort);
return foo;//the reference is returned directly to client
}
}
As you see, I didn't add it anyway to registry, for example I didn't do this:
registry.rebind(url, fooStub);
Can I be 100% sure that among all RMI clients the access to each instance of created foo
will have only one client (that, who called that method) and no one else can get the reference to this object (via registy or somehow else) and use it?
P.S. Please, include in your answer yes
or no
.
Can I be 100% sure that among all RMI clients the access to each instance of created foo will have only one client (that, who called that method) and no one else can get the reference to this object (via registry or somehow else) and use it?
Yes. It isn't in the Registry, as you didn't put it there. The only reference that is visible is the one you returned to the client.