Search in sources :

Example 1 with BSFDeclaredBean

use of org.apache.bsf.BSFDeclaredBean 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();
    }
}
Also used : Context(org.mozilla.javascript.Context) ImporterTopLevel(org.mozilla.javascript.ImporterTopLevel) Scriptable(org.mozilla.javascript.Scriptable) BSFFunctions(org.apache.bsf.util.BSFFunctions) BSFDeclaredBean(org.apache.bsf.BSFDeclaredBean)

Aggregations

BSFDeclaredBean (org.apache.bsf.BSFDeclaredBean)1 BSFFunctions (org.apache.bsf.util.BSFFunctions)1 Context (org.mozilla.javascript.Context)1 ImporterTopLevel (org.mozilla.javascript.ImporterTopLevel)1 Scriptable (org.mozilla.javascript.Scriptable)1