-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbsf.html
141 lines (117 loc) · 4.67 KB
/
bsf.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?xml version="1.0" encoding="UTF-8"?>
<html>
<head>
<title>BSF Bean Scripting Framework</title>
</head>
<body bgcolor="ffffff">
<table cellspacing="10">
<tr>
<td align="center"><a href="http://www.beanshell.org/"><img src="images/homebutton.png" /><br />Home</a>
</td>
<td><a href="execscripts.html#Executable_scripts_under_Unix"><img
src="images/backbutton.png" /><br />Back
</a></td>
<td align="center"><a href="contents.html"><img src="images/upbutton.png" /><br />Contents</a></td>
<td align="center"><a href="more.html#Learning_More"><img src="images/forwardbutton.png" /><br />Next
</a></td>
</tr>
</table>
<h1>BSF Bean Scripting Framework</h1>
BSF is the Apache "Bean Scripting Framework".
It is generic framework that allows
many scripting languages to be plugged into an application. It shields
the application from knowledge of how to invoke the scripting languages and
their APIs, via adapter "engines".
<p CLEAR="ALL" />
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.
<p CLEAR="ALL" />
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:
<p />
<center>
<table border="1" cellpadding="5" width="100%">
<tr>
<td bgcolor="#dfdfdc">
<pre>
import com.ibm.bsf.*;
// register beanshell with the BSF framework
String [] extensions = { "bsh" };
BSFManager.registerScriptingEngine(
"beanshell", "bsh.util.BeanShellBSFEngine", extensions );
</pre>
</td>
</tr>
</table>
</center>
<p />
See
<a href="http://jakarta.apache.org/bsf/">http://jakarta.apache.org/bsf/</a>
and
<a href="http://oss.software.ibm.com/developerworks/projects/bsf">
http://oss.software.ibm.com/developerworks/projects/bsf</a>
for more information about BSF.
<h2><a name="Ant">Ant</a></h2>
<em>This section needs to be updated. I'm not sure what versionf of Ant use
the new and which use the old BSF API.</em>
<p CLEAR="ALL" />
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.
<h3>Installation</h3>
To use BeanShell within Ant you must do two things:
<ol>
<li>Add the
<a href="http://oss.software.ibm.com/developerworks/projects/bsf">
BSF bsf.jar file</a>
to ANT_HOME/lib or the classpath.</li>
<li>Add the
<a href="http://www.beanshell.org/download.html">
BeanShell bsh.jar file</a>
to ANT_HOME/lib or the classpath.</li>
</ol>
<p CLEAR="ALL" />
You can then run scripts from a file, or in-line like so:
<p CLEAR="ALL" />
<p />
<center>
<table border="1" cellpadding="5" width="100%">
<tr>
<td bgcolor="#dfdfdc">
<pre>
<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">&lt;![CDATA[
for(int i=0; i<10; i++ )
print( "i="+i );
]]&gt;</script>
</target>
</project>
</pre>
</td>
</tr>
</table>
</center>
<p />
<table cellspacing="10">
<tr>
<td align="center"><a href="http://www.beanshell.org/"><img src="images/homebutton.png" /><br />Home</a>
</td>
<td><a href="execscripts.html#Executable_scripts_under_Unix"><img
src="images/backbutton.png" /><br />Back
</a></td>
<td align="center"><a href="contents.html"><img src="images/upbutton.png" /><br />Contents</a></td>
<td align="center"><a href="more.html#Learning_More"><img src="images/forwardbutton.png" /><br />Next
</a></td>
</tr>
</table>
</body>
</html>