I am writing Jersey RESTful web services. All my method like add, delete, get work. But i want create method who showing what book what user borrowing.
public class UserManagement {
private Map<Long, UserMaker> userMaker = DataBase.getUserMaker();
public UserManagement(){ //id , name, surname, nin, status of book
userMaker.put((long) 1, new UserMaker(1,"John", "Castles", 12345,0));
public UserMaker hireBook(UserMaker user, BookMaker book){ // method who update status hiring book , if 0 that means book is rented
if(user.getId() <= 0){
return null;
}
book.setStatus((int) user.getId()); //
user.setWhatIhave((int) (book.getId())); // convert int to long
userMaker.put(user.getId(), user);
return user;
} }
And now i want using method with multiple parameters
@Path("/user")
public class UserCRUD {
UserManagement userManagementWS = new UserManagement();
@PUT
@Path("/{idU}/{idB}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public UserMaker hireBook(
@PathParam("idU") long idU, UserMaker user,
@PathParam("idB") long idB, BookMaker book) {
user.setId(idU);
return userManagementWS.hireBook(user, book); //borrowing books
} }
And i got error, but all looks fine:
Method public project.emil.lib.model.UserMaker project.emil.lib.resources.UserCRUD.hireBook(long,project.emil.lib.model.UserMaker,long,project.emil.lib.model.BookMaker) on resource class project.emil.lib.resources.UserCRUD contains multiple parameters with no annotation. Unable to resolve the injection source.
Any tip? :)