/* | |
* Copyright 2007 Google Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | |
* use this file except in compliance with the License. You may obtain a copy of | |
* the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
* License for the specific language governing permissions and limitations under | |
* the License. | |
*/ | |
package com.google.gwt.core.client; | |
import com.google.gwt.dev.shell.ShellGWT; | |
/** | |
* The hosted mode implementation of the magic GWT class, with different | |
* implementations of certain core methods. | |
*/ | |
public final class GWT { | |
public interface UncaughtExceptionHandler { | |
void onUncaughtException(Throwable e); | |
} | |
// hosted mode default is to log the exception to the log window | |
private static UncaughtExceptionHandler sUncaughtExceptionHandler = new UncaughtExceptionHandler() { | |
public void onUncaughtException(Throwable e) { | |
log("Uncaught exception escaped", e); | |
} | |
}; | |
public static UncaughtExceptionHandler getUncaughtExceptionHandler() { | |
return sUncaughtExceptionHandler; | |
} | |
public static void setUncaughtExceptionHandler( | |
UncaughtExceptionHandler handler) { | |
sUncaughtExceptionHandler = handler; | |
} | |
public static Object create(Class classLiteral) { | |
// deferred binding at runtime | |
return ShellGWT.create(classLiteral); | |
} | |
public static String getTypeName(Object o) { | |
// uses reflection in hosted mode | |
return ShellGWT.getTypeName(o); | |
} | |
public static boolean isScript() { | |
// false in hosted mode | |
return false; | |
} | |
public static String getHostPageBaseURL() { | |
return Impl.getHostPageBaseURL(); | |
} | |
public static String getModuleBaseURL() { | |
return Impl.getModuleBaseURL(); | |
} | |
public static String getModuleName() { | |
return Impl.getModuleName(); | |
} | |
public static void log(String message, Throwable e) { | |
// logs to the shell logger in hosted mode | |
ShellGWT.log(message, e); | |
} | |
} |