T - the type of interface that must be implemented by the derivative
class.@AsyncProxy.DefaultValue public interface AsyncProxy<T>
Once method playback has finished, the proxy will continue to forward invocations onto the instantiated object.
Example use:
interface IFoo {
void doSomething(int a, int b);
void anotherMethad(Object o);
}
class FooImpl implements IFoo { .... }
@ConcreteType(FooImpl.class)
interface FooProxy extends AsyncProxy<IFoo>, IFoo {}
class UserOfIFoo {
private IFoo foo = GWT.create(FooProxy.class);
void makeTrouble() {
// This first call triggers a runAsync load
foo.doSomething(1, 2);
// and this second will replayed after the call to doSomething()
foo.anotherMethod("A string");
}
}
For cases where dispatch speed is critical, a ProxyCallback can be installed
in order to reassign the field containing the AsyncProxy instance with the
backing object:
class UserOfIFoo {
private IFoo fooOrProxy = GWT.create(FooProxy.class);
public UserOfIFoo() {
// When the load, initialization, and playback are done, get rid of the proxy.
((AsyncProxy<IFoo>) fooOrProxy).setProxyCallback(new ProxyCallback<IFoo>() {
public void onComplete(IFoo instance) {
fooOrProxy = instance;
}
});
}
void makeTrouble() {
// This first call triggers a runAsync load
fooOrProxy.doSomething(1, 2);
// and this second will also be replayed before the above onComplete is called
fooOrProxy.anotherMethod("A string");
}
}
| Modifier and Type | Interface and Description |
|---|---|
static interface |
AsyncProxy.AllowNonVoid
If this annotation is applied to an AsyncProxy type, it will be legal for
the parameterized type
T to declare non-void methods. |
static interface |
AsyncProxy.ConcreteType
This interface should be applied to the AsyncProxy subtype in order to
specify the Class literal that will be passed to
GWT.create(Class). |
static interface |
AsyncProxy.DefaultValue
This annotation specifies the return value for primitive methods when the
AsyncProxy.AllowNonVoid annotation has been applied to an AsyncProxy. |
static class |
AsyncProxy.ProxyCallback<T>
The callback used by
setProxyCallback(ProxyCallback). |
| Modifier and Type | Method and Description |
|---|---|
T |
getProxiedInstance()
Returns the underlying proxied object if it has been instantiated or
null. |
void |
setProxyCallback(AsyncProxy.ProxyCallback<T> callback)
Sets a callback that can be used to influence the initialization process.
|
T getProxiedInstance()
null.void setProxyCallback(AsyncProxy.ProxyCallback<T> callback)