views:

248

answers:

1

We're looking at how to do distributed configuration within our primarily Java based deployment. We have a number of applications and it makes sense to centralise the configuration of the applications. JNDI appears to be the standard choice, probably backing off to something like ApacheDS (that way we can store non Java config in there as well). Here are some of the things that I've considered. Has anyone tried something similar? Any recommendations?:

Distributed

This would be for multiple applications on multiple machines, some of the applications would be clustered. The Directory Server should also ideally be clustered.

Lightweight

JNDI has a bit of a J2EE feel to it. Anyone use an alternative distributed configuration mechanism. The applications themselves tend to be relatively lightweight rather than full JEE applications (ok controversial whether JEE is still considered heavyweight and requirements are certainly heavyweight).

Supports fallbacks

Often the same configuration applies to multiple applications (e.g. multiple applications may connect to the same database). One the other hand, some applications may need specific configuration. Sometimes it is difficult to know in advance whether an application will use a 'global' configuration or something specific, so being able to first search for application / host specific configuration and then falling back would be good. I'm thinking of a structure something like this:

/global/host/application/instance or /global/application/host/instance:

so, start by checking to see if there is any configuration specific to this instance of the application on this host, then check if there is any configuration specific to this application for this host, then check to see if there is anything specific for this application, then try the global setting. Are there any best practices for this kind of thing?

Live configuration changes

Spring allows configuration with a jee:jndi-lookup and you can choose not to cache the value which means it is looked up each request. I'm not sure that makes sense for "String" type configuration values. It also doesn't appear to use the NamingListener way of detecting changes in the DS. It would be good to be able to update a value on the Directory Server and have that change broadcast to all of the applications that use it.

Other considerations

  • Managing different environments
  • Adding the configuration to source control so that it can have change management applied to it
  • Managing different versions
  • Rolling back
+1  A: 

Have you considered using a database to store the application configuration? Apache Commons has a DatabaseConfiguration class that exposes your table as a java.util.Properties instance (see http://commons.apache.org/configuration/apidocs/org/apache/commons/configuration/DatabaseConfiguration.html).

Sasi
+1 Commons Configuration actually looks quite interesting... thanks.
jamie mccrindle