This plugin dynamically loads a coldbox application with the groovy runtime and other java libraries you so desire. You can configure a classpath within your application that will act as the root of what you want to execute or you can dynamically use the groovy scripting tags.

The groovy loader plugin also leverages the coldbox cache in order to store the java class files the groovyloader creates from script. Internally, the groovy class loader also caches the parsed classes so they are not re-parsed at runtime. The plugin includes two methods to interact with these caches:

  • clearClazzCache() : Cleans the coldbox cache of loaded groovy scripts
  • clearClassLoaderCache() : Cleans the actual classloader's cache, use sparingly

Why would I want to clear the class loader cache? You want to do this, whenever you make changes to the groovy files on disk. However, be warned that classloading is a very tempestous beast and it can lead to memory leaks or JVM permGen errors as class definitions do not get garbage collected or disposed of. However, this side effect is only visualized on development.

Requirements:

  • ColdFusion 9 and above
  • Railo 3.0 and above

Install:

Copy the plugin folder: GroovyLoader to your custom plugins or bring them in via the MyPluginsLocation or PluginsExternalLocation setting. Then either configure the class path and plugin like in the sample application:


<cfset getMyPlugin("GroovyLoader.GroovyLoader").configureClassPath(getSetting("ApplicationPath") & "model/groovy")>


Or just use the GroovyStarter interceptor, way easy:

		
interceptors = [
 { class="#appMapping#.plugins.GroovyLoader.GroovyStarter",
   properties = { groovyLibPaths = "/#appMapping#/model/groovy,/#appMapping#/model/anotherPath",
                  javalibPaths = "/#appMapping#/model/lib" }
];

VERSION 3.0

  • Updated to ColdBox 3.6 standards
  • Updated for ColdFusion 9
  • Updated to pass in the private request collection to groovy bindings
  • Updated to pass in the request scope to groovy bindings
  • Updated all examples and cleanup
  • Better cache utilizations and retrievals

VERSION 2.0

  • Added ability to load more than 1 location for groovy scripts
  • Added ability to load more than 1 location for java libraries alongside groovy language
  • Added the GroovyStarter interceptor for easy loading of the runtime, fully configurable

VERSION 1.0

  • Initial groovy integration

 

 
$ box install GroovyLoader
5.00 / 1
  • Dec 02 2009 05:18 PM
  • Feb 23 2017 01:00 PM
  • 4386
  • 1652
  • 2