RMI and references / Proxy classes

Y

yoxoman

Hello,

As far as I can see, given a IFoo interface extending Remote and a FooImpl
class implementing IFoo, the following two code fragments are (almost)
equivalent : (1)

IFoo stub = ( IFoo )UnicastRemoteObject.exportObject( new FooImpl() );
Naming.bind( "foo", stub );

and, if FooImpl is a class that extends UnicastRemoteObject : (2)

Naming.bind( "foo", new FooImpl() );

In fact, the FooImpl instance exportation is done in the implicit
UnicastRemoteObject constructor call.

But in (1), the object returned by UnicastRemoteObject.exportObject() is
a Proxy (dynamic) class, and consequently the object recorded in the RMI
registry is obviously a reference. Whereas in (2), it is not clear.

Where is the Proxy construction based an a FooImpl instance realized ? I
have seen that the RMI registry management in the client code (Naming.bind
()) encapsulates a (registry) Proxy class creation with a call to
LocateRegistry.getRegister(). So in the request :

Naming.bind( "foo", new FooImpl() );

is it the registry Proxy class invocation handler that handles the
parameters extending Remote to transform them as references / Proxy
classes ?

And in that case, given that the stub Proxy class in (1) is itself a
Remote class, would that mean that the object stored in the registry is a
reference to a reference (i.e. a Proxy calling another Proxy calling the
real class) ?

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top