Railo archives

One of the minor disadvantages when you have a compiler is, that the initial load of a website takes quite long since all uncompiled cfm files first have to be converted into java bytecode. Sure, Railo 1.1 has tremendeously improved the compiling speed (by factor 5!!!) but nevertheless this is something that has to be done. It would be a cool thing to have an application completely compiled, or even better only delivered as bytecode. This is where Railo archives come into play.

Another scenario is for instance if you want to deploy a certain application and you want to protect your code. Other engines use an encryption mechanism for protection. Railo takes a different path. With Railo archives you are able to only distribute the binaries, with no way to decompile these files into the original code.

So what are Railo archives?
Railo archives are the same as JAR files. They contain the java binaries in zip format. And it is possible to let the application execute without having the cfm-files on the server.

How can I use Railo archives?
If you have an archive of an application from your software distributor, just add the location of the archive to a mapping definition. The simplest example is the Railo Administrator. You can see it when you call the mappings page:

As you can see, if you place the mouse cursor over the archive input field (after save) you can see both the virtual and physical location of the archive.
An example mapping definition looks like this:


virtual:    /railo-context
physical:    {railo-web}/context/
archive:    {railo-web}/context/railo-context.ra
primary:    physical
trusted:    Yes

What does the primary setting cause?
When Railo looks for a certain file, this setting defines where Railo first looks for the requested file. In the mapping or in the physical directory. This has a larger influence on the way applications can be distributed and customized.
If you have an application that can be customized by changing files in a folder named design then it is adviseable to create an archive that contains everything of your pages except the customizeable files in the design folder. Then you define a mapping that uses this archive and place the design folder containing only the customizeable files into the physical path of the mapping. When you now set the primary to archive, Railo will only look for the customizeable files in the physical direcory named design since these files are missing in the archive. Cool!

What does the trusted setting cause?
The trusted setting does exactly the same as it does in other CFML engines. Except that you can switch the trusted cache on and off per mapping. This setting will significantly boost the executing performance, since no filechecks have to be made anymore. At least for this certain mapping.

How do I know that an archive is used and not my CFM file?
This is quite easy to find out. Just turn on debugging and check the list of the files that have been accessed for this request. You will see entries like this:

...
ra://d:\projects\test\WEB-INF\railo\context\railo-context.ra!/admin/admin_layout.cfm
...

Then you know, that the file /admin/admin_layout.cfm from the archive d:\projects\test\WEB-INF\railo\context\railo-context.ra has been accessed.

How do I create an archive?
Here are the steps you need to do in order to create your own mapping.
  • Define a mapping for you application
  • Compile the mapping using the compile button in the Railo Administrator
  • Navigate to the /WEB-INF/railo/cfclasses directory
  • In there there is a mapping that is named like the physical path to your mapping without special characters (i.e. CFD__projects_test_WEB_INF_railo_context9157)
  • zip this folder to an archive and name it whatever.ra (the suffix is not important)

Now you have your Railo archive.

Important note: The zipped archive must start inside the folder which contains the .class files. The folder structure inside the archive must mach the one in the physical directory of the mapping you plan to use the archive for.

Do I need the .java files?
The java files are not necessary for the use of Railo archives. You can delete them from your archive. BTW: Railo 1.1 will not create java files anymore.

Do I receive a correct error codeprint?
No. Since the bytecode file does not know anything about your original .cfm file the codeprint will miss and the error output will only contain the error message and the file that raised the exception. If you like to have the coresponding codeprint, just add the .cfm files to the mapping or place them into the physical directory.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.002. Contact Blog Owner