![]() Home |
![]() Back |
![]() Contents |
![]() Next |
BeanShell supports the BSF API by providing the necessary adapter. This means that BeanShell can be used as a scripting language for any BSF 2.3 capable application simply by dropping the bsh JAR file into the classpath.
Prior to version 2.3, BSF was maintained by IBM. To get BeanShell to work with older versions of BSF you must use the older bsh-bsf-1.2x.jar file which includes the adapter class for the previous ibm packaged BSF API. You must also explicitly register the BeanShell adapter with older versions of BSF. Here is an example of how to do that:
import com.ibm.bsf.*; // register beanshell with the BSF framework String [] extensions = { "bsh" }; BSFManager.registerScriptingEngine( "beanshell", "bsh.util.BeanShellBSFEngine", extensions ); |
See http://jakarta.apache.org/bsf/ and http://oss.software.ibm.com/developerworks/projects/bsf for more information about BSF.
Ant 1.5+ has explicit support for BeanShell as a BSF scripting language. The BeanShell JAR file includes the necessary BSF adapter. You must simply specify language="beanshell" in your script tags.
You can then run scripts from a file, or in-line like so:
<project name="testbsh" default="runscript" basedir="."> <target name="runscript"> <!-- Run script from a file --> <script language="beanshell" src="myscript.bsh"/> <!-- Run script in-line --> <script language="beanshell"><![CDATA[ for(int i=0; i<10; i++ ) print( "i="+i ); ]]></script> </target> </project> |
![]() Home |
![]() Back |
![]() Contents |
![]() Next |