ScriptingAction donation to support more languages
--------------------------------------------------
Key: JBESB-1683
URL:
http://jira.jboss.com/jira/browse/JBESB-1683
Project: JBoss ESB
Issue Type: Feature Request
Security Level: Public (Everyone can see)
Components: Build and Release, Examples, Rosetta, Testing
Affects Versions: 4.2.1
Environment: agnostic
Reporter: David Ward
This is a donation to add a greater scripting capability to JBoss ESB. Currently, only
Groovy is supported via the GroovyActionProcessor. This new donation, the
ScriptingAction, uses the Apache Jakarta Bean Scripting Framework (BSF) to support any of
the 23 scripting languages it supports, Groovy being one of them. Yes, I thought of the
Java 6 javax.script package, but everything in JBoss ESB 4.2 needs to work with JDK 5,
thus my choice.
Everything has been built against
http://anonsvn.jboss.org/repos/labs/labs/jbossesb/trunk
as of 2008-04-19 03:45:28 -0400 (Sat, 19 Apr 2008).
Please see the attached jbossesb-scripting.zip file, with the following contents:
jbossesb/trunk/product/build-distr.xml
jbossesb/trunk/product/.classpath
jbossesb/trunk/product/lib/ext/bsf-2.4.0.jar
jbossesb/trunk/product/lib/ext/bsh-2.0b4.jar
jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/scripting/ScriptingAction.java
jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/scripting/ScriptingActionUnitTest.java
jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/scripting/test.bsh
jbossesb/trunk/product/samples/quickstarts/conf/base-build.xml
jbossesb/trunk/product/samples/quickstarts/conf/quickstarts.properties-example
jbossesb/trunk/product/samples/quickstarts/scripting/build.xml
jbossesb/trunk/product/samples/quickstarts/scripting/deployment.xml
jbossesb/trunk/product/samples/quickstarts/scripting/jbmq-queue-service.xml
jbossesb/trunk/product/samples/quickstarts/scripting/jbm-queue-service.xml
jbossesb/trunk/product/samples/quickstarts/scripting/jbossesb-properties.xml
jbossesb/trunk/product/samples/quickstarts/scripting/jboss-esb.xml
jbossesb/trunk/product/samples/quickstarts/scripting/jndi.properties
jbossesb/trunk/product/samples/quickstarts/scripting/juddi.properties
jbossesb/trunk/product/samples/quickstarts/scripting/lib/js-14.jar
jbossesb/trunk/product/samples/quickstarts/scripting/lib/js.jar
jbossesb/trunk/product/samples/quickstarts/scripting/lib/jython.jar
jbossesb/trunk/product/samples/quickstarts/scripting/log4j.xml
jbossesb/trunk/product/samples/quickstarts/scripting/readme.txt
jbossesb/trunk/product/samples/quickstarts/scripting/scripts/helloworld.bsh
jbossesb/trunk/product/samples/quickstarts/scripting/scripts/helloworld.gy
jbossesb/trunk/product/samples/quickstarts/scripting/scripts/helloworld.js
jbossesb/trunk/product/samples/quickstarts/scripting/scripts/helloworld.py
jbossesb/trunk/product/samples/quickstarts/scripting/src/org/jboss/soa/esb/samples/quickstart/scripting/test/SendJMSMessage.java
First off, I made some config/build fixes. Here is a diff:
Index: product/build-distr.xml
===================================================================
--- product/build-distr.xml (revision 19660)
+++ product/build-distr.xml (working copy)
@@ -63,6 +63,10 @@
<delete dir="${esbserver.dist.dir}"/>
<unzip
src="${installation.files.dir}/standalone/jbossesb-server-base.zip"
dest="${build.dir}"/>
<chmod dir="${build.dir}/jbossesb-server/bin" perm="ugo+rx"
includes="*.sh"/>
+ <!-- upgrade BeanShell from 1.3.0 to 2.0b4 -->
+ <copy file="${lib.ext.dir}/bsh-2.0b4.jar"
tofile="${build.dir}/jbossesb-server/server/default/lib/bsh.jar"
overwrite="true"/>
+ <!-- introduce Apache Bean Scripting Framework -->
+ <copy file="${lib.ext.dir}/bsf-2.4.0.jar"
tofile="${build.dir}/jbossesb-server/server/default/lib/bsf.jar"/>
<move file="${build.dir}/jbossesb-server"
tofile="${esbserver.dist.dir}"/>
</target>
Index: product/.classpath
===================================================================
--- product/.classpath (revision 19660)
+++ product/.classpath (working copy)
@@ -12,14 +12,16 @@
<classpathentry kind="lib"
path="lib/ext/commons-lang-2.1.jar"/>
<classpathentry kind="lib" path="lib/ext/emma_ant.jar"/>
<classpathentry kind="lib" path="lib/ext/emma.jar"/>
+ <classpathentry kind="lib" path="lib/ext/bsf-2.4.0.jar"/>
+ <classpathentry kind="lib" path="lib/ext/bsh-2.0b4.jar"/>
<classpathentry kind="lib"
path="lib/ext/groovy-all-1.0.jar"/>
<classpathentry kind="lib" path="lib/ext/hsqldb.jar"/>
<classpathentry kind="lib"
path="lib/ext/jbossall-client.jar"/>
<classpathentry kind="lib" path="lib/ext/jboss-system.jar"/>
<classpathentry kind="lib"
path="lib/ext/jbossts-common.jar"/>
<classpathentry kind="lib" path="lib/ext/jsch-0.1.jar"/>
- <classpathentry kind="lib"
path="lib/ext/juddi-1.0-SNAPSHOT.jar"/>
- <classpathentry kind="lib"
path="lib/ext/juddi-client-1.0-SNAPSHOT.jar"/>
+ <classpathentry kind="lib" path="lib/ext/juddi-2.0rc5.jar"/>
+ <classpathentry kind="lib"
path="lib/ext/juddi-client-2.0rc5.jar"/>
<classpathentry kind="lib" path="lib/ext/junit-4.1.jar"/>
<classpathentry kind="lib" path="lib/ext/log4j.jar"/>
<classpathentry kind="lib" path="lib/ext/mail.jar"/>
@@ -33,9 +35,10 @@
<classpathentry kind="lib"
path="lib/ext/xercesImpl-2.7.1.jar"/>
<classpathentry kind="lib"
path="lib/ext/xml-apis-1.3.02.jar"/>
<classpathentry kind="lib" path="lib/ext/xmlpublic.jar"/>
- <classpathentry kind="lib" path="lib/ext/xstream-1.1.3.jar"/>
+ <classpathentry kind="lib" path="lib/ext/xstream-1.2.2.jar"/>
<classpathentry kind="lib" path="lib/ext/jboss.jar"/>
<classpathentry kind="lib"
path="lib/ext/commons-io-1.3.jar"/>
+ <classpathentry kind="lib"
path="lib/ext/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="lib/ext/edtftpj-1.5.4.jar"/>
<classpathentry kind="lib"
path="ftp/lib/backport-util-concurrent-2.2.jar"/>
<classpathentry kind="lib"
path="ftp/lib/ftplet-api-1.0-incubator-SNAPSHOT.jar"/>
Index: product/samples/quickstarts/conf/quickstarts.properties-example
===================================================================
--- product/samples/quickstarts/conf/quickstarts.properties-example (revision 19660)
+++ product/samples/quickstarts/conf/quickstarts.properties-example (working copy)
@@ -5,7 +5,7 @@
##############################################################################################
# Location of your JBoss Application Server installation.
# Will override the same property name from install/deployment.properties
-#org.jboss.esb.server.home=${product.dir}/build/jbossesb-server-4.2GA
+#org.jboss.esb.server.home=${product.dir}/build/jbossesb-server-4.2.1GA
# JBossAS server name. If not set defaults to 'default'
# Will override the same property name from install/deployment.properties
Index: product/samples/quickstarts/conf/base-build.xml
===================================================================
--- product/samples/quickstarts/conf/base-build.xml (revision 19660)
+++ product/samples/quickstarts/conf/base-build.xml (working copy)
@@ -271,6 +271,7 @@
<pathelement location="${basedir}/src" />
<fileset dir="${org.jboss.esb.server.server}/lib"
includes="jboss-remoting.jar jboss-j2ee.jar jboss-messaging-client.jar" />
<!-- Required for JMS Client Code. -->
<fileset dir="${org.jboss.esb.server.server}/lib"
includes="hibernate3.jar commons-collections.jar hsqldb.jar" /> <!--
Required for jbpm Client Code. -->
+ <fileset dir="${org.jboss.esb.server.server}/lib"
includes="bsf.jar" /> <!-- Required for scripting Client Code. -->
<fileset dir="${org.jboss.esb.server.server}/lib"
includes="bsh.jar" /> <!-- Required for scripting Client Code. -->
<fileset dir="${org.jboss.esb.server.home}/lib/endorsed"
includes="*.jar" /> <!-- Required for JMS Client Code. -->
<fileset
dir="${org.jboss.esb.server.server}/deploy/jboss-aop-jdk50.deployer"
includes="jboss-aop-jdk50.jar" /> <!-- Required for JMS Client Code.
-->
Please note in .classpath I had to fix the juddi, xstream and commons-codec jars because
someone else busted them. 'twasn't me! ;) You will also notice the addition
of BSF 2.4.0, and the upgrade of BeanShell from 1.3.0 to 2.0b4 in AS (something I've
wanted for a long time). Last, I fixed the quickstarts.properties-example file to reflect
the change to jbossesb-server-4.2.1GA.
Now, for the meat. The relatively simple code lives in ScriptingAction.java, which was
modeled after GroovyActionProcessor.java.
There is also a test case, ScriptingActionUnitTest, which exercises both BeanShell and
Groovy scripts:
[java] [junit] Running
org.jboss.soa.esb.actions.scripting.ScriptingActionUnitTest
[java] [junit] Testsuite:
org.jboss.soa.esb.actions.scripting.ScriptingActionUnitTest
[java] [junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 1.392 sec
[java] [junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 1.392 sec
[java] [junit] ------------- Standard Output ---------------
[java] [junit] EMMA: collecting runtime coverage data ...
[java] [junit] ------------- ---------------- ---------------
[java] [junit]
[java] [junit] Testcase: test_groovy_file took 0.932 sec
[java] [junit] Testcase: test_bsh_file took 0.1 sec
[java] [junit] Testcase: test_groovy_inlined took 0.05 sec
[java] [junit] Testcase: test_bsh_inlined took 0.012 sec
[java] [junit] Testcase: test_beanshell_inlined took 0.012 sec
I also created a quickstart, called "scripting". It has an action pipeline
which calls out to BeanShell, Groovy, Python, and JavaScript. (Note: bsf.jar and bsh.jar
are in the server's lib directory because older versions were already there. Python
uses the jython library, and JavaScript uses the Mozilla Rhino library - both of which
have different licenses. Thus, I did not included them in the server's lib directory.
I only put them in just the quickstart's lib directory.)
ANYwho, it runs fine in both '.esb' archive mode:
01:13:11,865 INFO [STDOUT] Hello World from BeanShell!
01:13:11,926 INFO [STDOUT] Hello World from Groovy!
01:13:11,960 INFO [STDOUT] Hello World from Python!
01:13:11,968 INFO [STDOUT] Hello World from JavaScript!
as well as in standalone mode:
[qsjava] Hello World from BeanShell!
[qsjava] Hello World from Groovy!
[qsjava] Hello World from Python!
[qsjava] Hello World from JavaScript!
Hopefully this can make it into an upcoming version of the ESB. Any questions, feel free
to ask. Comments welcome. Enjoy!
David
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira