use of org.apache.bsf.util.BSFFunctions in project groovy by apache.
the class GroovyEngine method initialize.
/**
* Initialize the engine.
*/
public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
super.initialize(mgr, lang, declaredBeans);
// create a shell
shell = new GroovyShell(mgr.getClassLoader());
// register the mgr with object name "bsf"
shell.setVariable("bsf", new BSFFunctions(mgr, this));
int size = declaredBeans.size();
for (int i = 0; i < size; i++) {
declareBean((BSFDeclaredBean) declaredBeans.elementAt(i));
}
}
use of org.apache.bsf.util.BSFFunctions in project groovy-core by groovy.
the class CachingGroovyEngine method initialize.
/**
* Initialize the engine.
*/
public void initialize(final BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
super.initialize(mgr, lang, declaredBeans);
ClassLoader parent = mgr.getClassLoader();
if (parent == null)
parent = GroovyShell.class.getClassLoader();
setLoader(mgr, parent);
execScripts = new HashMap<Object, Class>();
evalScripts = new HashMap<Object, Class>();
context = shell.getContext();
// create a shell
// register the mgr with object name "bsf"
context.setVariable("bsf", new BSFFunctions(mgr, this));
int size = declaredBeans.size();
for (int i = 0; i < size; i++) {
declareBean((BSFDeclaredBean) declaredBeans.elementAt(i));
}
}
use of org.apache.bsf.util.BSFFunctions in project groovy-core by groovy.
the class GroovyEngine method initialize.
/**
* Initialize the engine.
*/
public void initialize(BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
super.initialize(mgr, lang, declaredBeans);
// create a shell
shell = new GroovyShell(mgr.getClassLoader());
// register the mgr with object name "bsf"
shell.setVariable("bsf", new BSFFunctions(mgr, this));
int size = declaredBeans.size();
for (int i = 0; i < size; i++) {
declareBean((BSFDeclaredBean) declaredBeans.elementAt(i));
}
}
use of org.apache.bsf.util.BSFFunctions in project groovy by apache.
the class CachingGroovyEngine method initialize.
/**
* Initialize the engine.
*/
public void initialize(final BSFManager mgr, String lang, Vector declaredBeans) throws BSFException {
super.initialize(mgr, lang, declaredBeans);
ClassLoader parent = mgr.getClassLoader();
if (parent == null)
parent = GroovyShell.class.getClassLoader();
setLoader(mgr, parent);
execScripts = new HashMap<Object, Class>();
evalScripts = new HashMap<Object, Class>();
context = shell.getContext();
// create a shell
// register the mgr with object name "bsf"
context.setVariable("bsf", new BSFFunctions(mgr, this));
int size = declaredBeans.size();
for (int i = 0; i < size; i++) {
declareBean((BSFDeclaredBean) declaredBeans.elementAt(i));
}
}
use of org.apache.bsf.util.BSFFunctions in project jmeter by apache.
the class BSFJavaScriptEngine method initialize.
/**
* Initialize the engine.
* Put the manager into the context-manager
* map hashtable too.
*/
@Override
public void initialize(BSFManager mgr, String lang, // superclass does not support types
@SuppressWarnings("rawtypes") Vector declaredBeans) throws BSFException {
super.initialize(mgr, lang, declaredBeans);
// Initialize context and global scope object
try {
Context cx = Context.enter();
global = new ImporterTopLevel(cx);
Scriptable bsf = Context.toObject(new BSFFunctions(mgr, this), global);
global.put("bsf", global, bsf);
// superclass does not support types
@SuppressWarnings("unchecked") final Vector<BSFDeclaredBean> beans = declaredBeans;
for (BSFDeclaredBean declaredBean : beans) {
declareBean(declaredBean);
}
} catch (Throwable t) {
// NOSONAR We handle correctly Error case in function
handleError(t);
} finally {
Context.exit();
}
}
Aggregations