Monthly Archives: May 2008

Coldbox, ColdSpring, and Transfer – Dynamic Datasource Support

We know how to use the Coldbox environment interceptor to load different values for datasources. We know how to circumvent datasource.xml files with Transfer by using a datasource bean. Now, how can we use ColdSpring to put it all together for us.




That’s what my coldspring.xml file would look like. There are a few things to note. I use Coldbox to get the Datasource information I need because it has already been defined in the Coldbox config or environment file. This is the reason I wanted to avoid a datasource.xml file for Transfer. Otherwise, I’d have the same DSN info repeated all over the place.

I also point to model.TransferConfig. A simple extension of the Transfer Configuration bean. You can learn more about that from my previous post.

If you notice, there is a Transfer_DSNAlias argument being passed into the Coldbox getDatasource method. This tells CB which DSN you want to load up and pass on to Transfer. Coldbox allows for multiple datasources to be stored for use in your App. But Transfer only connects to one at a time. So I made it a setting in the config/environment.

Here’s a peak at my environements.xml file.

That’s it.

Dynamic Datasources With Transfer – Using a Datasource Bean Instead of the Datasource.xml

By default Transfer expects a path to a datasource.xml file. However, the TransferFactory.init() method will accept a configuration bean. Which you can find in the path. The Configuration.cfc init() method is only looking for paths as arguments, and sets the DSN username and password to blank on creation. The object does have a hasDatasourceName() method, so how do we utilize this?

Well, I extended the object and overwrite the init() method.
It now accepts a datasource bean and sets the DSN info in Transfer with it.
When Transfer natively calls hasDatasourceName() it will bypass checking the datasourcePath.

variables.instance = StructNew();




return this;

Overriding Complex Values in Coldbox Config File with the Environment Interceptor

I talked previously about the abilities of the new Environment Interceptor in Coldbox. The next step was to wire it up so I could automate the initialization of Transfer using ColdSpring and these environment specific values from Coldbox.

Before I get into that I needed to know how to overwrite complex values, like Datasources, set in the Coldbox config file with those from the environments.xml.

Luis was kind enough to point me in the right direction, and said dump the ConfigSettings struct and Transverse whatever you want. That I did, using JSON notation. Just substitute single quotes for double quotes maintaining valid XML format.

Coldbox Environment Interceptor updated to Support RegEx

The latest release of Coldbox 2.6.0 RC1 is like every other Coldbox release…Filled with goodies.

For now, I am keying in on the Environment Interceptor. It allows you to specify a different set of configuration settings based on the environment your application is running in. You are no longer limited to a single config file and the settings bound to it.

By default, Luis uses URLS specified in the environments.xml and looks for them in the cgi.http_host. While it is effective, I have always liked the flexibility of regular expressions.

I have updated the code to accept a PATTERNS attribute from the config xml file and use the pattern as a regular expression against the cgi.http_host.

It extends the environmentControl interceptor that is distributed with CB, and is completely backward compatible.

Get the CODE –

If you want to use the PATTERNS leave the URLS empty.

I thought about using both URLS and PATTERNS together, but with regEx you can pretty much capture any URL.

The environments.xml.cfm would look like:

The interceptor in the config.xml.cfm would look like:
(only difference here is the class path – no longer points to coldbox.system.interceptors)


For more on the latest release, check out What’s New in Coldbox 2.6.0

How to use SVNSERVE with Shared Folders in a VM or a Mapped Network Drive

I had posted a while back about setting up a Subversion Server on a Windows machine. However, now I am running my SVNSERVE on a Windows 2003 Server Virtual Machine with VMWare. With the Shared Folders feature I am able to access my repositories from the HOST machine.

When I tried to set it up as a service using the code provided in my earlier post, I kept getting errors when starting the service. I tried mapping a network drive, in order to avoid the double slashes in the URN path to the share, but no dice.

After a good noggin knock it was apparent the syntax needed to be tweaked when using the URN path to allow for the double slashes.

Use the following single-line command:

sc create “svnserve” binpath= “”C:Program FilesSubversionbinsvnserve.exe”” –service –root “”\.hostShared FoldersDEVrepo”””” displayname= “”Subversion Repository Server”” depend= Tcpip start= auto”