SCJP 1.4, SCJD
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Originally posted by Hanna Habashy:
hi Mike,
First, what did you store in the properties file that is so fatal and a must to have?
SCJP 1.4, SCJD
Originally posted by mike acre:
...
2/ Have an 'untouchable' properties file inside the Jar.
Andrew favours the former: here
I favour the latter.
java.util.Properties is set up better for the latter.
Imagine a getProperty() call.
Get property from Properties object.
it is not there, null returned.
get it from defaults, oh need an internal hashMap of defaults.
Pain!
Even if you validate all properties on initial read you have similar problem.
Seems to me if you go with the defaults in the Jar then the coding becomes much simpler.
Thoughts please.
Originally posted by peter wooster:
What I do is...
SCJP 1.4, SCJD
Well you must have some value, and if you can guarantee there is a default value
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
What default value do you garantee??
The magic cookie value, and the db location can be changed by the admin..
SCJP 1.4, SCJD
Wickes Potgieter<br />SCJP<br />BEA Certified Specialist: Server, Integration, Portal, Tuxedo<br />BEA WebLogic Server 7 Certified Enterprise Developer<br />BEA Certified Architect<br /><a href="http://www.bea.com" target="_blank" rel="nofollow">www.bea.com</a>
Best Regards <br /> <br />Omar F. Kalaldah<br />---------------------<br />SCJP, SCJD, SCBCD
What about text for labels, error messages, etc. where do you put yours? in the properties file or do you hard code them in your source?
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
If I put this data in a property file, then I am openning a window for someone to change what it meant not to be changed.
I know many people will disagree with me, however I found this technique very secure.
Regards, Richard
Did you ever put some data in your property file?
For instance, you are able to put magicCookie/numFields/fileName values into it before the property file was created?
why is this kind of mechanism secure as you said?
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Anton Golovin ([email protected]) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
Regards, Richard
At startup, I check the properties file, if it is there, I read it, and if it is not there, I reintialize it from the original DB file.
Regards, Richard
1) Should I specify the current path of the property file?
If the code above is correct,is this right that I start the main program through command line argument "alone" or "server"?
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Regards, Richard
Anton Golovin ([email protected]) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
Anyone has any suggestions? Please correct and criticize for me.
local GUI design: looks for properties file and datafile path in it; if not, prompts user to locate data file and, upons ascertaining it is a data file, logs the path into the properties file.
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Anton Golovin ([email protected]) SCJP, SCJD, SCBCD, SCWCD, OCEJWSD, SCEA/OCMJEA [JEE certs from Sun/Oracle]
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Originally posted by Hanna Habashy:
However, your design makes tight couupling between your software and the original db file. What will happen if the company decided to operate on a different dababase file, with differnt magic cookie value?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Don't get me started about those stupid light bulbs. |