• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Server implementation

 
Kruger Scheitz
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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
  • 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??
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic