...
Argument Name | Description | Type | Nullable | Note | ||
---|---|---|---|---|---|---|
objectName | The object name of the target object MBean | javax.management.ObjectName | No | N.A. | ||
operationName | This is the operation to be invoked on the target MBean | java.lang.String | No | N.A. | ||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="997beef5fd87b8d6-2c5100ae-42324aef-be4c9189-4b6d3e1c1c536d46cd458c33"><ac:plain-text-body><![CDATA[ | parameters | These are the input parameters of the operation | java.lang.Object[] | No | N.A. | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="1f00082654e4e520-d2c41375-40e34820-abeabf7f-f81b517f0d7cccd5d526093c"><ac:plain-text-body><![CDATA[ | signature | The operation signature | java.lang.String [] | No | N.A. | ]]></ac:plain-text-body></ac:structured-macro> |
...
Code Block | ||
---|---|---|
| ||
public class Example { public static void main(String[] args) throws Exception { MBeanServer server = ManagementFactory.getPlatformMBeanServer(); // Suppose that this is an object name corresponding to a valid managed domain instance. ObjectName objectName = new ObjectName("A:N=1"); // Suppose the mbean has an operation // public int purge(int request) try { String outputParameterName = "result"; String operationName = "purge"; Object [] parameters = new Object[]{1235}; String [] signature = new String[]{int.class.getName()}; InvocationResult result = (InvocationResultserver.invoke( objectName, operationName, parameters, signature); // Output parameters map Map<String,Object> outputSection = result.getOutputSection(); // Output parameter Integer outputParameter = (Integer) outputSection.get(outputParameterName); System.out.println("Output parameter : "+outputParameter); } catch (MBeanException exception) { Exception nested = exception.getTargetException(); if (nested instanceof MethodInvocationException) { MethodInvocationException invocationException = (MethodInvocationException) nested; System.out.println("Status Code : "+invocationException.getReturnCode()); System.out.println("Status Text : "+invocationException.getStatusText()); } } } } |
...