cz.eman.jsonrpc.shared
Class RpcHandler

java.lang.Object
  extended by cz.eman.jsonrpc.shared.RpcHandler

public class RpcHandler
extends java.lang.Object

Main class to process json-rpc strings. Method parses string, tries to create instance of class with methods acording to url and tries to call it's method acording to json-rpc.

Author:
Karel Hovorka

Constructor Summary
RpcHandler()
           
 
Method Summary
 java.lang.String displayHelp()
          Displays simple list of classes, their methods and parameters.
 java.lang.String onCall(java.lang.String url, java.lang.String text)
          Tries to retrieve class registered under this url, if there is one, tries to call method.
static void registerClass(java.lang.String url, java.lang.Class<?> cl)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RpcHandler

public RpcHandler()
Method Detail

registerClass

public static void registerClass(java.lang.String url,
                                 java.lang.Class<?> cl)
Parameters:
url - Address relative to address of JsonRpcServlet, see your web.xml. For example if servlet maping is domain.com/jsonrpc/ and you register for url "user", all calls to domain.com/jsonrpc/user will try to call registered class.
cl - RPC class to register. It must have public parameter-less constructor.

onCall

public java.lang.String onCall(java.lang.String url,
                               java.lang.String text)
Tries to retrieve class registered under this url, if there is one, tries to call method. If method succeeds, replies with json-rpc response. If there is error, reply is also in json-rpc. If error is too serious that it isn't even possible to create json-rpc reply, Throwable.getMessage() of failing exception will be returned.

Parameters:
url - Relative url of service.
text - Json-rpc 2.0 string.
Returns:

displayHelp

public java.lang.String displayHelp()
Displays simple list of classes, their methods and parameters.

Returns:
Simple list of classes, their methods and parameters.
See Also:
ServiceDetailsWriter