We have four different environments: dev, q/a, test and prod. I decided to convert our Application.cfm to Application.cfc and put them in our source control. There are plenty application vars that have different values for each environment.
I ended up creating several sql server tables to store these environment variables based on their types. Now, I am in the middle of dynamically setting up these application variables.
My question is that I started adding custom methods inside application.cfc. I am not 100% sure if this is the best place. [For example: getAppLinks(), setAppLinks() ]. Otherwise, I could create a new cfc and call this one from Application.cfc.
All these methods are currently being called once in the onApplicationStart() method.
Does anybody have any comments on implementing custom methods in Application.cfc?
thanks
edited: added a custom method:
<cffunction name="setUpAppDSNs" access="private" returnType="void" output="false">
<cfargument name="dsn" type="string" required="yes">
<cfargument name="serverName" type="string" required="yes">
<cfscript>
var dsnNames = structNew();
var qryAppDSNs = new Query(dataSource = '#arguments.dsn#',
sql = ' SELECT dsnID, #arguments.serverName#Server, description
FROM cfAppDSN ').execute().getResult();
for (i = 1; i lte qryAppDSNs.recordCount; i++) {
dsnNames['#qryAppDSNs.description[i]#'] = qryAppDSNs['#serverName#Server'][i];
}
StructAppend(application,dsnNames);
</cfscript>
</cffunction>
If you call this method explicitly, ColdFusion does not start the application; it does execute the method code, but does not lock the Application scope while the method executes.- Travis