RESTlet フレームワークを使用しています。
サーバーがクライアントから送信されたオブジェクトを取得する方法がわかりません。例えば。クライアント側にそのようなインターフェースがあります:
public interface AuthorizationResource {
@Post
public void login(Authentication auth);
}
次に、Authentication クラスのオブジェクトをサーバーに送信します。
Authentication auth = new Authentication ("login", "password");
resource.login(auth);
Authentication クラス (どちらのクラスもサーバーとクライアントで利用できます):
public class Authentication implements Serializable{
private static final long serialVersionUID = 1L;
public String login;
public String password;
public Authentication() {}
public Authentication(String login, String password) {
super();
this.login = login;
this.password = password;
}
public String getLogin() {
return login;
}
public String getPassword() {
return password;
}
public void setLogin(String login) {
this.login = login;
}
public void setPassword(String password) {
this.password = password;
}
}
次にサーバー側で、Authentication クラスのオブジェクトを取得します。
public class AuthenticationServerResource extends ServerResource {
Authentication auth = new Authentication("defaultLogin", "defaultPassword");
@Post
public void login (Authentication auth) {
this.auth = auth;
System.out.println(auth.getLogin());
}
}
しかし、何も起こりません。コンソールには何も出力されません。
オブジェクトをシリアル化する最良の方法はどれですか? 私のやり方は正しいですか?