You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Felix Meschberger <fm...@gmail.com> on 2007/11/20 11:38:57 UTC

Scripting Engine Support

Hi all,

In Sling we currently have the ScriptEngine interface to support
multiple scriping engines. Implementations exist for JavaScript (Rhino),
Velocity, Ruby, Freemarker and JSP. I proposed this light-weight
interface because, I want to go forward quickly and didn't want to lock
in to any of the other two big contenders in the field: Java Scripting
(JSR-223) and BSF.

I now learned that BSF 3 (currently in Beta) will be an implementation
of the Java Scripting API and will be ready to run in Java 1.4 and newer
(as opposed to Sun's reference implementation, which is part of Java 6
and not available earlier). So this opens the question again, whether we
really need our own interface for scripting engines.

I suggest we drop the ScriptEngine interface in favore of using Java
Scripting. We could then make use of all Java Scripting supporting
scripting languages and would not have to implement our own bindings.

WDYT ?

Regards
Felix


Re: Scripting Engine Support

Posted by pi...@wasabicowboy.com.
Sounds great, if you need help refactoring Shawn and I can lend a hand.

Paddy
Sent via BlackBerry from T-Mobile

-----Original Message-----
From: Felix Meschberger <fm...@gmail.com>

Date: Tue, 20 Nov 2007 11:38:57 
To:Sling Developers <sl...@incubator.apache.org>
Subject: Scripting Engine Support


Hi all,

In Sling we currently have the ScriptEngine interface to support
multiple scriping engines. Implementations exist for JavaScript (Rhino),
Velocity, Ruby, Freemarker and JSP. I proposed this light-weight
interface because, I want to go forward quickly and didn't want to lock
in to any of the other two big contenders in the field: Java Scripting
(JSR-223) and BSF.

I now learned that BSF 3 (currently in Beta) will be an implementation
of the Java Scripting API and will be ready to run in Java 1.4 and newer
(as opposed to Sun's reference implementation, which is part of Java 6
and not available earlier). So this opens the question again, whether we
really need our own interface for scripting engines.

I suggest we drop the ScriptEngine interface in favore of using Java
Scripting. We could then make use of all Java Scripting supporting
scripting languages and would not have to implement our own bindings.

WDYT ?

Regards
Felix

Re: Scripting Engine Support

Posted by Felix Meschberger <fm...@gmail.com>.
Hi all,

In the meantime, Paddy Hannon has created an issue [1] and provided a
patch. First I want to thank Paddy for this patch.

So here are the changes:

   - The SlingScriptEngine interfaces is removed without exposed
replacement
   - The SlingScript is reduced to the max: It provides the resource of
the
     script source and a method to evaluate the script.
   - ScriptBindings is new and is used to prepare the global variables
to
     evaluate the script.

The idea behind this is, that the implementation of the
SlingScriptResolver will return an instance of the SlingScript
interface, which internally keeps knowsledge of the Java Scripting
Engine used to actually evaluate the script. But this is an
implementation detail not exposed in the API.

Unless there is some opposition, I will apply this patch sometime next
week.

Regards
Felix

[1] https://issues.apache.org/jira/browse/SLING-110


Re: Scripting Engine Support

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On Nov 23, 2007 9:50 AM, Felix Meschberger <fm...@gmail.com> wrote:
> Hi all,
>
> Am Freitag, den 23.11.2007, 01:40 +0200 schrieb Alexandru Popescu ☀:
> > Haven't been around, so excuse me if this discussion has a long
> > history behind.
>
> Never mind, this is a young story :-)
>
> > IMO we should go with the standard, and just offer a
> > small door for non-standard solutions. I am pretty sure that the JDK
> > is/will be more stable than BSF.
>
> I absolutely agree. This is also why I was reluctant in the first place
> to go BSF (de-facto standard) or Java Scripting (only available as of
> Java 6) and we came up with our own Scripting Engine interface.
>
> Now, the case is different today: We BSF 2.4 has its own API while BSF
> 3.0 currently in beta2 ([1]) is an implementation of the Java Scripting
> API and comes with all the API classes runnable in Java 1.4 and higher.
> So, this is where I propose to start. This way we have the standard
> (Java Scripting) and can run on Java 5.
>

I couldn't find the part about BSF3.0 being a Java Scripting API
implementation, but I trust you. In this case, I do agree going this
way, as it is exactly what I was suggesting (but without knowing that
BSF is following the standard API now).

./alex
--
.w( the_mindstorm )p.

> Regards
> Felix
>
> [1] http://jakarta.apache.org/bsf/bsfnews.html
>
>
>
> >
> > bests,
> >
> > ./alex
> > --
> > .w( the_mindstorm )p.
>
>

Re: Scripting Engine Support

Posted by Felix Meschberger <fm...@gmail.com>.
Hi all,

Am Freitag, den 23.11.2007, 01:40 +0200 schrieb Alexandru Popescu ☀:
> Haven't been around, so excuse me if this discussion has a long
> history behind. 

Never mind, this is a young story :-)

> IMO we should go with the standard, and just offer a
> small door for non-standard solutions. I am pretty sure that the JDK
> is/will be more stable than BSF.

I absolutely agree. This is also why I was reluctant in the first place
to go BSF (de-facto standard) or Java Scripting (only available as of
Java 6) and we came up with our own Scripting Engine interface.

Now, the case is different today: We BSF 2.4 has its own API while BSF
3.0 currently in beta2 ([1]) is an implementation of the Java Scripting
API and comes with all the API classes runnable in Java 1.4 and higher.
So, this is where I propose to start. This way we have the standard
(Java Scripting) and can run on Java 5.

Regards
Felix

[1] http://jakarta.apache.org/bsf/bsfnews.html


> 
> bests,
> 
> ./alex
> --
> .w( the_mindstorm )p.


Re: Scripting Engine Support

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Nov 23, 2007 12:40 AM, Alexandru Popescu ☀
<th...@gmail.com> wrote:

> ...I am pretty sure that the JDK
> is/will be more stable than BSF....

The problem is that java script is only available in JDK 1.6, whereas
(IIUC) BSF provides support in JDK 1.5, which is our current JDK
target.

-Bertrand

Re: Scripting Engine Support

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On Nov 22, 2007 6:37 PM, Bertrand Delacretaz <bd...@apache.org> wrote:
> On Nov 20, 2007 11:38 AM, Felix Meschberger <fm...@gmail.com> wrote:
>
> > ...I suggest we drop the ScriptEngine interface in favore of using Java
> > Scripting....
>
> I'm +1 on that, assuming that runs on JDK 1.5 (which IIUC would be ok
> with BSF 3, as you mentioned).
>
> -Bertrand
>

Haven't been around, so excuse me if this discussion has a long
history behind. IMO we should go with the standard, and just offer a
small door for non-standard solutions. I am pretty sure that the JDK
is/will be more stable than BSF.

bests,

./alex
--
.w( the_mindstorm )p.

Re: Scripting Engine Support

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Nov 20, 2007 11:38 AM, Felix Meschberger <fm...@gmail.com> wrote:

> ...I suggest we drop the ScriptEngine interface in favore of using Java
> Scripting....

I'm +1 on that, assuming that runs on JDK 1.5 (which IIUC would be ok
with BSF 3, as you mentioned).

-Bertrand