Category Filtering: 'ColdFusion'
I want to be able to define in my service definition that for example my UserService will receive this instantiated object as a dependency. How do I define this? Is this possible? Am I totally deranged for trying to do this? Any thoughts? Do you understand my dilema?
I know I can inject it later by hand coding it, but I don't want to do that, I want Coldspring to do this for me. Is this possible?
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.
This is the day we came up with my superior of a way to stimulate diversity, learning and fun for the developers, at least once a week. Our developers can work on personal projects or just learning projects every friday. As long as there are not any pending deadlines, production issues or overwhelming issues.
This has been phenomenal. We have developers learning Flex, creating new web 2.0 apps, showing off their personal projects, and basically promoting learning and a little bit of FUN!!
So managers, listen if you dare!! I did!! and it has paid off. We have been getting the best ideas every friday now. New techniques, getting to play around with new frameworks, specially ColdBox (had to throw the marketing here) which is AWESOME, coldspring, etc.
To tell you the truth, if it were not for this day, I will have not begun to play around with coldspring, which I am a total newbie and need to start learning it so I can extend it for ColdBox.
This is my testimony and it has really improved the learning environment. So developers out there, bother your managers and bother them again, so you can have one day of the week to learn and inspire.
Just a note that i took my ColdFusion 7 Certification friday at 4:00 PM. Well, got an 88%!! The studying payed off. My only material for studying was Ben Forta's Macromedia ColdFusion MX7 Certified Developer Study Guide which is a great study aid. However, the best tool is actually using ColdFusion in you daily work.
I can now upgrade my certification, Hooray!!
For any eclipse newbie, you will find out that all the plugins you download or update will be placed by you or the update manager in the eclipse install folder under the plugins directory. However, when updating comes around or removing or any kind of update, it is a hassle to manage it. That is why you can create multiple plugin extension directories in order to facillitate plugin management. I have attached a simple zip file with the correct format of an extension directory.
It basically contains the following structure:
+MyPlugins (Dir)
|--+eclipse (Dir)
|--features (Dir)
|--plugins (Dir)
|--.eclipseextension
The .eclipseextension is a text file that contains the following:
id=org.eclipse.platform
name=Eclipse Platform
version=3.1.0
You now have a succesfull extension directory. You now can go to eclipse to add it.
1) Open Eclipse
2) Click on Help ==> Manage Configuration
3) Click on Add An Extension Location:
4) Choose your directory
5) Restart your workbench
6) You are set and dandy!! Ready to roll!!
Hope this works for you. I have also a testing eclipse extension folder, so I can drop and test new plugins without affecting my workbench.
Here is the link to it:
http://labs.macromedia.com/wiki/index.php/ColdFusion/Flex_Connectivity:Eclipse_RDS_Support
Here is their description:
Remote Development Services (RDS) lets you access files and data sources registered in the ColdFusion Administrator on a ColdFusion server. You must enable RDS during the installation process. With Eclipse RDS Support, you can use CFEclipse as your IDE and access ColdFusion files remotely.
Eclipse RDS Support is supported on all ColdFusion server platforms.
I will be installing it soon, so I will let you know how it goes.
UPDATE
The link to RDS is confusing. You need to go here
You need to go to the Flex Builder 2.0 Beta 2 downloads and download the
following:
Download ColdFusion Extensions to Flex Builder 2.0 (ZIP, 1.8 MB)
You then extract it and move it to your eclipse plugins directory.
Basically, cfcompile is not supported on MAC OS X (Am I right here???). So I decided to fool around a bit to see if I could figure out why. Well, basically, I created a new case in the cfcompile.sh script for the Mac OS "Darwin" and made sure that it would point to the correct places to compile the source into java bytecode.
I am attaching the full cfcompile.sh script for you to try out. Here is a sample of the case for the -deploy argument:
Darwin)
OS=Darwin
/bin/sh -c "${Setting: _JAVACMD not found} -cp $CLASSES -Dcoldfusion.classPath=$CFUSION_HOME/lib/updates,$CFUSION_HOME/lib -Dcoldfusion.libPath=$CFUSION_HOME/lib coldfusion.tools.CommandLineInvoker Compiler -deploy -webinf $WEBINF -webroot $webroot -cfroot $CFUSION_HOME -srcdir $srcdir -deploydir $deploydir"
;;
I removed the su, since in Mac OS, the cfmx engine runs under the install user. So there was no need to su to that specific user.
I in no way support this tinkering, do at your own risk. I may be doing it wrong or badly, however, it has worked for me.
I am attaching the cfcompile.sh for you to download.
Hope you enjoy it.
Thanks to Dave Stanten at Adobe, for sending me the technote and resolving this issue: Tech Note
ColdFusion MX 7 Gateway Connection URL
If you are using Flash Remoting to access ColdFusion code, you may run into an issue where ColdFusion constructs an invalid URL when appending a jsessionid. If this occurs, the web server that is accessing your code could throw errors. The solution is to simply add a question mark (?) to the end of the gateway URL. Change /flashservices/gateway to /flashservices/gateway?. This ensures that the URL is created correctly.
I only had this problem with flash player 8 and 7 for the MAC, but standalone only. If I used the flash player plugin within a browser I was ok or if I used any form of the flash player on Windows.
Also, the tricky part is that the Coldfusion logs report the following, which is due to the malformed URL's:
[Flash Remoting MX]->Request received was not Flash-based (not of the binary AMF protocol)
So lookout for this tricky bug if you come upon it. A single character can make a difference. :)
Happy Remoting!!!