java - A method that returns a value obtained in an asynchronous call -


i know it's beginner's doubt, i'll try objective possible.

i know correct way make method return value obtained through asynchronous call within own method. below simplified code of way i'm trying.

for clarification questions, i'm trying in 1 of endpoits of webservice (jersey)

@post @path("authentication") public string auth(string token) {    gson gson = new gson();   jsonresponse response = new jsonresponse();    new authusertoken(token, authcallback() {         @override         public void onsuccess(token decodedtoken) {             string uid = decodedtoken.getuid();             string email = decodedtoken.getemail();              user user = new userdao().find(uid, email);             if ( usuario != null ){                 response.setcode(response.status.accepted.name());                 response.setmessage("user found");                 response.setpayload(gson.tojson(user));              } else{                 response.setcode(response.status.accepted.name());                 response.setmessage("user not found");                 response.setpayload("");             }         }          @override         public void onerror(exception e) {             system.out.println("onfailure = "+ e.getmessage());             response.setcode(response.status.unauthorized.name());             response.setmessage(e.getmessage());             response.setpayload("");         }     });      return new gson().tojson(response); } 


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -