loaders = new ModuleLoader[] {
new JsModuleLoader(), new JsonModuleLoader(), new ClassModuleLoader()
};
RingoDebugger debugger = null;
if (config.getDebug()) {
debugger = new RingoDebugger(config);
debugger.setScopeProvider(this);
debugger.attachTo(contextFactory);
debugger.setBreakOnExceptions(true);
}
// create and initialize global scope
Context cx = contextFactory.enterContext();
try {
boolean sealed = config.isSealed();
globalScope = new RingoGlobal(cx, this, sealed);
Class<Scriptable>[] classes = config.getHostClasses();
if (classes != null) {
for (Class<Scriptable> clazz: classes) {
defineHostClass(clazz);
}
}
ScriptableList.init(globalScope);
ScriptableMap.init(globalScope);
ScriptableObject.defineClass(globalScope, ScriptableWrapper.class);
ScriptableObject.defineClass(globalScope, ModuleObject.class);
if (globals != null) {
for (Map.Entry<String, Object> entry : globals.entrySet()) {
ScriptableObject.defineProperty(globalScope, entry.getKey(),
entry.getValue(), ScriptableObject.DONTENUM);
}
}
mainWorker.evaluateScript(cx, getScript("globals"), globalScope);
evaluateBootstrapScripts(cx);
if (sealed) {
globalScope.sealObject();
}
if (debugger != null) {
debugger.setBreak();
}
try {
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
shutdown();