Advanced Configuration of the Spring MVC Framework
Subject:   Additional way to configure
Date:   2006-03-23 02:14:30
From:   Andrew_Sazonov

Hi Dejan!

Thank you for your great article - it's very useful and it was real pleasure for me to readit.

I'd just like to note that there could be another way to configure web application. This is approach I've used and it worked find for me.

Actually, this is combination of property placeholder and ContextLoaderListener.

The project I'm worked on included several web servers which may be added dynamically. Including all possible configuration files in war or building war file for every deployment was not acceptable option due some project' requirements.

Briefly, I've used the following scheme:

  1. ContextLoaderListener was extended so during context initialization it was able to either
      load properties from properties file located on predefined location specified in web.xml (all servers has the same location of that property file, while content of it, of course, was specific for particular server) or
    • load property file from specific URL;

  2. After retrieving Properties, ContextLoaderEx simply stores PProperties it read in ThreadLocal variable.
  3. To retrieve configuraiton properties, I extended PropertyPlaceholderConfigurer and that class was able to retrieve properties from saved threadlocal.

That's all - such a solution allowed me to have single .war file for arbitrary server, but have ability to convigure them individually.

If someone is interested in details, I'll be glad to provide sample code.

I hope my solution could be helpful

Best regards,

Andrew Sazonov


1 to 1 of 1
1 to 1 of 1