org.elkoserver.util
Class JSONHTTPRequest

java.lang.Object
  extended by org.elkoserver.util.JSONHTTPRequest

public class JSONHTTPRequest
extends Object

Utility class to produce a slow service task that will make a simple HTTP call out to a JSON webservice.


Method Summary
static Callable<Object> make(String url, JSONLiteral request)
          Produce a task that will make an HTTP POST request to an external URL, wait for the reponse, parse the response as JSON, and return the parsed response as the product of the task.
static Callable<Object> make(String url, JSONObject request)
          Produce a task that will make an HTTP POST request to an external URL, wait for the reponse, parse the response as JSON, and return the parsed response as the product of the task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

make

public static Callable<Object> make(String url,
                                    JSONLiteral request)
Produce a task that will make an HTTP POST request to an external URL, wait for the reponse, parse the response as JSON, and return the parsed response as the product of the task.

Parameters:
url - The URL to issue the HTTP request to.
request - A JSON literal containing the request body to be posted.
Returns:
a parsed JSON object representing the result that was returned by the webservice, or null if there was an error of some kind.

make

public static Callable<Object> make(String url,
                                    JSONObject request)
Produce a task that will make an HTTP POST request to an external URL, wait for the reponse, parse the response as JSON, and return the parsed response as the product of the task.

Parameters:
url - The URL to issue the HTTP request to.
request - A JSON object containing the request body to be posted.
Returns:
a parsed JSON object representing the result that was returned by the webservice, or null if there was an error of some kind.