You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Andrea Aime <a....@satanet.it> on 2005/04/29 15:30:11 UTC

Application configuration

Hi,
I have a set of property files that allow me to configure my application.
They contain things like file system locations, database access parameters
and so on.
Now, I would like to put them outside the war file in order to make installation
easier for people not used to web app deployements, but at the same time
I would like to make those files visible only to my app (for example, I'd like
to change the log levels in log4j without unpacking the war).
So, it seems that using shared/classes is not a great solution...

What do you suggest? Is there a clean and easy solution?
Best regards
Andrea Aime


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Application configuration

Posted by Will Hartung <wi...@msoft.com>.
> From: "Dave Butler" <bu...@manxsoft.net>
> Sent: Friday, April 29, 2005 8:39 AM

> Andrea Aime wrote:

> > I have a set of property files that allow me to configure my
application.
> > They contain things like file system locations, database access
> > parameters
> > and so on.
> > Now, I would like to put them outside the war file in order to make
> > installation
> > easier for people not used to web app deployements, but at the same time
> > I would like to make those files visible only to my app (for example,
> > I'd like
> > to change the log levels in log4j without unpacking the war).
>
> Why not use Java Preferences.

Java Preferences is the way to go, but you need to provide a mechanism to
manipulate them (whereas with property files you can simply use an editor).

Ideally this mechanism is within your webapp, but you need to ensure that it
can work with potentially Really Bad values in the preferences (i.e. if your
property editor part breaks with bad properties, it's kind of hard to fix
them, eh?).

A notable scenario being "I forgot my admin password" or something else.

One thing you can do is to put a "reset" directory in the top level of your
WAR, then put a ResetProperties class within there (in the "reset" package,
of course). Then, in your webapp protect the "reset" url with an invalid
role.

Finally, when the user needs to reset their preferences, they can simply do:

java -jar WebApp.war reset.ResetProperties

and it will set the preferences to reasonable defaults. A WAR file is simply
a JAR file, so this should work just fine (I haven't tested it).

You protect the "reset" path so that it can't be downloaded over the web.

The reason you jump through these hoops is because the Java Preferences
stores its values differently on different systems. Notably it uses the
Registry on Windows, and a file on Unix (in the users home directory). But,
rather then fighting that, you can provide something that will work
consistenly across platforms by leveraging the API and Java.

Regards,

Will Hartung
(willh@msoft.com)




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Application configuration

Posted by Dave Butler <bu...@manxsoft.net>.
Andrea Aime wrote:

> Hi,
> I have a set of property files that allow me to configure my application.
> They contain things like file system locations, database access 
> parameters
> and so on.
> Now, I would like to put them outside the war file in order to make 
> installation
> easier for people not used to web app deployements, but at the same time
> I would like to make those files visible only to my app (for example, 
> I'd like
> to change the log levels in log4j without unpacking the war).
> So, it seems that using shared/classes is not a great solution...
>
> What do you suggest? Is there a clean and easy solution?
> Best regards
> Andrea Aime
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
Why not use Java Preferences.

-- 
Regards

Dave Butler
butlerdi-at-manxsoft-dot-net

Also on Skype as butlerdi

Get Skype here http://www.skype.com/download.html


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************