// call the an appropriate request dispatcher private JSONObject callRequestDispatcher(JmxRequest pJmxReq) throws InstanceNotFoundException, AttributeNotFoundException, ReflectionException, MBeanException, IOException { Object retValue = null; boolean useValueWithPath = false; boolean found = false; for (RequestDispatcher dispatcher : requestDispatchers) { if (dispatcher.canHandle(pJmxReq)) { retValue = dispatcher.dispatchRequest(pJmxReq); useValueWithPath = dispatcher.useReturnValueWithPath(pJmxReq); found = true; break; } } if (!found) { throw new IllegalStateException( "Internal error: No dispatcher found for handling " + pJmxReq); } JsonConvertOptions opts = getJsonConvertOptions(pJmxReq); Object jsonResult = converters .getToJsonConverter() .convertToJson(retValue, useValueWithPath ? pJmxReq.getPathParts() : null, opts); JSONObject jsonObject = new JSONObject(); jsonObject.put("value", jsonResult); jsonObject.put("request", pJmxReq.toJSON()); return jsonObject; }