Here you can find the source of getOperation(MBeanInfo info, String opName)
public static MBeanOperationInfo getOperation(MBeanInfo info, String opName)
//package com.java2s; //License from project: LGPL import javax.management.MBeanInfo; import javax.management.MBeanOperationInfo; import javax.management.MBeanParameterInfo; public class Main { /**/*from w w w . j ava2 s . c o m*/ * Returns the first operation with the specified name. */ public static MBeanOperationInfo getOperation(MBeanInfo info, String opName) { MBeanOperationInfo[] ops = info.getOperations(); for (int i = 0; i < ops.length; i++) { if (ops[i].getName().equals(opName)) return ops[i]; } return null; } /** * Returns the first operation that takes the specified number of parameters. */ public static MBeanOperationInfo getOperation(MBeanInfo info, String opName, int paramCount) { MBeanOperationInfo[] ops = info.getOperations(); for (int i = 0; i < ops.length; i++) { if (ops[i].getName().equals(opName) && ops[i].getSignature().length == paramCount) return ops[i]; } return null; } /** * Returns the operation with the specified name and signature. * @param signature can be null. */ public static MBeanOperationInfo getOperation(MBeanInfo info, String opName, String[] signature) { if (signature == null) signature = new String[0]; MBeanOperationInfo[] ops = info.getOperations(); for (int i = 0; i < ops.length; i++) { MBeanOperationInfo op = ops[i]; if (op.getName().equals(opName)) { MBeanParameterInfo[] params = op.getSignature(); if (params.length == signature.length) { boolean found = true; for (int j = 0; found && j < params.length; j++) { if (!params[j].getType().equals(signature[j])) found = false; } if (found) return op; } } } return null; } /** * Returns the operation with the specified name, signature and return type. * @param signature can be null. */ public static MBeanOperationInfo getOperation(MBeanInfo info, String opName, String[] signature, String returnType) { if (signature == null) signature = new String[0]; MBeanOperationInfo[] ops = info.getOperations(); for (int i = 0; i < ops.length; i++) { MBeanOperationInfo op = ops[i]; if (op.getName().equals(opName) && op.getReturnType().equals(returnType)) { MBeanParameterInfo[] params = op.getSignature(); if (params.length == signature.length) { boolean found = true; for (int j = 0; found && j < params.length; j++) { if (!params[j].getType().equals(signature[j])) found = false; } if (found) return op; } } } return null; } }