| Author |
best place to put configuration properties.
|
Jigar Naik
Ranch Hand
Joined: Dec 12, 2006
Posts: 744
|
|
where should i keep connection properties like hostName, and other properties for database conneciton, which i dont want to hard code(conneciton name & connection class). ??? Which is the best place for tham... so that in future if any modification requires than we can edit those properties without touching other code.
|
Jigar Naik
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6588
|
|
Well if you have a JNDI context to go with you can use that to store runtime values. You can also go with a properties files (just a flat file with some name value pairs) and I would recommend that you make them available outside your .WAR file. You can choose init parameters or context parameters also
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Rahul Bhattacharjee
Ranch Hand
Joined: Nov 29, 2005
Posts: 2300
|
|
|
I would have used a application.properties file with the properties in the form of key value pair and put that in the /WEB-INF/classes folder .In the application load that property file in the property object and make use of the values.
|
Rahul Bhattacharjee
LinkedIn - Blog
|
 |
Jigar Naik
Ranch Hand
Joined: Dec 12, 2006
Posts: 744
|
|
allright... I've set those parameters in .properties file but its in the war file. How can i make it available outside the war file ? because there are some parameters which will get changed at regular interval.
|
 |
Rahul Bhattacharjee
Ranch Hand
Joined: Nov 29, 2005
Posts: 2300
|
|
|
I guess you are using war format for distributing/deploying.each time you change the property file , you have to replace the old property file and then make and new war and deploy it again.
|
 |
Jigar Naik
Ranch Hand
Joined: Dec 12, 2006
Posts: 744
|
|
yes, that is what my TL dont want to do. Is there any other way i can put .properties file out side the war file and access it. ??
|
 |
Rahul Bhattacharjee
Ranch Hand
Joined: Nov 29, 2005
Posts: 2300
|
|
Originally posted by Jigar Naik: yes, that is what my TL dont want to do. Is there any other way i can put .properties file out side the war file and access it. ??
TL - team lead. (always use expanded version of your vocabulary) Two things you can do. 1> instead of making the way again and again , put the property file in the exploded war , which is there inside the server.and restart the server each time you change the property file. 2> make a build file that would make your job easy .replace property , make war , deploy ,restart server.
|
 |
Jigar Naik
Ranch Hand
Joined: Dec 12, 2006
Posts: 744
|
|
" make a build file " Did not get it. Can you please explain it in more detail ?
|
 |
Rahul Bhattacharjee
Ranch Hand
Joined: Nov 29, 2005
Posts: 2300
|
|
|
make a ant build file to do the task.
|
 |
Muhammad Saifuddin
Ranch Hand
Joined: Dec 06, 2005
Posts: 1318
|
|
Originally posted by Jigar Naik: Can you please explain it in more detail
Refer this to create build file
|
Saifuddin..
[Linkedin] How To Ask Questions On JavaRanch My OpenSource
|
 |
 |
|
|
subject: best place to put configuration properties.
|
|
|