Dynamic Configuration with Environment Config And a Coldspring Config Factory
When developing web application, it is very likely that at some point you will need to create dynamic configuration for your application in terms of development, staging and production environments. I recently discovered the excellent Environment Config project by Rolando Lopez. Rolando has created a very interesting package with lots of robust features for configuring your application dynamically. There are portions of the package that I must admit, I'm not using (yet). What follows is my current setup for integrating the environment config with a custom factory.



<cfset environment = CreateObject( 'component','components.utility.Environment' ).init(xmlFile='/config/environment.xml')
<cfset globalProperties = environment.getEnvironmentByID('dev') />
<cfset application.beanFactory = CreateObject('component', 'coldspring.beans.DefaultXmlBeanFactory').init() />
<cfset application.beanFactory.loadBeans(globalProperties.coldSpringConfig, globalProperties) />
In that case, you're just passing in the struct containing your properties to ColdSpring, and it will replace any of your dynamic properties where you're using the dynamic property syntax ${myProp}. Make sense, or am I misunderstanding what you're trying to do?
See you at CFUnited?
I had intended on passing the ConfigFactory to any services that required access to specific settings, but I see where your suggestion is much more simple for passing the dynamic parameters rather than writing bean references for them.
I guess it's back to the drawing board for me! ;-)