May 10th, 2007, 11:12 AM
Managing Spring configurations across platforms
I have based a few Java SE RMI client/server applications on the spring framework.
As these applications approach release time, I am facing the problem of managing the difference of configurations between my platforms. I have at least 3 of them:
- the developper platform (assuming all of them use the same settings, "localhost", file path,...)
- an internal integration platform
- the customer's production platform
("at least", because additional platforms may be: developpers may have differing settings, validation platform setup by the customer,... but they seem closely derived from one of the main 3).
The differences between these platforms are:
- properties of "external systems": host, port, login/pwd, folder,...)
- different implementations of beans: for example on the developper platform we have a a StubbedBillingService to stub out the BillingService that is developped by a contractor; on the integration platform we have a FakeSecurityService, a fake implementation of the customer's auth&auditing service, which enables us to inject behaviors (errors, events,...) in a programmatic way without needing to use the actual security servce (and, harder yet, to creeate erros and events with the actual service).
- different configuration files (not Spring files)
My naive assumption was that a PropertiesPlaceholderConfiguration would be enough, but that fails:
- either a common property file is retrieved from the CMS, and at some point it will require manual edition to tailor it for the platform.
- or each platform has its own version of the property file, which inccurs a lot of redundancy and syncing work (new property added to config for platform 1 and forgotten on config for platform 2 -> yuck!)
- differences are not reducible to just values of properties: the FakeSecurityService, for example, has some properties that the real service doesn't have, and vice-versa. I really need different <bean ...> sections for those two.
I found an article (http://www.onjava.com/pub/a/onjava/2...iguration.html) which suggests using <import ... /> tags to import parts of the spring-beans.xml file form a host-specific spring-beans-platform.xml, and even suggest a mechanism where the import file is named after the host's name, but I can't tell the hostnames in advance, especially for the customer's platforms.
My general question is: what are your suggestions to manage (development, CMS and deployment) such platform differences?
I have started thinking of a possible solution if I had a way to import the specific definitions from a file whose name is built using a system property such as -Dplatform.id=production (I think I can require editing of the launch script by the platform admin, ).
I don't know which Spring API to use to make Spring load a generic spring-beans.xml and import a variable spring-beans-<platform>.xml.
Can you help me in this direction too?
Thanks in advance.
May 10th, 2007, 10:08 PM
How about maintaining different context xml files for each configurations. You can then control which gets loaded by a property file that just contains the path to your config. You can use ClassPathXmlApplicationContext for this.
PropertiesPlaceholderConfiguration has always worked for us. you can try using the "locations" property to pick up your specific overrides for each configurations.