// TODO: consider a cleaner solution
wrapFactory.engine = this;
// Produce a ContextFactory that only redirects calls to RhinoEngine,
// so they can be overridden easily in inherited classes.
ContextFactory contextFactory = new ContextFactory() {
protected boolean hasFeature(Context cx, int feature) {
return RhinoEngine.this.hasFeature(cx,
feature, super.hasFeature(cx, feature));
}
protected Context makeContext() {
Context context = super.makeContext();
RhinoEngine.this.enter(context);
return context;
}
protected void observeInstructionCount(Context cx,
int instructionCount) {
RhinoEngine.this.observeInstructionCount(cx, instructionCount);
}
};
ContextFactory.initGlobal(contextFactory);
// The debugger needs to be created before the context, otherwise
// notification won't work
String rhinoDebug = System.getProperty("rhino.debug");
if (rhinoDebug != null) {
try {
debugger = new RhinoDebugger(rhinoDebug);
debugger.start();
contextFactory.addListener(debugger);
} catch (Exception e) {
e.printStackTrace();
}
}
context = contextFactory.enterContext();
topLevel = this.makeTopLevel(context);
}