Note that there are some explanatory texts on larger screens.

plurals
  1. POreturn not working in service
    primarykey
    data
    text
    <p>I am getting a wierd problem and i am stuck on it for atleast 4 hours now. Actually i had written my code in a controller for testing but when i have moved the code to service i am getting a strange behaviour that the methods in service are not returning or may be methods that are calling them in the service only are not receiving .</p> <pre><code>class FacebookService implements InitializingBean, GroovyInterceptable { def getUserLikes(def at){ List&lt;String&gt; listOfUrls = [] String basicFbUrl = "https://graph.facebook.com/" String likeUrl = basicFbUrl + "me/likes?access_token=${at}" URL url = new URL(likeUrl) String jsonResponse = getResponseFromUrl(url) println "JSON RESPONSE IS ${jsonResponse}" // this is showing null } String getResponseFromUrl() { String something String resp = null; HttpURLConnection conn = (HttpURLConnection) url.openConnection(); try { int respCode = conn.responseCode if (respCode == 400) { log.error("COULD NOT MAKE CONNECTION") BufferedReader br = new BufferedReader(new InputStreamReader(conn.getErrorStream())); def jsonResp = JSON.parse(br.text) } else { resp = conn.getInputStream().getText() } } finally { conn.disconnect() } println("RETURNIG RESPONSE ${resp}") // This returns me a map as expected return resp; } </code></pre> <p>Dont know where does resp goes ?? any suggestions please ?? OK i know the culprit , i am posting the code of invokeMethod</p> <pre><code>def invokeMethod(String name, args){ System.out.println("IN INVOKE METHOD NAME ${name}") if(facebookPalsCache==null) facebookPalsCache = new FacebookPalsCache(1000) System.out.println("time before ${name} called: ${new Date()}") //Get the method that was originally called. def calledMethod = metaClass.getMetaMethod(name, args) System.out.println("CALLED METHOD IS ${calledMethod}") //The "?" operator first checks to see that the "calledMethod" is not //null (i.e. it exists). if(name.equals("getFriends")){ println "getFriends..." def session = RequestContextHolder.currentRequestAttributes().getSession() def friends = facebookPalsCache.get(session.facebook.uid) if(!friends){ def getFriends = facebookGraphService.invokeMethod (name, args) println "Saving FBFRIENDS in CACHE" facebookPalsCache.put(session.facebook.uid, getFriends) return getFriends } else return friends } else { if(calledMethod){ System.out.println("IN IF AND INVOKING METHOD ${calledMethod}") calledMethod.invoke(this, args) } else { return facebookGraphService.invokeMethod(name, args) } } System.out.println "RETURNING FROM INVOKE METHOD FOR NAME ${name}" System.out.println("time after ${name} called: ${new Date()}\n") } </code></pre> <p>OK SOMETHING IS WRONG ABOVE I DONT KNOW WHAT CAN ANYONE PLEASE HELP ??</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload