Want a free ticket to CFUnited?
http://www.railo.ch/blog/index.cfm/2009/7/14/Win-a-CFUnited-ticket
Category Filtering: 'getrailo'
http://www.railo.ch/blog/index.cfm/2009/7/14/Win-a-CFUnited-ticket
Finally, a way to interact with java nulls easily. So all you do to create null values is do
if ( isNull( CacheManager.get('key') ) ){
writeoutput("object is not found in cache")
}
What if you need a null value?
cacheMap['luis'] = nullValue()
Two very simple functions, but they sure make life so so so much easier when integrating with java. This to me are my favorite two new functions.
Let's say I have a method that returns an array. Example below:
As you can see, a very simple example. So now, in my code outside my method I want to be able to access let's say item number 3 from the method call and the key called awesomeLevel from the structure call. Then I can do this:
item3 = getArray()[3];
MyAwesomeLevel = getStruct()['awesomeLevel'];
How cool is that, finally!! Array syntax from method calls.
Let's say you want to assign a value to multiple variables in coldfusion. You would usually do this:
Name = "Luis Majano";
ColdboxAuthor = Name;
CodexAuthor = Name;
AwesomenessAuthor = Name;
That is really neat right, well, Railo makes it fun!
Name = "Luis Majano"
ColdboxAuthor = CodexAuthor = AwesomenessAuthor = Name
How about that!! I can assign values to multiple variables, by just concatenaning the equals. Keep exploring Railo and you will find some nice hidden gems.
The websites look phenomenal and we also get a documentation website powered by Codex. I wonder who did the initial documentation?
You can download the open source version of Railo from their nice downloads page.
/* Start Exporter */
sqlBuffer = createObject("java","java.lang.StringBuilder").init('')
/* Create Function Namespace */
createNamespace(fncNamespace)
/* Read fnc Library */
xmlDoc = xmlParse(expandPath('web-cfmfunctionlibrary_1_0'))
fncXML = xmlSearch(xmlDoc,"//function")
fncXMLLen = arrayLen(fncXML)
I like this! No more noisy semi-colons. Just beware that if you are doing multiple statements on a single line, you will actually HAVE to put in the semicolons.
function formatnow(){ return "#dateformat(now(),"yyyy-mm-dd")# #timeformat(now(),"HH:mm:ss")#"; }
A part from that, I love it!
At least much easier than trying to do serialization and deserialization with java. Anyways, I thought I would share this little tip:
myStruct = {fname:'Luis',lname:'Majano',great:'You Know it!!',
dates:[now(),now()+1,now()+2],
TodayIs:'#now()#'};
dump(myStruct);
//Serialize the struct
MySerialization = serialize(myStruct);
writeOutput("MySerialized Structure: #MySerialization#");
//Reinflate it back.
NewStruct = evaluate(MySerialization);
dump(newStruct);
This step by step guide is to show you how to install Railo and create a connector to Apache in Mac OS X. I am now using Railo as my development environment due to its speed and strict coding that I can assign to it. This makes sure that every ColdBox release is what it is supposed to be. I am still amazed at how fast and stable Railo is and I highly encourage you to give it a shot!
Anyways, now for the fun.
1) Download Railo from http://railo.ch/en/index.cfm?treeID=224
I downloaded the All OS download: railo-3.0.1.000-resin-3.1.2-without-jre.zip (39 MB)
Once downloaded I unpacked it and installed it in
/Applications/railo
2) Remove some windows files, because I am a cleanup freak.
rm -rf httpd.exe setup.exe win32
3) Let's compile the apache connector by following these commands, but first cd into the Railo directory via your terminal.
$ cd /Applications/railo
$ ./configure --with-apxs=/usr/sbin/apxs --with-java-home=/System/Library/Frameworks/JavaVM.framework/Home
Update:
For java in 64 bit mode (snow leopard or leopard), use the following command:
./configure --with-apxs=/usr/sbin/apxs --enable-64bit
This should spurt out a long list of compilation checks and please look at my java home as my default jvm in my Mac. Once it finishes it should finish with the following:
configure: creating ./config.status
config.status: creating Makefile
config.status: creating modules/c/src/Makefile
config.status: creating modules/c/src/common/Makefile
config.status: creating modules/c/src/apache1/Makefile
config.status: creating modules/c/src/apache2/Makefile
config.status: creating modules/c/src/resin_os/Makefile
config.status: creating contrib/init.resin
config.status: executing depfiles commands
This means we are done. So now let's make and install the mod_caucho.so connector.
$ make
$ make install
After this, you should be A-OK. The script will copy mod_caucho.so to /usr/libexec/apache2/mod_caucho.so and modify your apache conf with
#
# mod_caucho Resin Configuration
#
LoadModule caucho_module /usr/libexec/apache2/mod_caucho.so
ResinConfigServer localhost 6800
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
Now it is up to you if you want to configure specifc virtual hosts to use resin or not. Example:
ServerName railo.jfetmac
DocumentRoot /Users/lmajano/Documents/MyDevelopment/
Options Indexes FollowSymLinks MultiViews Includes
DirectoryIndex index.html index.htm login.cfm index.php index.cfm
ResinConfigServer localhost 6800
CauchoConfigCacheDirectory /tmp
CauchoStatus yes
SetHandler caucho-status
Now we open the /Applications/railo/conf/resin.conf and add a few aliases that map our web application to apache:
After that just fire up apache and the resin server by running:
/Applications/railo/bin/httpd.sh
After that, the server runs and your application is up and running!!
Update
Some people have not been able to compile mod_caucho because Apache is running in 64bit mode and the caucho mod is 32 bit mode. Here is some extra help for you:
Here's how to change your apache to run in 32 bit mode.
From Adobe.com
---------------------------------------------
To switch Apache from running in 64-bit to 32-bit on Mac OS X 10.5, do the following:
1. Go to /usr/sbin and make a backup of httpd (for example,
httpd.back).
2. Run the following command from the terminal:
sudo lipo httpd -thin i386 -output httpd
3. To confirm the resulting http architecture, from /usr/sbin, run
the following command:
file httpd
4. The file command should give httpd:Mach-O executable i386.
5. Restart Apache by running the following command:
sudo ./apachectl restart
6. The conf file (httpd.conf) location remains the same
(/etc/apache2).
What: ColdFusion Camp 2008
When: November 27th from 9am to 6pm
Where: Conference center Orbis, Oberschleißheim
Price: 35 Euros!
You can find more details at http://www.cfug.de
Would this be a bug on the Adobe cf java proxy? It seems to me, because the same tests on Railowork (even faster to say the least)!!
To reproduce this error, just try this below:
The string is #myBuffer.toString()#
The length is #myBuffer.length()#
The error that Adobe CF produces is that the method length() does not exist. The only workaround for this is by lengthing the string produced, but it will definitely be slower than a direct length call:
Length: #myBuffer.toString().length()#