Hi Patrick, On 26 Aug 2005 at 17:24, QM wrote:
> On Fri, Aug 26, 2005 at 02:16:26AM +0800, Patrick Lacson wrote: > : I know that's typically where they go, but if the file is inside the > : .war, how is the file going to be configured by the sysadming folks? Our approach to this problem has been to: 1. Have a configuration file with "application-specific" properties that lives in the WEB-INF tree and is loaded in the usual way via a context-parameter reference in web.xml. This file contains properties that vary from one application to another, but are the same for every server. 2. Within our "application-specific" properties file (I'll call it "myapp.properties", we define a "relative reference" to a "server- specific" properties file ("myapp.local.properties"). That file is then located and loaded by code that tries several different ways to locate the local properties file - see below On our app server, we define a directory that contains all of our configuration files. Each application's configuration files is in its own subdirectory under the main "config" directory. So, for example, if our main config directory is "c:\serverconfig", under this will be a subdirectory for each web application, containing that web application's configuration file(s) - "c:\serverconfig\myapp1" etc.. The main configuration path ("c:\serverconfig" in the example above) is then placed in Tomcat's class path - in my development environment (windoze) I do this by opening the Tomcat configuration applet and adding it to the Java Classpath on the Java tab. As mentioned before each application's properties file contains a relative reference to it's "local" properties file. So our application "myapp1" will have in its "myapp1.properties" file (in its WEB-INF directory) a property called "local-properties-path" with the value "myapp1/myapp1.local.properties". In our application, we locate the local properties file by: 1. using the .getClassLoader().getResourceAsStream(..) method first (using the relative path loaded from our application properties file, it could also probably come straight from a context-parameter in web.xml I guess); 2. If that fails to locate the file, we then recursively load the classloader's parent (using the .getClassLoader().getParent() method) and use that to try and load the file, either until we find it, or until we reach the top "parent"; 3. If we've still not located the file, we try simply instantiating a File object using the relative path; Using this methodology, we've been able to load "local" server-specific properties files in Tomcat on Windows and in OC4J on Windows and Unix (don't have the actual OS to hand sorry). HTH, Rob Hills MBBS, Grad Dip Com Stud, MACS Senior Consultant Netpaver Web Solutions Tel: (08) 9485 2555 Mob: (0412) 904 357 Fax: (08) 9485 2555 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]