Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Loading properties from file from a Java Bean  RSS feed

 
Michael Crutcher
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a war file that I'd like to drop into various customer deployments. The war has several jsp's and a java bean that performs operations on a database backend and returns formated html for insertion in the jsp's.
Each customer has different database names, but the same table structure. I'd like the installation of the new war file to be as simple as possible. I'd like to use some sort of properties file that lists the various database names.
I don't know what the System.getProperty(user.dir) will return. Some jboss installations are started as services (thus making the user.dir the bin directory of jboss), some installations are started via a shortucut on the desktop (making the user.dir the desktop directory of whatever user clicked on the shortcut).
So I guess my requirements are this: I need a file that is easily editable to change the database names, I need to open this file through the java bean upon initialization to populate some values within the bean, and I need to make installation as painless as possible.
What would everyone suggest?
Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't say so specifically, but I am assuming that your problem is that, since you are allowing the war file to auto-deploy, you have no oppurtunity to customize the properties file containing the client's info.
In the web app installations that I set up, I always disallow auto-deployment of the war files precisely so that I have complete control over what gets installed when and where. When time comes for an update, I stop the web app using Tomcat's manager application, hand-deploy the war file (the jar command is handy for this), copy the appropriate property file or files (usually to WEB-INF/config), and restart the app.
As an alternative you could leave auto-deploy on, and simply create custom war files for each client that contain the appropriate property files, but I prefer the level of control that deploying by hand gives me.
And yet another alternative could be to store the property file completely out of the bounds of the web app (this is the tack I thing you were taking) to some well-known location which would make it immune to re-deployments of any kind.
I prefer the first approach I outlined since it leaves me in complete control.
And, if you are not the deployer, but rather deliver the files to the client for deployment you could always set up a shell or Ant script to perform these steps.
[ April 07, 2004: Message edited by: Bear Bibeault ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!