use of org.jolokia.client.request.J4pExecRequest in project fabric8 by jboss-fuse.
the class ProfileFacade method getFieldValue.
@SuppressWarnings("unchecked")
private static <T extends Object> T getFieldValue(J4pClient j4p, String operation, String versionId, String id, String field) {
T rc = null;
try {
J4pExecRequest request = Helpers.createExecRequest(operation, versionId, id, Helpers.toList(field));
J4pExecResponse response = j4p.execute(request);
Map<String, Object> value = response.getValue();
rc = (T) value.get(field);
} catch (MalformedObjectNameException e) {
throw new RuntimeException("Failed to get container field", e);
} catch (J4pException e) {
throw new RuntimeException("Failed to get container field", e);
}
return rc;
}
use of org.jolokia.client.request.J4pExecRequest in project fabric8 by jboss-fuse.
the class JolokiaInvocationHandler method invoke.
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;
}
}
use of org.jolokia.client.request.J4pExecRequest in project fabric8 by fabric8io.
the class JolokiaInvocationHandler method invoke.
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;
}
}
use of org.jolokia.client.request.J4pExecRequest in project fabric8 by fabric8io.
the class JolokiaAssert method operationResult.
protected Object operationResult(String mbean, String operation, Object... arguments) throws MalformedObjectNameException, J4pException {
ObjectName objectName = new ObjectName(mbean);
J4pResponse<J4pExecRequest> results = client.execute(new J4pExecRequest(objectName, operation, arguments));
return results.getValue();
}
Aggregations