public class JsonRpcMultiServer extends JsonRpcServer
{ "jsonrpc": "2.0", "method": "service.method", "params": {"foo", "bar"}, "id": 1 }An example of using this class is:
JsonRpcMultiServer rpcServer = new JsonRpcMultiServer();
rpcServer.addService("Foo", new FooService())
.addService("Bar", new BarService());
A client can then call a test(String, String) method on the Foo service
like this:
{ "jsonrpc": "2.0", "method": "Foo.test", "params": ["some", "thing"], "id": 1 }
Modifier and Type | Field and Description |
---|---|
static char |
DEFAULT_SEPARATOR |
ACCEPT_ENCODING, CODE_OK, CONTENT_ENCODING, DATA, ERROR, ERROR_CODE, ERROR_MESSAGE, EXCEPTION_TYPE_NAME, httpStatusCodeProvider, ID, JSONRPC, JSONRPC_CONTENT_TYPE, METHOD, NAME, NULL, PARAMS, RESULT, VERSION, WEB_PARAM_ANNOTATION_CLASS_LOADER
Constructor and Description |
---|
JsonRpcMultiServer() |
JsonRpcMultiServer(com.fasterxml.jackson.databind.ObjectMapper mapper) |
Modifier and Type | Method and Description |
---|---|
JsonRpcMultiServer |
addService(java.lang.String name,
java.lang.Object handler) |
JsonRpcMultiServer |
addService(java.lang.String name,
java.lang.Object handler,
java.lang.Class<?> remoteInterface) |
protected java.lang.Object |
getHandler(java.lang.String serviceName)
Get the handler (object) that should be invoked to execute the specified
RPC method based on the specified service name.
|
protected java.lang.Class<?>[] |
getHandlerInterfaces(java.lang.String serviceName)
Returns the handler's class or interfaces.
|
protected java.lang.String |
getMethodName(java.lang.String methodName)
Get the method name from the methodNode, stripping off the service name.
|
char |
getSeparator() |
protected java.lang.String |
getServiceName(java.lang.String methodName)
Get the service name from the methodNode.
|
void |
setSeparator(char separator) |
handle, handle, setContentType
getRequestInterceptor, handleJsonNodeRequest, handleRequest, setAllowExtraParams, setAllowLessParams, setBackwardsCompatible, setConvertedParameterTransformer, setErrorResolver, setHttpStatusCodeProvider, setInvocationListener, setRequestInterceptor, setRethrowExceptions, setShouldLogInvocationErrors
public static final char DEFAULT_SEPARATOR
public JsonRpcMultiServer()
public JsonRpcMultiServer(com.fasterxml.jackson.databind.ObjectMapper mapper)
public JsonRpcMultiServer addService(java.lang.String name, java.lang.Object handler)
public JsonRpcMultiServer addService(java.lang.String name, java.lang.Object handler, java.lang.Class<?> remoteInterface)
public char getSeparator()
public void setSeparator(char separator)
protected java.lang.Class<?>[] getHandlerInterfaces(java.lang.String serviceName)
getHandlerInterfaces
in class JsonRpcBasicServer
serviceName
- the optional name of a serviceprotected java.lang.String getServiceName(java.lang.String methodName)
getServiceName
in class JsonRpcBasicServer
methodName
- method namenull
protected java.lang.String getMethodName(java.lang.String methodName)
getMethodName
in class JsonRpcBasicServer
methodName
- the JsonNode for the methodprotected java.lang.Object getHandler(java.lang.String serviceName)
getHandler
in class JsonRpcBasicServer
serviceName
- the service name