Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

A conundrum - RMI remote or Local reference

 
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.
 
author
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
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
ScroogeXHTML 9.0 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/731949/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic