Creates a new mapping for CFML/CFC resources. You must specify either directory or archive, but not both


BOOLEAN = MappingAdd( logicalpath, directory, archive )
Argument Summary
logicalpath logical path of the mapping
directory the directory (real path) to which the mapping will go. Exclusive with archive
archive the OpenBD archive file to use for the mapping. You can create a new mapping using MappingCreateArchive() function [optional]


Supports named-parameter calling allowing you to use the function like:


Supports passing parameters as a structure using ArgumentCollection:

MappingAdd( ArgumentCollection={
   logicalpath : ?, 
   directory : ?, 
   archive : ?
} );


Mappings are a way to create logical top-level URI (web) directories that map into a directory or a secure OpenBD archive. An OpenBD archive is a means of packaging up your CFML and CFC resources into a single file which the webapp serves directly from there. These files look like a ZIP file, but are encrpyted inside using an AES algorithm.

The following code snippet creates a new OpenBD archive. You specify the full pathname of the archive you want to create, and then the directory to which you wish to create the archive from. All .cfm, .cfc, .htm, .html, .inc files will be included, leaving out any .svn/.git/.csv directories.

<cfset MappingCreateArchive( "e:\tmp\myarchive.openbd", "E:\war\mywebapp\rpc\", true )>

Once you have created this OpenBD archive you can move this file anywhere, to any machine. Next you must register this new file. You can do this a number of ways:

Let us look at registering it using the function MappingAdd(). The following example will create a logical mapping of "aw2" reaching into the OpenBD archive for the files. It will also create this mapping at the "global" level, meaning it will persist after this call for all subsequent requests.

<cfset MappingAdd( logicalpath="aw2", archive="e:\tmp\myarchive.openbd", scope="global" )>

Once this is registered, any request to http://myserver/aw2/ for example http://myserver/aw2/test.cfm it will look for "test.cfm" inside the archive file myarchive.openbd

Mapping Notes:

  • Subdirectories are supported inside the OpenBD archive
  • Specify the archive in bluedragon.xml/Application.cfc as: openbd://full-path-of-archive@
  • The mapping is not only for CFINCLUDE/CFMODULE/CreateObject calls, but will also operate directly. For example you could put all your remote AJAX endpoints into an archive
  • If you update your archive, then be sure to clear the file cache SystemFileCacheFlush()
  • Files in mappings will be searched after it is determined the file does not exist in the phsyical location
  • Once the file has been found and cached, no more searching will be made. Flush the file cache.