* Create a new bridge for every request to avoid all the problems with
* JSON-RPC-Java storing the bridge in the session
*/
HttpSession session = request.getSession();
JSONRPCBridge jsonrpcBridge = new JSONRPCBridge();
jsonrpcBridge.registerObject("Service", serviceInstance, serviceInterface);
session.setAttribute("JSONRPCBridge", jsonrpcBridge);
org.json.JSONObject jsonReq = null;
com.metaparadigm.jsonrpc.JSONRPCResult jsonResp = null;
try {
jsonReq = new org.json.JSONObject(requestData);
} catch (java.text.ParseException e) {
throw new RuntimeException("Unable to parse request", e);
}
String method = jsonReq.getString("method");
if ((method != null) && (method.indexOf('.') < 0)) {
jsonReq.putOpt("method", "Service" + "." + method);
}
// invoke the request
jsonResp = jsonrpcBridge.call(new Object[] {request}, jsonReq);
return jsonResp.toString().getBytes("UTF-8");
}