This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RPCServiceImpl extends RemoteServiceServlet implements RPCService { | |
public List<Car> getCars(String city) { | |
// Implementation here | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface RPCService extends RemoteService { | |
public List<Car> getCars(String city); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface RPCServiceAsync { | |
public void getCars(String city, AsyncCallback<List<Car>> callback); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RPCServiceAsync service = GWT.create(RPCService.class); | |
service.getCars("Thessaloniki", new AsyncCallback<List<Car>>() { | |
public void onSuccess(List<Car> results) { | |
// Work done here after data is available | |
} | |
}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> Tuple2<Future<T>, AsyncCallback<T>> make() { | |
final Promise<T> promise = Promise.make(); | |
final AsyncCallback<T> callback = new AsyncCallback<T>() { | |
@Override | |
public void onFailure(final Throwable throwable) { | |
promise.failure(throwable); | |
} | |
@Override | |
public void onSuccess(final T t) { | |
promise.success(t); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Future<List<GenericDTO>> getCars(String city) { | |
final Tuple2<Future<List<GenericDTO>>, AsyncCallback<List<GenericDTO>>> futureCallback = AsyncUtils.make(); | |
rpcServiceAsync.getMediaGroups(city, futureCallback._2); | |
return futureCallback._1; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getCars(city).onSuccess(r -> {/* code here */}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> Future<T> call(Consumer<AsyncCallback<T>> c) { | |
Tuple2<Future<T>, AsyncCallback<T>> futureCallback = AsyncUtils.<T>getTuple(); | |
c.accept(futureCallback._2); | |
return futureCallback._1; | |
} | |
private static <T> Tuple2<Future<T>, AsyncCallback<T>> getTuple() { | |
final Tuple2<Future<T>, AsyncCallback<T>> futureCallback = AsyncUtils.make(); | |
return futureCallback; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call(c -> service.getCars(city, c)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyComponent { | |
private MyOtherComponentImpl otherComponent = Registry.get("MyOtherComponent", this); | |
private MyThirdComponent thirdComponent = otherComponent.getFactory(Registry.get("config")); | |
public MyComponent performAction() | |
{ | |
if(otherComponent.isConditionOk()) | |
{ | |
innerAction(); |
OlderNewer