aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Help understanding what is written to configuration file and who writes what. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Help understanding what is written to configuration file and who writes what." Watch "Help understanding what is written to configuration file and who writes what." New topic
Author

Help understanding what is written to configuration file and who writes what.

Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
Hi,
Would someone mind giving me an indication of what needs to be written to configuration file for standalone client, network client and server? I presume server definitely writes the database location and port number.
I'm slightly confused as to whether the standalone or network client actually write anything to configuration file. I note the following
"All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory. "
But how can this happen, as I presume the configuration file resides on the server? Is there multiple copies of this configuration file, for clients and server. Sorry, if I'm making glaring mistakes but I haven't attempted a full project before. Will def contribute to forum when project complete. Thanks!
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Howdy, Mark!

Please take a look here. I think it might be helpful!


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
Cheers, thanks for your kind reply, they are excellent threads.
I'm still quite confused though and I will explain why. My confusion lies in the fact that I think the server, standalone client and network code is all together in the one jar file. Is below right?
(1) The jar file contains the server, standalone client and network client, and the server mode say is run from the "user.dir" setting on a machine. But multiple copies of the same jar file can exist on same machine or different machines. Therefore in standalone client mode, the user must be able to select the database location and save the database location to "suncertify.properties" to be persistent between runs. Database resides on same machine. Therefore this copy of suncertify.properties is held locally and is essentially viewed as a different copy to the server one. The network client then is run from the same jar and a new "suncertify.properties" is created for each client that connects, therefore the client needs to query the ip address of the running server and save it. This is dependent upon what client inputs either ip address or hostname, but either way, this essentially means a new copy of "suncertify.properties" exists for each client.
I think the above is correct. My confusion lay in the following: Being new:
(1) Viewing the server, standalone and network client code together all packaged as one jar. Does this actually happen in industry? I had it in my head of viewing the 3 modes as packaged separately. This is why I had difficulty seeing the network client writing to the same properties file as the server.
Thanks, any input appreciated.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Howdy, Mark!

(1) Viewing the server, standalone and network client code together all packaged as one jar. Does this actually happen in industry?


Hum... sometimes yes, but it is likely that these components would be distributed in separated .jar files.

Now, the suncertify.properties file has to always be saved in the application working directory. Let's say that you start the application for the first time. Since the file still doesn't exist, you have to create one, no matter how the application was started, but let's say that the application is started in standalone mode. You create the suncertify.properties file and save the values provided by the user. Then, let's say that the application is started in client mode. The values related to the server (IP address or port number, for instance) do not exist in the .properties file, so no values should be displayed to the user. Then, let's say that the application is now started in standalone mode again. The values provided by the user should already exist, so you show them to the user. The point is, you always use the same file to save the values provided by the user. You can create different properties for it.
Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
Hi,
I have that concept, but does that mean the jar is always going to be run from the same "user.dir", the same working directory. Basically standalone + network client + server all run from the same directory?
Or can the network client be run from 1 jar and server run from different jar in different "user.dir", say on different machines,in which case how do they share the same properties file?
Probably repeating myself here, sorry, just a bit confused. Thanks for your help, hope you understand my situation.
Johnny Barbosa
Greenhorn

Joined: Sep 29, 2009
Posts: 26
Hi Mark,

Look, You will have only one file JAR, which is your application as whole (alone, connected and server). Architecturally your system is only one file:runme.jar.
However, how your system will go run not matter!! If your system is running in two machine different (as server and client connected), so, they will go have one file suncertify.properties for each one's. A properties in the machine 1 and other properties in the machine 2. This not matter. if your system is running as server and client at the same machine, there will be only one properties and so, they will share the same properties. However, you need to save pair key/value different for each mode that is running. figure out?


Cheers,
Johnny Barbosa
SCJA, SCJP, SCWCD, SCJD(Story | Relato), SCBCD (coming soon)
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Grande Johnny! Exactly!

And also, the suncertify.properties file is to be placed in the current working directory. So, if you put the .jar file in another directory, then you'll have to create another suncertify.properties file.
 
Don't get me started about those stupid light bulbs.
 
subject: Help understanding what is written to configuration file and who writes what.