BoxLang 🚀 A New JVM Dynamic Language Learn More...
This download includes a full blown sample application and the groovy loader plugin. For just the plugin, look at the plugin contribution type.
This plugin is thanks to Barney Boisevert for his cfgroovy inspiration.
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:
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.
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" } ];
$
box install Groovy-Loader-Project