Search in sources :

Example 1 with BshClassManager

use of bsh.BshClassManager in project qi4j-sdk by Qi4j.

the class BeanShellMixin method buildNamespace.

private static NameSpace buildNamespace(Class compositeType, Interpreter runtime) throws IOException {
    ClassLoader loader = compositeType.getClassLoader();
    BshClassManager classManager = BshClassManager.createClassManager(runtime);
    classManager.setClassLoader(loader);
    NameSpace namespace = new NameSpace(classManager, compositeType.getName());
    URL scriptUrl = getFunctionResource(compositeType);
    if (scriptUrl == null) {
        return null;
    }
    Reader source = getSource(compositeType, scriptUrl);
    try {
        runtime.eval(source, namespace, scriptUrl.toString());
    } catch (EvalError evalError) {
        //TODO: Auto-generated, need attention.
        evalError.printStackTrace();
    }
    return namespace;
}
Also used : NameSpace(bsh.NameSpace) EvalError(bsh.EvalError) BshClassManager(bsh.BshClassManager) URL(java.net.URL)

Aggregations

BshClassManager (bsh.BshClassManager)1 EvalError (bsh.EvalError)1 NameSpace (bsh.NameSpace)1 URL (java.net.URL)1