tracker issue : CF-3713264

select a category, or use search below
(searches all categories and all time range)
Title:

Allow dynamic addition of application mappings outside of Application.cfc

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/

Reporter/Name(from Bugbase): Bradley Wood / Bradley Wood (Bradley Wood)

Created: 02/25/2014

Components: Application Deployment

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: PublicBeta /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Platforms All

Vote Count: 0

It is difficult to add app mappings outside of the actual Application.cfc file.  The information is available here:

getPageContext().getFusionContext().getApplicationCustomMappings()

When there are no app mappings, this is null.  

Provide a built in function to access the struct of app mappings so developers can modify them as necessary to add additional mappings on the fly based on installed packages, etc.

There is a rather specific use case for this in the ColdBox framework that I can expand on it you're curious.

Also, an alternative method of solving this is already implemented in Railo.  The cfapplication tag has an action of "update" which can be used to update ANY application setting in your app.  That would also be a good solution and it looks like this:

// Add an app mapping on-the-fly in Railo:
var mappings = getApplicationSettings().mappings;
mappings[ name ] = path;
application action='update' mappings='#mappings#';

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3713264

External Customer Info:
External Company:  
External Customer Name: bradwood.com
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

Note: another way I found to access mappings is via application.getApplicationSettingsMap() or application.getApplicationSettings() in CF9. One can add mappings there and they will get picked up, but that is not an official, documented method. CF does have the getApplicationMetadata() function, but unfortunately adding mappings to the struct returned from that function ONLY works if there was at least one app mapping to begin with.
Comment by External U.
13217 | February 28, 2014 12:21:26 PM GMT
Mapping metadata is being made available to applicationMetadata even it is not defined in application.cfc/application.cfm. Now a developer can add application mapping programmatically at runtime without any issue. Just a note of caution, the added mapping would be available only for that request. The updates are never persisted and rather the application settings are loaded in the beginning of each and every requests.
Comment by Awdhesh K.
13218 | March 07, 2014 01:45:48 AM GMT
Thank for the update Awdhesh, that's perfect! And I understand that it would be on a per-request basis. That only makes sense seeing as how app mappings are re-parsed every request in Application.cfc and can be dynamic.
Comment by External U.
13219 | March 07, 2014 02:57:11 AM GMT