public final class GWT extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
GWT.UncaughtExceptionHandler
This interface is used to catch exceptions at the "top level" just before
they escape to the browser.
|
Modifier and Type | Field and Description |
---|---|
static String |
HOSTED_MODE_PERMUTATION_STRONG_NAME
This constant is used by
getPermutationStrongName() when running in
Development Mode. |
Constructor and Description |
---|
GWT() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
create(Class<?> classLiteral)
Instantiates a class via deferred binding.
|
static void |
debugger()
Emits a JavaScript "debugger" statement on the line that called this method.
|
static String |
getHostPageBaseURL()
Gets the URL prefix of the hosting page, useful for prepending to relative
paths of resources which may be relative to the host page.
|
static String |
getModuleBaseForStaticFiles()
Gets the URL prefix that should be prepended to URLs that point to
static files generated by the GWT compiler, such as files in the
module's public path.
|
static String |
getModuleBaseURL()
Gets the URL prefix that should be prepended to URLs that
are intended to be module-relative, such as RPC entry points.
|
static String |
getModuleName()
Gets the name of the running module.
|
static String |
getPermutationStrongName()
Returns the permutation's strong name.
|
static String |
getTypeName(Object o)
Deprecated.
|
static GWT.UncaughtExceptionHandler |
getUncaughtExceptionHandler()
Returns the currently active uncaughtExceptionHandler.
|
static String |
getUniqueThreadId()
Returns the empty string when running in Production Mode, but returns a
unique string for each thread in Development Mode (for example, different
windows accessing the dev mode server will each have a unique id, and
hitting refresh without restarting dev mode will result in a new unique id
for a particular window.
|
static String |
getVersion() |
static boolean |
isClient()
Returns
true when running inside the normal GWT environment,
either in Development Mode or Production Mode. |
static boolean |
isProdMode()
Returns
true when running in production mode. |
static boolean |
isScript()
Determines whether or not the running program is script or bytecode.
|
static void |
log(String message)
Logs a message to the development shell logger in Development Mode, or to
the console in Super Dev Mode.
|
static void |
log(String message,
Throwable e)
Logs a message to the development shell logger in Development Mode, or to
the console in Super Dev Mode.
|
static void |
reportUncaughtException(Throwable e)
Reports an exception caught at the "top level" to a handler set via
setUncaughtExceptionHandler(UncaughtExceptionHandler) . |
static void |
runAsync(Class<?> name,
RunAsyncCallback callback)
The same as
runAsync(RunAsyncCallback) , except with an extra
parameter to provide a name for the call. |
static void |
runAsync(RunAsyncCallback callback)
Run the specified callback once the necessary code for it has been loaded.
|
static void |
setUncaughtExceptionHandler(GWT.UncaughtExceptionHandler handler)
Sets a custom uncaught exception handler.
|
public static final String HOSTED_MODE_PERMUTATION_STRONG_NAME
getPermutationStrongName()
when running in
Development Mode.public static <T> T create(Class<?> classLiteral)
The argument to create(Class)
must be a class literal
because the Production Mode compiler must be able to statically determine
the requested type at compile-time. This can be tricky because using a
Class
variable may appear to work correctly in Development Mode.
classLiteral
- a class literal specifying the base class to be
instantiatedpublic static String getHostPageBaseURL()
getModuleBaseURL()
unless you have a specific reason to
load a resource relative to the host page.public static String getModuleBaseForStaticFiles()
Normally this will be the same value as getModuleBaseURL()
, but
may be different when a GWT app is configured to get its static resources
from a different server.
public static String getModuleBaseURL()
If the URL points to an output file of the GWT compiler (such as
a file in the public path), use getModuleBaseForStaticFiles()
instead.
public static String getModuleName()
public static String getPermutationStrongName()
@Deprecated public static String getTypeName(Object o)
Object.getClass()
, Class.getName()
public static GWT.UncaughtExceptionHandler getUncaughtExceptionHandler()
reportUncaughtException(Throwable)
public static void reportUncaughtException(Throwable e)
setUncaughtExceptionHandler(UncaughtExceptionHandler)
. This is
used in places where the browser calls into user code such as event
callbacks, timers, and RPC.
If no UncaughtExceptionHandler
is set, the exception is reported
to browser. Browsers usually log these exceptions to the JavaScript
console.
public static String getUniqueThreadId()
public static String getVersion()
public static boolean isClient()
true
when running inside the normal GWT environment,
either in Development Mode or Production Mode. Returns false
if this code is running in a plain JVM. This might happen when running
shared code on the server, or during the bootstrap sequence of a
GWTTestCase test.public static boolean isProdMode()
true
when running in production mode. Returns
false
when running either in development mode, or when running
in a plain JVM.public static boolean isScript()
public static void log(String message)
public static void log(String message, Throwable e)
public static void debugger()
public static void runAsync(Class<?> name, RunAsyncCallback callback)
runAsync(RunAsyncCallback)
, except with an extra
parameter to provide a name for the call. The name parameter should be
supplied with a class literal. If two GWT.runAsync calls use the same
class literal, the codesplitter will put the corresponding code in
the same code fragment.public static void runAsync(RunAsyncCallback callback)
public static void setUncaughtExceptionHandler(GWT.UncaughtExceptionHandler handler)
getUncaughtExceptionHandler()
for details.handler
- the handler that should be called when an exception is
about to escape to the browser, or null
to clear the
handler and allow exceptions to escape.Copyright © 2018. All rights reserved.