I am using RESTlet framework.
I don't understand how server can take an object sent by the client. For example. I have such an interface on the client side:
public interface AuthorizationResource {
@Post
public void login(Authentication auth);
}
Then I send to server the object of Authentication class:
Authentication auth = new Authentication ("login", "password");
resource.login(auth);
The Authentication class (Both classes are also available on the server and client):
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;
}
}
Then on the server side, I want to get the object of Authentication class:
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());
}
}
but nothing happens. The console doesn't output anything.
My questions, which is best way to serialize an object? Is my way right?