Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

properties file

 
William Smith II
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My assignment requires that I have all configuration done via a GUI and saved into suncertify.properties. I'm sure this is consistent across all assignments.

I've got this bug. What I do is if the user chooses to change the data source and they are running local or alone, then my UI, which is MVC writes the new settings to the suncertify.properties file. The View uses a dialog box, then the model writes out the new config settings.

Then, my model tries to connect to the new data source (without passing on any information about the new data source). But lower down at the DB level, it looks at the suncertify.properties to setup the new DB filename. But it isn't updated yet on the suncertify.properties! So I'm connecting to the last data source. When I go back in to change the data source, it is updated.

Is there any easy fix?
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
How about using system properties:
System.getProperties().setProperty(property, value);
 
Romeo Son
Ranch Hand
Posts: 92
Android Eclipse IDE Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wiliam,

I wouldn't rely on suncertify.properties file at the DB level, because suncertify.properties file is related to the GUI level. This file is created ONLY if the assessor presses the save button in the configuration pane.

In my opinion you need to develop the database without thinking to the GUI.
Obviously, the database needs the data access file to work with. Because of this, I have created two constructors for the database class, a default constructor that assumes that the data access file is in the current working directory and another one, that gets the data access file as a parameter.

I am using the suncertify.properties file only to load the user preferences into the configuration pane. At this moment, the database is not instantiated yet. After the user presses OK, accepting the values (in this case the path to the file), the data access file is sent to the DB level (after checks that the file exists etc.), and the constructor that takes it as a parameter is used, instantiating the database class.

My specification file does not say that the user should be able to change data sources on the fly, so I DID NOT implement that.
If you want to do more than the specification requires, you need to be sure that you did it properly, otherwise you will loose points.

I wish you good luck with your assignment.
[ November 27, 2007: Message edited by: Romeo Son ]
 
William Smith II
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Musab Al-Rawi:
hi,
How about using system properties:
System.getProperties().setProperty(property, value);


That doesn't work because I'm reading the property in seperate packages and by the time the second package needs the data, the first package hasn't written it out like it was coded to.

I decided to rework my config setup so that the Data layer doesn't check the configuration.properties. I've moved it up into the GUI, and written methods to push the data file name down to the Data layer. So far, so good!
 
archana kher
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well I am afraid that communication between ui and db is done thru properties file. This isn't make sense. properties file is used to store data that is provided and used by UI. Eevry client will have his own suncertify.propeties file. How will things work when client and db are not on same m/c.

Please ignore this if I have mistaken your query!!!
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your server side should simply use the information provided with the call from the client, no property check..

I load the properties at startup, only to populate the values in the model.

you are supposed to have a property file on the server side, distinct from the one on the client side. Since both happen to have the same filename, when both server and client are on the same system, they should both use the same file to store data. But distinct data (at least, that makes it very easy).

I use a custom Property class that registers itself to the model. Every time, the model is modified, the property class is warned and write it to the file.

The opposite, at launch, the Property class will read the file and try to set the values in the model (through the controller).
After setting values, it register itself to the model.

It seems you already know what you are doing is a bug/fix. My suggestion is you change your design instead of applying a fix. Anyway, you might even break a "must" with that. The client and server must communicate with socket/RMI..

Regards,
Alex
[ November 27, 2007: Message edited by: Alex Belisle Turcot ]
 
William Smith II
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Alex Belisle Turcot:
Your server side should simply use the information provided with the call from the client, no property check..

I load the properties at startup, only to populate the values in the model.

you are supposed to have a property file on the server side, distinct from the one on the client side. Since both happen to have the same filename, when both server and client are on the same system, they should both use the same file to store data. But distinct data (at least, that makes it very easy).

I use a custom Property class that registers itself to the model. Every time, the model is modified, the property class is warned and write it to the file.

The opposite, at launch, the Property class will read the file and try to set the values in the model (through the controller).
After setting values, it register itself to the model.

It seems you already know what you are doing is a bug/fix. My suggestion is you change your design instead of applying a fix. Anyway, you might even break a "must" with that. The client and server must communicate with socket/RMI..

Regards,
Alex

[ November 27, 2007: Message edited by: Alex Belisle Turcot ]




In local mode, the Model reads in the properties file and pushes the DB filename down to my data facade class which then instantiates a Data object with the filename as a parameter.

In remote mode, the Model reads in the properties file and pushes the server /port to my client networking code.

In server mode, the main application reads in the config file, and pushes the DB filename down to the data face class which then instanties a Data object.

I don't think I would break a "must" with this design.
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have some more comments..


...MVC writes the new settings to the suncertify.properties file. The View uses a dialog box, then the model writes out the new config settings.

Then, my model tries to connect to the new data source (without passing on any information about the new data source). But lower down at the DB level, it looks at the suncertify.properties to setup the new DB filename.


This looks to me like your client is passing values to the server through the configuration file.

The configuration file SHOULD not be required to run the application. For instance, if you run the application on UNIX with an account without write permission on the directory...

From other poster it seems that SUN performs some testing with that property file and I would advice you allow your application to run entirely without it.

Best regards,
Alex
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic