wood burning stoves*
The moose likes Spring and the fly likes Architecture problem: How to manage property files to the following scenario... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Architecture problem: How to manage property files to the following scenario..." Watch "Architecture problem: How to manage property files to the following scenario..." New topic
Author

Architecture problem: How to manage property files to the following scenario...

Rafael F. Oliveira
Greenhorn

Joined: Aug 26, 2008
Posts: 12
Hi, I have a big problem in my company:

Scenario
- The same application "App" was installed in two contexts: www.company.com.br/AppProd and www.company.com.br/AppTest
- Each one has an app.properties file that contains its database configuration (url, user, password, etc).
- Each one has a separated Apache HTTP Server and 2 Tomcat for load balancing.
- Base technologies: Apache, Tomcat, Spring and Java

Problem:
We would like to keep the user changes (in the app.properties file) even if a new App is released and deployed.
Where/how should I put, link and load the app.properties in the source code/directory of the application?

Possible Solution (just a idea, not yet implemented):
Put each app.properties in the apache configuration directory, for example, apache1/conf/app.properties and apache2/conf/app.properties. Using this, we can redeploy a new version without overwrite the app.properties file, instead of to put this file (packed in the .war file) in the tomcat webapps directory.
I've read about PropertyPlaceholderConfigurer, but how to use this Class in my scenario?

Anyone has a idea how to solve this problem?

Thanks in advance!

Rafael Oliveira
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

This is not a certification question, so it does not belong in the certification forums.

I've been trying to decide where to move this to - normally I would handle this as a basic servlet / container issue. Using something like the ServletConfig you could store the database configuration on the Tomcat server, and this would be readable at the time the servlet starts up.

However since you have asked about Spring in particular, the people in the Spring forum may have other solutions. So I am moving this to the Spring forum.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Rafael F. Oliveira
Greenhorn

Joined: Aug 26, 2008
Posts: 12
Can I use JNDI and DataSource to solve my problem?

For example, If I started my application using the following link http//10.0.0.1/app_test -> get the dataSource from jdbc/app_test, else, if I started my application using the following link http//10.0.0.1/app_prod -> get the dataSource from jdbc/app_prod

Is this possible?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Architecture problem: How to manage property files to the following scenario...
 
Similar Threads
apache (tomcat) not parsing XML file?
Admin and Manager on apache
Want to change Application Property at startup
context root
$ expressions in applicationContext.xml not evaluated