...
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="b9bdd7515e022b61-716bf6ec-4010426b-abfba372-2ba2cbd9dca7df893f1c402b"><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="b7655354c05c56bc-d0045e99-4e394b56-a233a73d-bdaf94107d5a644b7f37a017"><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 = (InvocationResult) server.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 (exception.getTargetException()nested instanceof MethodInvocationException) { MethodInvocationException invocationException = (MethodInvocationException) exception.getTargetException()nested; System.out.println("Status Code : "+invocationException.getReturnCode()); System.out.println("Status Text : "+invocationException.getStatusText()); } } } } |
...