public class ServiceBase
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
ServiceBase(RequestDispatcher requestDispatcher)
Create a service with the given connection.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkForError(com.solidfire.gson.JsonObject resultObj) |
protected <TResult> TResult |
decodeResponse(java.lang.String response,
java.lang.Class<TResult> resultParamsClass)
Decodes the JSON-RPC response.
|
protected <TRequest> java.lang.String |
encodeRequest(java.lang.String method,
TRequest requestParams,
java.lang.Class<TRequest> requestParamsClass)
Constructs the JSON-RPC request.
|
protected ApiServerException |
extractApiError(com.solidfire.gson.JsonElement errorElem)
Decodes the error portion, if it exists, from the JSON-RPC response.
|
protected com.solidfire.gson.GsonBuilder |
getGsonBuilder()
Getter for property 'gsonBuilder'.
|
RequestDispatcher |
getRequestDispatcher()
Get the communication mechanism of this service.
|
<TResult,TRequest> |
sendRequest(java.lang.String method,
TRequest requestParams,
java.lang.Class<TRequest> requestParamsClass,
java.lang.Class<TResult> resultParamsClass)
Send the request to the remote system.
|
protected ServiceBase(RequestDispatcher requestDispatcher)
requestDispatcher
- is the mechanism for sending requests to some location.public RequestDispatcher getRequestDispatcher()
protected com.solidfire.gson.GsonBuilder getGsonBuilder()
public <TResult,TRequest> TResult sendRequest(java.lang.String method, TRequest requestParams, java.lang.Class<TRequest> requestParamsClass, java.lang.Class<TResult> resultParamsClass)
method
- the api method namerequestParams
- the object containing the request parametersrequestParamsClass
- the class (type) of the request objectresultParamsClass
- the class (type) of the results objectprotected <TRequest> java.lang.String encodeRequest(java.lang.String method, TRequest requestParams, java.lang.Class<TRequest> requestParamsClass)
method
- the api method namerequestParams
- the object containing the request parametersrequestParamsClass
- the class (type) of the request objectprotected <TResult> TResult decodeResponse(java.lang.String response, java.lang.Class<TResult> resultParamsClass)
response
- the JSON encoded responseresultParamsClass
- the class (type) of the result object returnedprotected void checkForError(com.solidfire.gson.JsonObject resultObj) throws ApiServerException
ApiServerException
protected ApiServerException extractApiError(com.solidfire.gson.JsonElement errorElem)
errorElem
- the JSON error object