public synchronized TreeLogger loadModule(BrowserChannel channel,
String moduleName, String userAgent, String url, String tabKey,
String sessionKey, byte[] userAgentIcon) {
PerfLogger.start("OophmSessionHandler.loadModule " + moduleName);
BrowserChannelServer serverChannel = (BrowserChannelServer) channel;
ModuleHandle moduleHandle = host.createModuleLogger(moduleName, userAgent,
url, tabKey, sessionKey, serverChannel, userAgentIcon);
TreeLogger logger = moduleHandle.getLogger();
moduleHandleMap.put(serverChannel, moduleHandle);
ModuleSpace moduleSpace = null;
try {
// Attach a new ModuleSpace to make it programmable.
ModuleSpaceHost msh = host.createModuleSpaceHost(moduleHandle,
moduleName);
moduleSpace = new ModuleSpaceOOPHM(msh, moduleName, serverChannel);
moduleMap.put(serverChannel, moduleSpace);
PerfLogger.start("ModuleSpace.onLoad");
moduleSpace.onLoad(logger);
moduleHandle.getLogger().log(TreeLogger.INFO,
"Module " + moduleName + " has been loaded");
} catch (Throwable e) {
// We do catch Throwable intentionally because there are a ton of things
// that can go wrong trying to load a module, including Error-derived
// things like NoClassDefFoundError.
//
moduleHandle.getLogger().log(TreeLogger.ERROR, "Failed to load module '"
+ moduleName + "' from user agent '" + userAgent + "' at "
+ channel.getRemoteEndpoint(), e);
if (moduleSpace != null) {
moduleSpace.dispose();
}
moduleHandle.unload();
moduleMap.remove(serverChannel);
moduleHandleMap.remove(serverChannel);
return null;
} finally {
PerfLogger.end();
PerfLogger.end();
}
return moduleHandle.getLogger();
}