/**
* Runs the module's user startup code.
*/
public final void onLoad(TreeLogger logger) throws UnableToCompleteException {
Event moduleSpaceLoadEvent = SpeedTracerLogger.start(DevModeEventType.MODULE_SPACE_LOAD);
// Tell the host we're ready for business.
//
host.onModuleReady(this);
// Make sure we can resolve JSNI references to static Java names.
//
try {
createStaticDispatcher(logger);
Object staticDispatch = getStaticDispatcher();
invokeNativeVoid("__defineStatic", null, new Class[] {Object.class},
new Object[] {staticDispatch});
} catch (Throwable e) {
logger.log(TreeLogger.ERROR, "Unable to initialize static dispatcher", e);
throw new UnableToCompleteException();
}
// Actually run user code.
//
String entryPointTypeName = null;
try {
// Set up GWT-entry code
Class<?> implClass = loadClassFromSourceName("com.google.gwt.core.client.impl.Impl");
Method registerEntry = implClass.getDeclaredMethod("registerEntry");
registerEntry.setAccessible(true);
registerEntry.invoke(null);
Method enter = implClass.getDeclaredMethod("enter");
enter.setAccessible(true);
enter.invoke(null);
String[] entryPoints = host.getEntryPointTypeNames();
if (entryPoints.length > 0) {
try {
for (int i = 0; i < entryPoints.length; i++) {
entryPointTypeName = entryPoints[i];
Method onModuleLoad = null;
Object module;
// Try to initialize EntryPoint, else throw up glass panel
try {
Class<?> clazz = loadClassFromSourceName(entryPointTypeName);
try {
onModuleLoad = clazz.getMethod("onModuleLoad");
if (!Modifier.isStatic(onModuleLoad.getModifiers())) {
// it's non-static, so we need to rebind the class
onModuleLoad = null;
}
} catch (NoSuchMethodException e) {
// okay, try rebinding it; maybe the rebind result will have one
}
module = null;
if (onModuleLoad == null) {
module = rebindAndCreate(entryPointTypeName);
onModuleLoad = module.getClass().getMethod("onModuleLoad");
// Record the rebound name of the class for stats (below).
entryPointTypeName = module.getClass().getName().replace(
'$', '.');
}
} catch (Throwable e) {
displayErrorGlassPanel(
"EntryPoint initialization exception", entryPointTypeName, e);
throw e;
}
// Try to invoke onModuleLoad, else throw up glass panel
try {
onModuleLoad.setAccessible(true);
invokeNativeVoid("fireOnModuleLoadStart", null,
new Class[]{String.class}, new Object[]{entryPointTypeName});
Event onModuleLoadEvent = SpeedTracerLogger.start(
DevModeEventType.ON_MODULE_LOAD);
try {
onModuleLoad.invoke(module);
} finally {
onModuleLoadEvent.end();
}
} catch (Throwable e) {
displayErrorGlassPanel(
"onModuleLoad() threw an exception", entryPointTypeName, e);
throw e;