tags:

views:

57

answers:

1

In Java can a remote object also be a client?

So a client may call a remote object and the definition of that tat object through it's interface is a remote object, but can it also be a client of another remote object?

And if yes, does anything special need to be done to make a remote object a client

Thanks!

+1  A: 

It's possible, but not without direct intervention. When you call a remote object, then that is one "hop". From the client to the server. If the server is it self a client to some other remote object, then that is two hops.

You could make this happen by implementing a Proxy that delegates all calls on the server to the second server (since both client and server use the same RMI interface.)

E.g. You have

  ClientA --->  (ServerA>ClientB) ----> ServerB

The implementation of ServerA>ClientB is a java proxy that's exposed as ServerA which delegates all methods to ClientB.

mdma