• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX: Server implementation

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm not confidence of which design pattern should i go for in respect of initializing certain instances.

i have three classes
StartupServer.java - has a Naming.rebind method()
This is a class where ConnectionFactory is initialized.
ConnectionFactory.java - return RemoteData
RemoteData.java - a delegate to remote db
now my question is where should i initialize LockManager instance?
Should i initialize it in the StartupServer and pass it as an argument to ConnectionFactory and in turn pass it again an argument to RemoteData
or Should i initialize in Connection Factory
or should just simple initialize it in the RemoteData as static instance?
 
Kruger Scheitz
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And one more question. Do i need to allow the client to specify the remote db path. i don't think this is a good as i saw so many ppl doing it....
And if this is the case, that is if u don't allow the client to specify the db path, there will only one database and lockmanager and u don't have to deal all the singleton stuff..am i right??
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In remote the client only needs to specify the server address and port, if not using the default.
I'd create the instance of the LockManager at the same point you create the instance of the Data class. Which in your case I think is in the StartupServer class. This is the class that you create your ConnectionFactory and bind it to the registry. The instances of Data and LockManager should be instance variable of OnnectionFactory, so that it can pass the references to each RemoteData instance.
Yes, do not make them Singletons, it isn't necessary. Since it is created in the StartupServer and passed to the ConnectionFactory classes instance variables. Then you are positive that there is only one instance in this Factory class that all RemoteData class will have a reference to.
Mark
Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic