Hi,
Am Montag, den 10.03.2008, 18:31 +0100 schrieb Carsten Ziegeler:
> >> b) We need a convention to pass the method name and the method
> >> parameters to the script engine
> >> c) Check for the new info mentioned in b) and if available don't execute
> >> the whole script, but just the single method.
> >
> > The problem with calling a method (or function) is that there will
> > probably not be a script file to be "compiled" and a method called on it
> > but rather some already existing functions or objects in the
> > ScriptEngine scope on which we call a function or method....
> >
> > Probably we need to enter the arena of direct ScriptEngine use here ??
> I assume you mean javax.script.ScriptEngine? And javax.script.Invocable?
Yes, exactly.
> > I am not in favor of defining special hacks into e.g. the SlingBindings
> > object to support this.
> >
> Yes, I agree - I'm wondering if it makes more sense to shrink our
> scripting layer (we have own bindings objects etc) and start direcly
> using the javax.script stuff?
First, I think the SlingScript interface provides a nice abstraction to
integrate with the Servlet/Script execution mechanism and taking the
burden of acquiring a ScriptEngine off the shoulders of developers.
Having said that, lets start about a reduction of the API in the
o.a.s.api.scripting:
* InvalidServiceFilterSyntaxException - thrown by
ScriptHelper.getServices
should be kept
* ScriptEvaluationException - "wraps" a Scripting API ScriptException
as a SlingException
suggest to keep
* SlingBindings - predefined "global" variables for scripts
keep ?
* SlingScript - represents a Script in Sling, comparable to a Servlet
keep, but getScriptResource public API might be dropped
* SlingScriptHelper - usefull methods and stuff for scripting
keep or merge with SlingBindungs to be the script call
context
* SlingScriptResolver - this is probably not required anymore and may
be dropped
Now, to support calling methods on scripts we need the following basis:
* load code on ScriptEngineFactory startup for "public" use
* Identify functions to call
This is inherently ScriptEngine specific, which is not really a problem.
On the other hand, what is the advantage of having special methods
called on scripts instead of just having the code in Java ?
The longer I think of it, the more problematic, I find the proposal as
it creates ScriptEngine lockin and limits extensibility...
Regards
Felix