![]() |
Free
EcmaScript Interpreter. A JavaScript interpreter written in Java. |
| Bean Scripting
Framework |
The Bean Scripting Framework (information at http://jakarta.apache.org/bsf) , is a generic interface to many scripting engines. If you want to use the BSF engine, you must add the corresponding jar to the classpath.
The source file FESI.Tests.BSFTest.java
is a test of the interface, that can be used as an example on how
to invoke it.
BSFManager mgr = new BSFManager()
String[] extensions = { "es" }; // File name extensions
BSFManager.registerScriptingEngine("ecmascript",
"FESI.Bsf.BsfEngine", extensions);
// Call via generic interface
Object result = mgr.eval("ecmascript", "testString", 0, 0, "2+32");
// Result is a Byte with value 34.
See the documentation of BSF for alternative ways of calling the
script and for the use bean registration. Use the BSF apply function if you want to
return a value using the return statetement.
It is possible to access the JSGlobalObject
of the interpreter by using the following idom (any object can be used):
Object
result = mgr.eval("ecmascript", "getAnObject", 0, 0,
"new Object(); ");
JSObject
jso = (JSObject) result;
JSGlobalObject global = jso.getGlobalObject();
Or more directly using:
FESI.Bsf.BsfEngine fesiEngine = (FESI.Bsf.BsfEngine) mgr.loadScriptingEngine ("ecmascript");
JSGlobalObject global =
fesiEngine.getJSGlobalObject();
| Category |
Description |
| Language identifier |
ecmascript |
| File extension(s) |
.es |
| Looking up a bean |
x = bsf.lookupBean
(“name-of-bean”) |
| Create a new bean |
Any Java object can be used as a
bean. |
| Registering a bean |
bsf.registerBean
(“name-of-bean”, bean) |
| Unregistering a bean |
bsf.unregisterBean
(“name-of-bean”) |
| Binding a script to be executed upon event firing |
target.onEvent= "script-to-exec” The BSF method (addEventListener) has not beend tested. |
| Doing all bean operations |
Use FESI JavaAccess capabilities
(similar to LiveConnect) |
| Language home |
http://fesi.lugrin.ch |
| Copyright © Jean-Marc Lugrin 1998-2003 - Under LGPL license | Last update: 1 September 2003 |