Blog

Luis Majano

October 15, 2008

Spread the word


Share your thoughts

As you know, ColdBox is now fully supported for BlueDragon and Railo. However, to port it was a bit tedious when it came to the auto-registration engine for handlers, since I need to traverse the handlers directory recursively and create an array of handlers. This is so easy in Adobe ColdFusion, but BlueDragon and Railo, does not support it (BD 6, railo 1). Here is the Adobe ColdFusion code: That is awesome!! So easy!! Well, to do it the Java Way, takes some patience and well, some insight into recursion. The following example is using the CF/JAVA hybrid notation, but the end result is the same as above. And with some speed tests, the code actually compares, not that much of a slow down. So :) Here is my call to the recursion, the entry point: What I do is call my recurseListing method with the handlerArray I want the results in, the handlersPath into the initial directory and the working directory. Why do I send in the HandlerPath again? Well, I do it, to actually clean the path to show me the invocation paths, mumbo jumbo!! Give me the code!! Here it is: Remember that this code is not to get the query like cfdirectory, it could, but you will have to do that, I am just showing how I solved my problem. This is a great exercise also. //Init the oDirectory object with the initial working directory (Java File Object) var oDirectory = CreateObject("java","java.io.File").init(arguments.Directory); //Get an array listing of the objects in the directory var Files = oDirectory.list(); //My Index. var i = 1; //My temp File Object var tempfile = ""; //My clean handler string. var cleanHandler = ""; //Loop Through listing if any files found. for ( i=1; i lte arrayLen(Files); i=i+1 ){ //get first File reference as a File Object tempFile = CreateObject("java","java.io.File").init(oDirectory,Files[i]); //Directory Check for recursion, if directory, then recurse. if ( tempFile.isDirectory() ){ //recurse, directory found, send in the new directory path. arguments.fileArray = recurseListing(arguments.fileArray,tempFile.getPath(), arguments.HandlersPath); } else{ //File found //Filter only cfc's, I could have used a Filter Java object, but was lazy. if ( listlast(tempFile.getName(),".") neq "cfc" ) continue; //Clean entry by using Handler Path (For my specific purposes) cleanHandler = replacenocase(tempFile.getAbsolutePath(),arguments.handlersPath,"","all"); //Clean OS separators accordingly if ( getSetting("OSFileSeparator",1) eq "/") cleanHandler = removeChars(replacenocase(cleanHandler,"/",".","all"),1,1); else cleanHandler = removeChars(replacenocase(cleanHandler,"",".","all"),1,1); //Clean Extension right off baby cleanHandler = getPlugin("fileUtilities").ripExtension(cleanhandler); //Add data to array, a cleaned Handler, thank you GOD, bless you. ArrayAppend(arguments.fileArray,cleanHandler); } } //else return the empty array or filled array. return arguments.fileArray; There you go, you can follow the comments to tell you what I did. This is an awesome exercise and shows you how ColdFusion is really powerful by leveraging its Java backbone. When things like this just work, it just amazes me of how ColdFusion has evolved and how EASY it is to overcome problems by leveraging Java. Viva Java Mis Amigos!! Viva!! Viva!! Hope you enjoy this little java/cf/recursion tutorial. This example shows potential of how you can build your own recursion methods.

Add Your Comment

Recent Entries

Into the Box - Celebrating 20 years of Ortus - Big time!

Into the Box - Celebrating 20 years of Ortus - Big time!

Into the Box 2026: Celebrating 20 Years of Ortus, Big Time! šŸš€

For two decades,Ā Ortus SolutionsĀ has been building, innovating, and empowering developers around the world. What started as a vision to create bet...

Victor Campos
Victor Campos
March 18, 2026
TestBox 7 : Real-Time Streaming, a Browser IDE, and a Major Leap for BoxLang

TestBox 7 : Real-Time Streaming, a Browser IDE, and a Major Leap for BoxLang

TestBox 7.x series continues our mission to be the best testing framework for BoxLang and CFML. This release is focused heavily on BoxLang CLI runner enhancements, real-time streaming test execution via SSE, a powerful dry run capability, the brand-new TestBox RUN web IDE, and significant quality-of-life improvements for developers working in both BoxLang and CFML environments.

Luis Majano
Luis Majano
March 17, 2026
From Legacy Risk to Modern Agility: A Phased Modernization Roadmap for CFML Teams

From Legacy Risk to Modern Agility: A Phased Modernization Roadmap for CFML Teams

Many organizations running CFML applications today face the same challenge.

Their systems still work.

They support core business processes.

They generate revenue.

But at the same time, those platforms are increasingly exposed to risk.

Unsupported runtimes, operational fragility, security exposure, and difficulty integrating with modern systems are becoming more common in environments still running older versions of Adobe ColdFusion or Lucee.

The quest...

Cristobal Escobar
Cristobal Escobar
March 16, 2026