Hi,
I was wondering, did anyone in the scripting real consider using the JSR 223
extensions to have GeoServer processes and functions be scriptable in
any JVM supported language?
The scripting support seems rather simple to use:
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/
What I was thinking is something along the line of having two files for each
process, a description one, and a script one.
The description one would be uniform for all processes/functions, and would
indicate what scripting engine to use. Something like:
{
engine: rhino,
title: "Centroid Example",
description: "Example script that calculates the centroids of the
input geometries",
inputs: {
features: geotools.feature.FeatureCollection
},
outputs: {
centroid: geotools.feature.FeatureCollection
}
}
The second one instead would be a pure script, which we'd pass parameter to
using the JSR 223 script context.
The efforts I see so far are focused on a specific language, meaning that if
I wanted to script something using beansheel or jruby I'd have to build some
custom support. With a generic JSR 223 support we'd have the ability to
use any language instead, maybe adding some generic java sugar to invoke
other processes (I see process orchestration as the sweet spot for scripting
languages).
Another idea would be to actually add a level of indirection and make our own
engine interfaces, with one implementation able to relay to any JSR
223 scripting
language in the classpath.
But other engines could for example wrap geoscript and eventually
perform initializations
and/or data transformation before calling the process (such as
wrapping feature collections
in their own wrappers).
Another interesting use case could be a "command line" scription
enginge, allowing to call
onto any shell program (this one would make for a nice built-in
scripting engine).
Ah, what about functions? The process/function bridge in the geotools
gt-process module
re-registers any process with just one output as a function.
This is done to support rendering transformations, but it also means
that one can write
processes and functions as if they were the same thing.
Opinions?
Cheers
Andrea
PS: all of this started with me wanting to use beanshell to create a
chain of processes
with a sprinkle of orchestration logic added. I wanted a script
language that I could
learn in a hour, with a very small jar, and with no extra deps, and
beanshell fit the bill nicely.
--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf
-------------------------------------------------------