• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

saving configuration

 
Amber Beerends
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My exam specifies that some configuration must be saved between runs in a specific file in the current working directory and must be persistent between runs. I've done this and its all well and good UNLESS I'm running the server and networked client on the same machine from the same working directory. Then the saves from one has the potential to wipe out changes made by the other. I'm torn about handling this. One one hand, its totally illogical in a real setting to be running the networked client and server on the same machine so this scenario is really just a developer testing problem. On the other hand, I'm technically not meeting the requirement in this (albeit unrealistic) scenario.

Thoughts??
 
rinke hoekstra
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amber,

I just had a different set of keys for each of the possible modes. That makes sure that they don't interfere, and it felt logical to me.

So:

server.databasefile and standalone.databasefile.
server.port and client.port
 
Jean Robillard
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just let each other overwrite the config settings

I am fine with it - if the server & client are launched from the same working directory using the same JAR file, then whatever the last-invoked JVM will make the most recent updates to the cofig file. This works for me because all the config settings are identical between a server & a client. and I only read & write at startup. There are many choice for approaching this obviously.
 
Amber Beerends
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rinke - That solution doesn't work. If the server writes X and Y to the file, the client can still overwrite the entire file so that it just contains A and B.

I think what Jean is saying makes more sense. I had been delaying saving the configuration until the application was shut-up down, but if I do it after a successful connection is made with the submitted data, this is less likely to happen. Although, it could be possible if someone opens both, then starts the server, then starts the client. :S

- amber
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amber Beerends:
rinke - That solution doesn't work.


It does. This is exactly how I did. You can start the application in any mode, it gets the last valid configuration for it. I believe you guys are handling the config file in a different way. However, I don't think this is wrong though. Maybe this is something you might point out in your choices.txt file.
 
rinke hoekstra
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amber Beerends:
rinke - That solution doesn't work. If the server writes X and Y to the file, the client can still overwrite the entire file so that it just contains A and B.


Well, just as Roberto said: I think you are handling this properties file in a different way than I do. My client cannot overwrite the entire file. It just can overwrite its own set of properties.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic