ColdBox Refactoring Guide

Navigation: ( WikiStart, cbFAQ, cbInstallGuide, es/start, ja/start)

This guide will show you how to refactor the ColdBox codebase in order for you to embed coldbox in a distributable application or just install in another non-standard installation. In order to proceed with this guide you will need the following:

I will demonstrate two of the easiest methods to refactor the ColdBox source for use in your server or application specific setup. Credits go to Tom Woestman, for being the refactoring pioneer.

Guide 1: ANT via Eclipse

The ColdBox install folder contains a file called refactor.xml. This file is an ANT task already developed for use in refactoring the ColdBox source code. You should have a directory layout like the one shown below as you downloaded and extracted the latest ColdBox release:

In this sample, I downloaded and extracted the archive on my desktop. So in my desktop I have a directory called coldbox. The second step is to fire up Eclipse and create a new project. Click on File > New > Project > CFEclipse > CFML Project

After you select the CFML Project, choose a name for your project, in this case its: ColdBoxRefactoring and I choose the location which is the coldbox folder in my Desktop and then click on Finish.

The project is created and you can see it in your project explorer. The next step is to actually open the refactor.xml and look at the following screenshot, it describes two properties:

  • coldbox.system_path : The location of the system folder according to its location.
  • coldbox.destination : Where to place the refactored code.

Now, you will need to change the properties to your liking. I mostly just change the coldbox.system_path to: ${basedir}\system which matches what you downloaded. You should have something similar to the screenshot below:

The next step is to actually execute the refactoring.xml ANT Task. To do this, open the install folder and right click on the refactor.xml file. A context menu will appear with tons of options, look for the one called Run As > Ant Build Look below:

Once you click on the Ant Build, the task will execute and you will get a popup similar to the one below. In this popup, fill out the new prefix of the ColdBox path. The default one is coldbox.system, and lets say that I want the new location of the framework to be on a folder called frameworks off my root and in a directory called coldbox_2_0. Then I would type: frameworks.coldbox_2_0

Do not add a final . this is appended automatically.

After you click ok, then you will be asked for the absolute path of the new location. In my case I enter: /frameworks/coldbox_2_0

Once you click the final OK, the ant task will execute and you will see the following output on the eclipse console:

This means the task executed correctly and you are ready to use the refactored code. The final screenshot below shows you the refactored system folder in the install directory and a code snapshot of some changes. ENJOY!!

Guide 2: Search and Replace

This guide is just a basic use of search and replace features of your favorite IDE, either Eclipse, Dreamweaver, or whatever. All you need to do is the following:

  1. Search for coldbox.system and replace it with {Your Prefix}.coldbox.system
  2. Search for /coldbox/system and replace it with /{Your Prefix}/coldbox/system

Enjoy your refactored ColdBox recipe.


Copyright 2006 ColdBox Framework by Luis Majano