Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX Contractors: getting remote implementation to return a reference

 
Noah Le
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, for a remote connection, I want to have just one Data instance running on the server that all remote clients get a reference to. Can anyone advise me the best way to do this? Right now I'm just creating new instances of Data every time, and I don't want that.
Off the top of my head, I'm thinking about creating a new class (like DBServer) that has a static Data member (let's call it 'db'). The main() method will instantiate db as a new Data object. Then I will have a getConnection() method that returns db.
And then in my DBAdapter class, I will use DBServer.getConnection() to get my reference. Does any of this sound ok? But I'm not sure how to get DBServer to persist. Should I include an infinite loop in the main() method so that it never dies? Does that violate any principles?
Please help! I'd really appreciate it!
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Noah,
I am not sure I understand you question, but it seems like you are talking about Factory pattern.
You want a remote object (one instance) serving as a factory.
This Remote object (Factory) will deliver another remote objects (an instance pro client). All of them will refence one single Data object instance. (To make sure all remote object refence one single Data object -you may want to use either singleton or mutition pattern)
Do you understand you correct?
Vlad
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic