Thursday April 05, 2007 I'm working on a reasonably large (1000+ source files) J2EE application that makes extensive (some might say utterly excessive) use of external components - it requires in the order of 50 JAR libraries to run, over and above the standard J2EE ones.
And of course many of those JAR files have their own unique XML files to configure them.
And of course many bits information related to the configuration of the application (URLs, database details etc) have to be repeated in more than one of those XML files.
And there's no global way of doing this.
So the people who originally wrote the application came up with a scheme - they'd store the configuration values in property files.
But that only helped for things that got the values dynamically, for example by using the J2SE Properties class. All those external components they'd used didn't know anything about the application's property files, they only knew about their own unique little XML files.
So the people writing the application came up with another scheme - they'd embed tokens in all those little XML files, then use the Ant Filter task to replace them at build-time with the values from the property files.
"Job's a good 'un!" they doubtless exclaimed, flushed with their extreme cleverness.
Then I came along and had to maintain the beast, when I found:
All this means that there's a whole series of bear traps set for anyone who innocently changes any of the properties files of the application, in the mistaken assumption that the application will actually take any notice of them.
I'm sure I'm not the only person to have been hit by this problem - how to configure multiple external components which all have their own XML configuration files - without having to hand-edit each of the XML files each time every time something changes, and without hard-coding the configuration at build time. However I'm damned if I know of a good way of doing it - although I can easily think up several not-very-good ways of doing it.
If you know, please let me know!
Posted by Roland Kaufmann on April 07, 2007 at 07:54 PM BST #