Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

A conundrum - RMI remote or Local reference

 
Douglas Kent
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm dealing with a situation where I am implementing RMI for the communications. I've got an client object instantiating a local copy of Data for local use, depending on user selection. In that same object, if the user chooses remote, I get a reference to a remote "servant" which wraps one local (as far as the server is concerned) copy of Data. I would like to use one reference in the client object to either the local Data or the remote "servant", but can't get a common reference. Has anyone else dealt with this, and how have you solved it? One way (brute-force) would be to remember which way (local or remote) and keep separate references and invoke the appropriate one.
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to use both the remote and the local Data as if they were the same type, yet their implementations differ considerably. Hmmm... isn't that what interfaces were created for?
interface DataInterface...
class Data implements DataInterface...
- Peter
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!