登録フォームからデータを取得してデータベースに保存するという非常に基本的な機能を実行する、かなり標準的な GWT フォームがあります。
authenticationService.registerStudent(email, password, firstName, lastName, contact,
country, countryCode, school, lecturerFirstName, lecturerLastName,
lecturerEmail, language, new AsyncCallback<Boolean>() {
@Override
public void onFailure(Throwable throwable) {
}
@Override
public void onSuccess(Boolean bool) {
}
});
サーバー側には、データをデータベースに格納するサーブレットがあります。
public class AuthenticationServiceImpl extends RemoteServiceServlet implements AuthenticationService {
@Override
public Boolean registerStudent(String email, String password, String firstName, String lastName,
String contact, String country, String countryCode, String school,
String lecturerFirstName, String lecturerLastName, String lecturerEmail,
String language) throws IllegalArgumentException {
....
}
}
その人にアカウントの確認を求める確認メールを送信したいと考えています。関数に電子メール ロジックを実装する際の問題はregisterStudent()
、SMTP サーバーとの通信に時間がかかり、クライアント側で応答がなくなる可能性があることです。
データベースへの挿入が成功したときtrue
に関数から戻ることができる一方で、電子メールの送信機能を別のクラス/関数に「委譲」するにはどうすればよいですか? registerStudent()
なんらかの形式のマルチスレッドが必要になると思いますが、それを行う方法がわかりません。