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.

[More]

Comments
Brian Kotek's Gravatar Paul, unless I'm misreading what you're doing, I think you can accomplish the same thing in a much easier way. Instead of the custom "factory bean" calls to get each and every dynamic property, you can just pass the environment properties structure into ColdSpring when you create the Bean 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?
# Posted By Brian Kotek | 6/16/08 4:01 PM
Paul Marcotte's Gravatar Hi Brian,

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! ;-)
# Posted By Paul Marcotte | 6/16/08 4:51 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.9. Contact Blog Owner