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;
}
Aggregations