• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

NX: RMI implemention question

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my implementation of the Contractors, I want to ensure that each client instance gets its own instance of the RemoteDataImpl running on the server. That is, if there are 3 clients, three instances of RemoteDataImpl will be created.
I was planning on making this happen by creating a RemoteDataFactory interface (extends Remote). The factory would then be responsible for creating a new instance of RemoteDataImpl to send back to the client. Something has confused me though. Do I implicitly create RemoteDataImpl objects by 'new'ing them? Or do I need to look up a RemoteDataImpl in the RMI Registry and return that?
I guess I am not sure of the semantics of either situation. If I 'new' the RemoteDataImpl, does the RMI system automatically just send the stub to the client? Also, if I get the instance from the RMI Registry, does that create a new instance?
Thanks!
 
Jeff Wisard
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nevermind...I had a momentary lapse of reason. For those interested:

This does exactly what I need.
 
Jeff Wisard
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
New question, though. When the client has exited or no longer needs the reference to the remote object returned via the factory, does the remote implementation instance get garbage collected?
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps you could replace your HashMap with WeakHashMap, the later could clean the object if no reference.
I also got one question about the RMI design, how to keep the RMI factory service running always(we cannot run the RMI factory service by : java package.rmifactoryclass,we start it from another class), and what's the better approach to stop the service do you think?
regards!
Frank
 
Lasagna is spaghetti flvored cake. Just like this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic