You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Alain Stalder <as...@span.ch> on 2017/02/28 09:44:45 UTC

[CASE STORY] Jexler powered by Grengine

Jexler is a container for running Groovy scripts,
"great for prototyping and useful for automating".

It consists of a relatively basic web GUI; screenshot:

   https://www.jexler.net/guide/jexler-gui.jpg

In the file system, the structure is also very simple;
all *.groovy files in the WEB-INF/jexlers directory
are part of the container:

WEB-INF/jexlers/
   - Jexler1.groovy
   - Jexler2.groovy
   - Util1.groovy
   - Config.groovy
   - ...

Scripts usually register events they would like to receive
at startup and are then idle until they get an event.

Until recently, I simply used a GroovyClassLoader, in which
I added the jexlers directory to the classpath and did this
for each jexler script individually.

This had the advantage that the container scripts could be
"dirty", only the ones that the specific jexler really needed
where compiled and loaded when needed.

Since I am also the author of Grengine, I had often imagined
to switch to Grengine, but usually dismissed the thought again,
considering Grengine more appropriate for a more static setup.

But last week I still gave it a try and the result was quite a
bit more satisfying than I had expected - not completely black
and white a clear winner, but in this specific use case I will
stick with it.

The new setup using Grengine distinguishes jexler scripts that
are run from utility scripts/config/etc. scripts (by a
specific comment that must be present in the script file to
make it a "jexler" script file).

Utility scripts are part of the Grengine engine code layers,
they are always compiled together with full dependencies.
Jexler scripts run each in their own classloader on top of the
class loader for the utility scripts.

So, if a jexler script does not compile, this has only the effect
that it cannot be started, no impact on other jexler scripts and
also not on the utility scripts.

If utility scripts are modified such they do not compile any more,
this does not impact already running jexlers nor even prevent to
stop and restart them, because the Grengine automatically keeps
the last known good state if compilation fails.

I have been operating jexler since about 2014 and am quite happy
in practice with the new architecture using Grengine - makes it
easier to maintain the container scripts and I can still use it
quite freely to prototype things etc.

Jexler: https://www.jexler.net/

(To try it out, either get https://www.jexler.net/jexler-3.0.1.war
or checkout https://github.com/jexler/jexler.git, run 'gradle test'
and visit http://localhost:9080/)

Grengine: https://www.grengine.ch/

Alain