commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: [Jelly][PATCH] BSF Script Patch
Date Wed, 05 Mar 2003 08:11:36 GMT
All patches applied, committed and snapshots of Jelly & tags-bsf deployed.
Thanks for this Pete!

I made a minor change; the latest bsf is 2.3.0-rc1 (you'd missed off the .0
A minor point below...

From: "Pete Kazmier" <>
> Here is a patch for the Jelly BSF Taglib.  In summary, this gets the
> BSF script tag working properly for Jython.  In Maven-land, we need
> this for a few plugins we are working on.
> A brief run down of the changes:
>   -  The existing ScriptTag calls the BSF eval() method, which can
>      only be used to evaluate single expressions. To evaluate a
>      script, the exec() method must be used.  This patch fixes that
>      issue.
>   -  Updated the BSF Taglib to use the latest and greatest BSF thats
>      been moved into the jakarta namespace.  Also provides more
>      support for addtional languages.
>   -  The ScriptTag was not populating the BSF object registry so the
>      jelly context was not available to scripts.  I used the same hack
>      that was used for the expressions, could be cleaned up, just
>      wanted to get this in so we had something working.
>   -  Added a JythonTagLibrary in addition to the JPythonTagLibrary.
>      Also updated to register this tag library under
>      "jython".

Great stuff.

> Outstanding issues (basically things I couldn't figure out myself
> yet as I am taglib deficient):
>   -  Couldn't figure out how to use the tag that expects the
>      'language' attribute, for that matter, didn't even know which one
>      supported that attribute.  So I was not able to get this to work:
>           <bsf:script language="jython">
>            ...
>           </bsf:script>

The <script> tag doesn't support the language attribute. I'd just added the
language property to the BSFTagLibrary so that someone could extend or
instantiate the tag library with some language. e.g.

JellyContext context = ...;
context.registerTagLibrary( "someURI", new BSFTagLibrary( "mylanguage"));

> With all that said, here is how I use the jython script tag in my
> maven build file:
> <project default="java:jar"
>   xmlns:jython="jelly:jython">
>   <goal name="jython-test">
>     <jython:script>
> print "This is a jython script"
> print "My Maven POM's name is", pom.getName()
> print "If the POM has a name, then the context passing is working"
>     </jython:script>
>   </goal>
> </project>


> And don't forget to include the deps needed for this in your POM (for
> you mavenites):
> <dependency>
>   <groupId>commons-jelly</groupId>
>   <artifactId>commons-jelly-tags-bsf</artifactId>
>   <version>1.0-SNAPSHOT</version>
> </dependency>
> <dependency>
>   <id>bsf</id>
>   <version>2.3-rc1</version>

this should be


> </dependency>
> <dependency>
>   <id>jython</id>
>   <version>2.1</version>
> </dependency>
> And finally, if you decide to try this out before the latest version
> of Jelly has been updated in Maven, you'll have to explicity set the
> class for the xmlns line.  For example, the above would look like:
> <project default="java:jar"
>   xmlns:jython="jelly:org.apache.commons.jelly.tags.bsf.JythonTagLibrary">

If it helps the latest snapshot has the alias of jelly:jython now.

Thanks again Pete.


Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message