com.almende.eve.rpc.jsonrpc
Class JSONRPC

java.lang.Object
  extended by com.almende.eve.rpc.jsonrpc.JSONRPC

public class JSONRPC
extends Object


Constructor Summary
JSONRPC()
           
 
Method Summary
static JSONRequest createRequest(Method method, Object[] args)
          Create a JSONRequest from a java method and arguments
static List<Object> describe(Class<?> c, RequestParams requestParams, Boolean asJSON)
          Describe all JSON-RPC methods of given class
static JSONResponse invoke(Object object, JSONRequest request)
          Invoke a method on an object
static JSONResponse invoke(Object object, JSONRequest request, RequestParams requestParams)
          Invoke a method on an object
static String invoke(Object object, String request)
          Invoke a method on an object
static String invoke(Object object, String request, RequestParams requestParams)
          Invoke a method on an object
static List<String> validate(Class<?> c, RequestParams requestParams)
          Validate whether the given class contains valid JSON-RPC methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSONRPC

public JSONRPC()
Method Detail

invoke

public static String invoke(Object object,
                            String request)
                     throws com.fasterxml.jackson.core.JsonGenerationException,
                            com.fasterxml.jackson.databind.JsonMappingException,
                            IOException
Invoke a method on an object

Parameters:
obj - Request will be invoked on the given object
request - A request in JSON-RPC format
Returns:
Throws:
IOException
com.fasterxml.jackson.databind.JsonMappingException
com.fasterxml.jackson.core.JsonGenerationException

invoke

public static String invoke(Object object,
                            String request,
                            RequestParams requestParams)
                     throws com.fasterxml.jackson.core.JsonGenerationException,
                            com.fasterxml.jackson.databind.JsonMappingException,
                            IOException
Invoke a method on an object

Parameters:
obj - Request will be invoked on the given object
request - A request in JSON-RPC format
requestParams - Optional request parameters
Returns:
Throws:
IOException
com.fasterxml.jackson.databind.JsonMappingException
com.fasterxml.jackson.core.JsonGenerationException

invoke

public static JSONResponse invoke(Object object,
                                  JSONRequest request)
Invoke a method on an object

Parameters:
sender - Sender url
obj - will be invoked on the given object
Returns:

invoke

public static JSONResponse invoke(Object object,
                                  JSONRequest request,
                                  RequestParams requestParams)
Invoke a method on an object

Parameters:
obj - Request will be invoked on the given object
request - A request in JSON-RPC format
requestParams - Optional request parameters
Returns:

validate

public static List<String> validate(Class<?> c,
                                    RequestParams requestParams)
Validate whether the given class contains valid JSON-RPC methods. A class if valid when:
- There are no public methods with equal names
- The parameters of all public methods have the @Name annotation
If the class is not valid, an Exception is thrown

Parameters:
c - The class to be verified
requestParams - optional request parameters
Returns:
errors A list with validation errors. When no problems are found, an empty list is returned

describe

public static List<Object> describe(Class<?> c,
                                    RequestParams requestParams,
                                    Boolean asJSON)
Describe all JSON-RPC methods of given class

Parameters:
c - The class to be described
requestParams - Optional request parameters.
asJSON - If true, the described methods will be in an easy to parse JSON structure. If false, the returned description will be in human readable format.
Returns:

createRequest

public static JSONRequest createRequest(Method method,
                                        Object[] args)
Create a JSONRequest from a java method and arguments

Parameters:
method -
args -
Returns:


Copyright © 2013 Almende BV. All Rights Reserved.