Does Sling use Apache BSF or a similar model for scripting language support.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Does Sling use Apache BSF or a similar model for scripting language support.

janandith jayawardena
Hi ,

The MANIFEST.MF file in \scripting\api\target\classes\META-INF contains the
following lines ,

"Bundle-Description: This bundle provides the internal API to implement
 scripting. As such        it bundles the Java Scripting API provided
 by Apache BSF. "


The Apache BSF manual at http://jakarta.apache.org/bsf/manual.html says ,

" In order to incorporate your own scripting language into BSF, you must
first write a class implementing the BSFEngine interface for the language;
examples are available in the BSF source distribution.

Usually, a scripting language author extends the BSFEngineImpl class, which
implements BSFEngine, and only requires the scripting language author to
implement the eval() method."

There is an eval method in AbstractSlingScriptEngine which is overidden by
an eval method in  "VelocityTemplatesScriptEngine" and other ScriptEngine
classes.

Does this mean Sling uses Apache BSF for scripting language support or a
similar model.
If so is it also an OSGi bundle.

Can i use the Apache BSF manual as a reference to the Sling scripting/api.

regards,
Janandith.
Reply | Threaded
Open this post in threaded view
|

Re: Does Sling use Apache BSF or a similar model for scripting language support.

Bertrand Delacretaz
Hi Janadith,

On Sun, Mar 30, 2008 at 8:24 PM, janandith jayawardena
<[hidden email]> wrote:

> ... Does this mean Sling uses Apache BSF for scripting language support or a
>  similar model...

Yes and no ;-)

Sling scripting is based on the  JSR 223 javax.script.* interfaces,
provided by the BSF 3.0 beta release. So we do use BSF, but not the
"old" BSF-specific interfaces.

> ... If so is it also an OSGi bundle....

Yes, each scripting engine is provided as an OSGi bundle, but to be
usable as a scripting engine the bundle has to include a
services/javax.script.ScriptEngineFactory file that gives the name of
the ScriptEngineFactory that implements the language.

The velocity script engine (in scripting/velocity) is probably the
simplest example.

> ... Can i use the Apache BSF manual as a reference to the Sling scripting/api....

Probably not, I haven't checked but I guess that manual describes the
"old" BSF API.

Better look at the javax.script APIs, for example at
http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html
- but BSF, being in beta, might not implement all of that.

-Bertrand

Reply | Threaded
Open this post in threaded view
|

Re: Does Sling use Apache BSF or a similar model for scripting language support.

janandith jayawardena
Hi Bertrand,

Thanks, i will have a look at it. :-).

janandith.

On 3/31/08, Bertrand Delacretaz <[hidden email]> wrote:

> Hi Janadith,
>
> On Sun, Mar 30, 2008 at 8:24 PM, janandith jayawardena
> <[hidden email]> wrote:
>
> > ... Does this mean Sling uses Apache BSF for scripting language support or
> a
> >  similar model...
>
> Yes and no ;-)
>
> Sling scripting is based on the  JSR 223 javax.script.* interfaces,
> provided by the BSF 3.0 beta release. So we do use BSF, but not the
> "old" BSF-specific interfaces.
>
> > ... If so is it also an OSGi bundle....
>
> Yes, each scripting engine is provided as an OSGi bundle, but to be
> usable as a scripting engine the bundle has to include a
> services/javax.script.ScriptEngineFactory file that gives the name of
> the ScriptEngineFactory that implements the language.
>
> The velocity script engine (in scripting/velocity) is probably the
> simplest example.
>
> > ... Can i use the Apache BSF manual as a reference to the Sling
> scripting/api....
>
> Probably not, I haven't checked but I guess that manual describes the
> "old" BSF API.
>
> Better look at the javax.script APIs, for example at
> http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html
> - but BSF, being in beta, might not implement all of that.
>
> -Bertrand
>