Tech Blog

EnvironmentConfig - About

by Rolando on Jun.03, 2009, under EnvironmentConfig

EnvironmentConfig (EC) aims to solve a problem developers face when using multiple tiers in the development lifecycle.  That is that each server/environment may have properties that do not match the other servers. For instance, in a three tier development setup (development, staging and production) you may find that the data-source names (DSN’s), mail server address and credentials, path to certain folders, etc. differ from server to server.  On each deployment or every time a patch is applied, the developer must ensure those variable properties are correct or else the application will break.  Ensuring each environment contains the right values for each property may become a tedious process, especially if the application evolves constantly.

EnvironmentConfig address this issue by allowing the developers define each environment and properties in an XML file once. This file is processed when the application starts and EC will automatically detect the environment the application is running at, based on the domain name. The environment’s specific properties are loaded and available to the developer for use in a several ways depending on configuration set.

stProperties

By default EC will return two structures with the properties set in the XML file. One follows the exact configuration set in the XML where you can declare both, simple values and structures of properties. This one is called stProperties .

stFlattened

stFlattened return the same properties and values as stProperties, however it flattens all structure properties and contains a single structure with all properties as single values.

GlobalConfig object

EC can be configured to create a GlobalConfig object (CFC). GlobalConfig is the default name but it can be named as desired and the path where is created can be set as well. If told to, EC will create this ColdFusion Component on the fly as a Bean with setters and getters for all the properties of that environment. The setters are set to private access while the getters are set to public encapsulating the properties and making them read-only through the life of the application.

You can choose to use any of the three options mentioned above to store and access the application properties. To make the accessible from anywhere in the application, you should place the selected option in the Application scope.

Notice that if the structures are used to handle the properties without the GlobalConfig object, these can be overwritten at anytime during the life of the application, while the properties are protected if the GlobalConfig object is used.

To Install EnvironmentConfig you can create a ColdFusion mapping to the EnvironmentConfig folder or just drop it in the root of your website.

:,

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...