ContextAction action = new ContextAction() {
public Object run(Context cx) {
log.info("initializing Rhino JavaScript engine...");
cx.setOptimizationLevel(-1); // Interpreter mode
Doc doc = document; //global 'this'-object
//define methods of doc object
String[] names = {
"getPageNumWords",
"getPageNthWord",
"selectPageNthWord",
"syncAnnotScan",
"getAnnots",
"getAnnot",
"getField",
"getURL",
"isBoxChecked",
"printSeps",
"breakpoint", //dummy
};
//TODO: problem: no overloading allowed
doc.defineFunctionProperties(names, Doc.class, ScriptableObject.DONTENUM);
Scriptable scope = cx.initStandardObjects(doc);
cx.putThreadLocal("topscope", scope);
cx.putThreadLocal("scrutinizer", scrutinizer);