Skip to content

Instantly share code, notes, and snippets.

@ochilab
Created September 25, 2013 08:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochilab/6696805 to your computer and use it in GitHub Desktop.
Save ochilab/6696805 to your computer and use it in GitHub Desktop.
SynchronizedRPCMethodControllerの使い方
SynchronizedRPCMethodController t = new SynchronizedRPCMethodController(10);
@UiHandler("button")
void onButtonClick(ClickEvent event) {
SynchronizedMethodHandler[] recall = new SynchronizedMethodHandler[2];
t.start();//必ず呼ぶ
t.add(new SynchronizedMethodHandler(){
public void run() {
System.out.println("前処理");
rpcMethod();
}});
t.add(new SynchronizedMethodHandler(){
public void run() {
System.out.println("1が終わり。");
rpcMethod2();
}});
t.add(new SynchronizedMethodHandler(){
public void run() {
System.out.println("2が終わり。");
rpcMethod3();
}});
t.add(new SynchronizedMethodHandler(){
public void run() {
System.out.println("後処理");
t.end();//最後の処理には必ずt.end()をいれること
}});
//以降には何も書いてはいけない(先に進んでしまいます。)
}
private void rpcMethod(){
GreetingServiceAsync service = GWT.create(GreetingService.class);
//RPC処理
service.method1("", new AsyncCallback<String>() { //XXXXのところは変更
public void onSuccess(String result) {
// RPC呼び出しが成功したときの処理
System.out.println("Success1");
t.next();//必須です。
}
public void onFailure(Throwable caught) {
//RPC呼び出しが失敗したときの処理
}
});
}
private void rpcMethod2(){
GreetingServiceAsync service = GWT.create(GreetingService.class);
//RPC処理
service.method2("", new AsyncCallback<String>() { //XXXXのところは変更
public void onSuccess(String result) {
// RPC呼び出しが成功したときの処理
System.out.println("Success2");
t.next();//必須です。
}
public void onFailure(Throwable caught) {
//RPC呼び出しが失敗したときの処理
}
});
}
private void rpcMethod3(){
GreetingServiceAsync service = GWT.create(GreetingService.class);
//RPC処理
service.method3("", new AsyncCallback<String>() { //XXXXのところは変更
public void onSuccess(String result) {
// RPC呼び出しが成功したときの処理
System.out.println("Success3");
t.next();//必須です。
}
public void onFailure(Throwable caught) {
//RPC呼び出しが失敗したときの処理
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment