@Override List<String> getRequestParts() { List<String> parts = super.getRequestParts(); parts.add(attribute); parts.add(serializeArgumentToRequestPart(value)); addPath(parts,path); return parts; }
@Override JSONObject toJson() { JSONObject ret = super.toJson(); ret.put("attribute",attribute); ret.put("value",serializeArgumentToJson(value)); if (path != null) { ret.put("path",path); } return ret; }
public static J4pWriteRequest createWriteRequest(String attribute, Object value) throws MalformedObjectNameException { J4pWriteRequest answer = new J4pWriteRequest(MBeans.FABRIC.getUrl(), attribute, value); answer.setPreferredHttpMethod("POST"); return answer; }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); String attribute; AbtractJ4pMBeanRequest request; if ((attribute = getterAttributeName(method)) != null) { request = new J4pReadRequest(objectName, attribute); } else if ((attribute = setterAttributeName(method)) != null) { request = new J4pWriteRequest(objectName, attribute, args[0]); } else { name = executeMethodName(method); if (args == null | method.getParameterTypes().length == 0) { request = new J4pExecRequest(objectName, name); } else { request = new J4pExecRequest(objectName, name, args); } } try { request.setPreferredHttpMethod("POST"); J4pResponse response = jolokia.execute(request); Object value = response.getValue(); return JolokiaHelpers.convertJolokiaToJavaType(method.getReturnType(), value); } catch (J4pException e) { List<Object> argsList = args == null ? null : Arrays.asList(args); LOG.warn("Failed to invoke " + objectName + " method: " + name + " with arguments: " + argsList + ". " + e, e); throw e; } }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { if (isGetter(method)) { String attname = getAttributeName(method); J4pReadRequest readReq = new J4pReadRequest(objectName, attname); Object result = client.execute(readReq).getValue(); return unmarshalResult(method, result); } else if (isSetter(method)) { String attname = getAttributeName(method); Object[] params = marshalParameters(method, args); J4pWriteRequest writeReq = new J4pWriteRequest(objectName, attname, params); writeReq.setPreferredHttpMethod("POST"); client.execute(writeReq); return null; } else { Object[] params = marshalParameters(method, args); String operation = getOperationInfo(method).getName(); J4pExecRequest execReq = new J4pExecRequest(objectName, operation, params); execReq.setPreferredHttpMethod("POST"); Object result = client.execute(execReq).getValue(); return unmarshalResult(method, result); } } catch (Throwable th) { LOGGER.error("Proxy invocation error on: " + method.getDeclaringClass().getName() + "." + method.getName(), th); throw th; } }
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String name = method.getName(); String attribute; AbtractJ4pMBeanRequest request; if ((attribute = getterAttributeName(method)) != null) { request = new J4pReadRequest(objectName, attribute); } else if ((attribute = setterAttributeName(method)) != null) { request = new J4pWriteRequest(objectName, attribute, args[0]); } else { name = executeMethodName(method); if (args == null | method.getParameterTypes().length == 0) { request = new J4pExecRequest(objectName, name); } else { request = new J4pExecRequest(objectName, name, args); } } try { request.setPreferredHttpMethod("POST"); J4pResponse response = jolokia.execute(request); Object value = response.getValue(); return JolokiaClients.convertJolokiaToJavaType(method.getReturnType(), value); } catch (J4pException e) { List<Object> argsList = args == null ? null : Arrays.asList(args); LOG.warn("Failed to invoke " + objectName + " method: " + name + " with arguments: " + argsList + ". " + e, e); throw e; } }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { if (isGetter(method)) { String attname = getAttributeName(method); J4pReadRequest readReq = new J4pReadRequest(objectName, attname); Object result = client.execute(readReq).getValue(); return unmarshalResult(method, result); } else if (isSetter(method)) { String attname = getAttributeName(method); Object[] params = marshalParameters(method, args); J4pWriteRequest writeReq = new J4pWriteRequest(objectName, attname, params); writeReq.setPreferredHttpMethod("POST"); client.execute(writeReq); return null; } else { Object[] params = marshalParameters(method, args); String operation = getOperationInfo(method).getName(); J4pExecRequest execReq = new J4pExecRequest(objectName, operation, params); execReq.setPreferredHttpMethod("POST"); Object result = client.execute(execReq).getValue(); return unmarshalResult(method, result); } } catch (Throwable th) { LOGGER.error("Proxy invocation error on: " + method.getDeclaringClass().getName() + "." + method.getName(), th); throw th; } }