Posted: April 21, 2010 at 8:50 AM by jbuda
Tags: Railo, Coldbox, Transfer, Coldfusion
The previous part of this step-by-step process of setting up the Coldbox / Coldspring and Transfer can be found here.
The next steps in this process is to start hooking up Coldbox config with Transfer. To begin with i created another configuration file called datasource.xml.cfm. This holds the values for the datasource that include name of dsn, username and password. The username and password, if left blank, will use the values from the Coldfusion/Railo admin.
datasource.xml.cfm
<datasource xmlns:xsi="xsd/datasource.xsd"> <name>YOURDSN</name> <username></username> <password></password> </datasource>
The file for the datasource was saved into the same config directory as the other xml files. The Coldbox.xml.cfm was updated to include the datasource file so that this can be used to link up to the database. The following was added into the Coldbox file to get it linked to the datasource and the Transfer config file. The definitions directory is populated with files that are generated when the application is initialised with Transfer ORM. The values of these need to reflect the locations of the files that were created previously.
coldbox.xml.cfm
<YourSettings> <Setting name="TransferSettings.datasourcePath" value="/config/datasource.xml.cfm" /> <Setting name="TransferSettings.configPath" value="/config/transfer.xml.cfm" /> <Setting name="TransferSettings.definitionPath" value="/config/definitions" /> </YourSettings>
After these have been added into the relevant config files, then Coldspring needs to included into the setup. Using the Coldbox.xml.cfm file and in the settings node of this file, the following was added into it :
coldbox.xml.cfm
<Setting name="IOCFramework" value="coldspring" /> <Setting name="IOCDefinitionFile" value="config/coldspring.xml.cfm" /> <Setting name="IOCObjectCaching" value="true" />
The IOCFramework can either be 'Coldspring' or 'Lightwire', in this case we are using Coldspring for object injection. IOCObjectCaching can be set to false but in production mode for the application it is wise to set it to true for caching of objects/cfcs. The final part of this setup, is to create our coldspring.xml.cfm file so that we can begin to use the IOC for our object injection. A basic setup of this file is shown below, and this gets Coldbox and Transfer both utilizing Coldspring.
coldspring.xml.cfm
<bean id="ColdboxFactory" class="coldbox.system.extras.ColdboxFactory" autowire="no" />
<bean id="Coldbox" factory-bean="ColdboxFactory" factory-method="getColdbox" />
<bean id="transferFactory" class="transfer.TransferFactory" singeleton="true">
<constructor-arg name="datasourcePath"><value>${TransferSettings.datasourcePath}</value></constructor-arg>
<constructor-arg name="configPath"><value>${TransferSettings.configPath}</value></constructor-arg>
<constructor-arg name="definitionPath"><value>${TransferSettings.definitionPath}</value></constructor-arg>
</bean>
<bean id="Transfer" factory-bean="TransferFactory" factory-method="getTransfer" singleton="true" />
This concludes the setup in my configuration files that enable me to get Coldbox, Coldspring and Transfer working together. It is important to note that the code in this post are all snippets and only display portions of the actual config files. For complete documentation and a run down of how each file needs to be setup, then please go to the relevant site to find out more :
The next step for this setup, i will cover how to start using Coldbox to utilize the configuration that has been created and show how easy and quick it is to build applications with this. However, if there are any questions of things that are not clear, please comment through the form below and i will do my best to answer any queries.

Jun 30, 2010 at 7:41 AM Where's part 3? You've got me on the edge of my seat.
Jun 30, 2010 at 8:26 AM @Tim, i have not managed to get Part 3 up yet. Should be up in the next couple of weeks when i get some spare time. Is it easy enough to follow?