public final class InitVotes extends Object
The InitVotes class provides the central algorithm around which disparate services within the Errai Framework can elect to prevent initialization and be notified when initialization occurs. This is required internally to ensure that services such as RPC proxies have been properly bound prior to any remote calls being made. This API also makes it possible for user-defined services and extensions to Errai to participate in the startup contract.
Initialization fails if there are any services still waiting after the timeout duration has elapsed. By default the
timeout is 90 seconds for Development Mode and 45 seconds for production mode, but it can be adjusted by setting the
Javascript variable erraiInitTimeout
in the GWT Host Page.
Modifier and Type | Method and Description |
---|---|
static void |
registerInitFailureListener(InitFailureListener failureListener)
Registers an
InitFailureListener to monitor for initialization failures of the
framework or its components. |
static void |
registerOneTimeDependencyCallback(Class clazz,
Runnable runnable) |
static void |
registerOneTimeInitCallback(Runnable runnable)
Registers a one-time callback task to be executed once initialization occurs.
|
static void |
registerOneTimePreInitCallback(Runnable runnable) |
static void |
registerPersistentDependencyCallback(Class clazz,
Runnable runnable) |
static void |
registerPersistentInitCallback(Runnable runnable)
Registers a callback task to be executed once initialization occurs.
|
static void |
registerPersistentPreInitCallback(Runnable runnable) |
static void |
reset()
Resets the state, clearing all current waiting votes and disarming the startup process.
|
static void |
setTimeoutMillis(int millis)
Specifies the number of milliseconds that will be permitted to transpire until dependencies are
assumed to have failed to satisfy, and thus an error is rendered to the browser console.
|
static void |
startInitPolling() |
static void |
voteFor(Class<?> clazz)
Votes for initialization and removes a lock on the initialization of framework services.
|
static void |
waitFor(Class<?> clazz)
Declares a startup dependency on the specified class.
|
public static void reset()
registerPersistentInitCallback(Runnable)
.public static void setTimeoutMillis(int millis)
millis
- milliseconds.public static void waitFor(Class<?> clazz)
voteFor(Class)
is called with the same
Class reference passed to this method.
If no dependencies have previously been declared, then the first caller to invoke this method
arms and begins the startup process. This starts the timer window (see
setTimeoutMillis(int)
) for which all components being waited on are expected to report
back that they're ready.clazz
- a class reference.voteFor(Class)
public static void voteFor(Class<?> clazz)
registerPersistentInitCallback(Runnable)
clazz
- a class referencepublic static void registerPersistentDependencyCallback(Class clazz, Runnable runnable)
public static void registerOneTimeDependencyCallback(Class clazz, Runnable runnable)
public static void registerPersistentPreInitCallback(Runnable runnable)
public static void registerOneTimePreInitCallback(Runnable runnable)
public static void registerPersistentInitCallback(Runnable runnable)
reset()
is called. If this is not desirable, see:
registerOneTimeInitCallback(java.lang.Runnable)
;
As of Errai 3.0, the callback list is de-duped based on instance to simplify initialization code in modules. You can now safely re-add a Runnable in initialization code as long as it is always guaranteed to be the same instance.*
runnable
- a callback to executepublic static void registerOneTimeInitCallback(Runnable runnable)
registerPersistentInitCallback(Runnable)
Callback(Runnable)},
callbacks registered with this method will only be executed once and will never be used again
if framework services are re-initialized.runnable
- a callback to executepublic static void registerInitFailureListener(InitFailureListener failureListener)
InitFailureListener
to monitor for initialization failures of the
framework or its components.failureListener
- the instance of the InitFailureListener
to be registered.public static void startInitPolling()
Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.