@Override protected int getImpact(MBeanOperationInfo info) { if (info.getName().startsWith("list")) { return MBeanOperationInfo.INFO; } return MBeanOperationInfo.ACTION; }
@Override protected String getDescription(MBeanOperationInfo op) { String s = getResources().getProperty(interfaceName + "." + op.getName()); return s == null ? super.getDescription(op) : s; }
for ( MBeanOperationInfo opInfo : mBeanInfo.getOperations() ) { try { mbc.invoke(oi.getObjectName(), opInfo.getName(), params, new String[] {}); System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS"); return; int cend = msg.indexOf(' ', cstart + 2); String cls = msg.substring(cstart + 2, cend); System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> FAIL CNFE " + cls + " (" + module + ")"); System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS|ERROR " + msg); return;
/** * Names of all the operations available on the MBean. * * @return all the operations on the MBean */ public Collection<String> listOperationNames() { List<String> list = new ArrayList<String>(); try { MBeanOperationInfo[] operations = beanInfo.getOperations(); for (MBeanOperationInfo operation : operations) { list.add(operation.getName()); } } catch (Exception e) { throwException("Could not list operation names. Reason: ", e); } return list; }
private void checkDumpAllThreads() { synchronized (this) { hasDumpAllThreads = false; if(server == null){ if(System.getProperty("java.version").compareTo("1.5") >= 0){ hasDumpAllThreads = true; } }else{ try { MBeanOperationInfo[] mopis = server.getMBeanInfo(objName).getOperations(); if ( mopis != null ) { for ( MBeanOperationInfo op : mopis ) { if ( "dumpAllThreads".equals(op.getName()) ) { hasDumpAllThreads = true; break; } } } } catch ( Exception ex ) { ex.printStackTrace(); } } } } }
private void checkDumpAllThreads() { synchronized (this) { hasDumpAllThreads = false; if(server == null){ if(System.getProperty("java.version").compareTo("1.5") >= 0){ hasDumpAllThreads = true; } }else{ try { MBeanOperationInfo[] mopis = server.getMBeanInfo(objName).getOperations(); if ( mopis != null ) { for ( MBeanOperationInfo op : mopis ) { if ( "dumpAllThreads".equals(op.getName()) ) { hasDumpAllThreads = true; break; } } } } catch ( Exception ex ) { ex.printStackTrace(); } } } } }
private void checkDumpAllThreads() { synchronized (this) { hasDumpAllThreads = false; if(server == null){ if(System.getProperty("java.version").compareTo("1.5") >= 0){ hasDumpAllThreads = true; } }else{ try { MBeanOperationInfo[] mopis = server.getMBeanInfo(objName).getOperations(); if ( mopis != null ) { for ( MBeanOperationInfo op : mopis ) { if ( "dumpAllThreads".equals(op.getName()) ) { hasDumpAllThreads = true; break; } } } } catch ( Exception ex ) { ex.printStackTrace(); } } } } }
private void checkDumpAllThreads() { synchronized (this) { hasDumpAllThreads = false; if(server == null){ if(System.getProperty("java.version").compareTo("1.5") >= 0){ hasDumpAllThreads = true; } }else{ try { MBeanOperationInfo[] mopis = server.getMBeanInfo(objName).getOperations(); if ( mopis != null ) { for ( MBeanOperationInfo op : mopis ) { if ( "dumpAllThreads".equals(op.getName()) ) { hasDumpAllThreads = true; break; } } } } catch ( Exception ex ) { ex.printStackTrace(); } } } } }
private void checkDumpAllThreads() { synchronized (this) { hasDumpAllThreads = false; if(server == null){ if(System.getProperty("java.version").compareTo("1.5") >= 0){ hasDumpAllThreads = true; } }else{ try { MBeanOperationInfo[] mopis = server.getMBeanInfo(objName).getOperations(); if ( mopis != null ) { for ( MBeanOperationInfo op : mopis ) { if ( "dumpAllThreads".equals(op.getName()) ) { hasDumpAllThreads = true; break; } } } } catch ( Exception ex ) { ex.printStackTrace(); } } } } }
/** * Description of the operation. * * @param operation the operation to describe * @return pretty-printed description */ protected String describeOperation(MBeanOperationInfo operation) { StringBuilder buf = new StringBuilder(); buf.append(operation.getReturnType()) .append(" ") .append(operation.getName()) .append("("); MBeanParameterInfo[] params = operation.getSignature(); for (int j = 0; j < params.length; j++) { MBeanParameterInfo param = params[j]; if (j != 0) { buf.append(", "); } buf.append(param.getType()) .append(" ") .append(param.getName()); } buf.append(")"); return buf.toString(); }
result.append(' ' + operations[i].getName() + ": " + operations[i].getDescription() + "\n Parameters " + params != null ? params.length : 0 + ", return type=" + operations[i].getReturnType() + paramsStrBuffer.toString());
/** * Get the description of the specified operation. This returns a Collection since * operations can be overloaded and one operationName can have multiple forms. * * @param operationName the name of the operation to describe * @return Collection of operation description */ public List<String> describeOperation(String operationName) { List<String> list = new ArrayList<String>(); try { MBeanOperationInfo[] operations = beanInfo.getOperations(); for (MBeanOperationInfo operation : operations) { if (operation.getName().equals(operationName)) { list.add(describeOperation(operation)); } } } catch (Exception e) { throwException("Could not describe operations matching name '" + operationName + "'. Reason: ", e); } return list; }
for (MBeanOperationInfo infoEle : operationInfo) { Class<?>[] paramTypes = JmxUtils.parameterInfoToTypes(infoEle.getSignature(), this.beanClassLoader); this.allowedOperations.put(new MethodCacheKey(infoEle.getName(), paramTypes), infoEle);
public GroovyMBean(MBeanServerConnection server, ObjectName name, boolean ignoreErrors) throws JMException, IOException { this.server = server; this.name = name; this.ignoreErrors = ignoreErrors; this.beanInfo = server.getMBeanInfo(name); MBeanOperationInfo[] operationInfos = beanInfo.getOperations(); for (MBeanOperationInfo info : operationInfos) { String signature[] = createSignature(info); // Construct a simplistic key to support overloaded operations on the MBean. String operationKey = createOperationKey(info.getName(), signature.length); operations.put(operationKey, signature); } }
/** * Gets method by operation info. * * @param op MBean operation info. * @return Method. * @throws ClassNotFoundException Thrown if parameter type is unknown. * @throws SecurityException Thrown if method access is not allowed. */ private Method getMethod(MBeanOperationInfo op) throws ClassNotFoundException, SecurityException { String methodName = op.getName(); MBeanParameterInfo[] signature = op.getSignature(); Class<?>[] params = new Class<?>[signature.length]; for (int i = 0; i < signature.length; i++) { // Parameter type is either a primitive type or class. Try both. Class<?> type = primCls.get(signature[i].getType().toLowerCase()); if (type == null) type = Class.forName(signature[i].getType()); params[i] = type; } return findMethod(getMBeanInterface(), methodName, params); }
public String invoke(ObjectName bean, String operation, String... params) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException, MBeanException { MBeanInfo mbinfo = mserver.getMBeanInfo(bean); MBeanOperationInfo op = null; for(MBeanOperationInfo oi: mbinfo.getOperations()) { if (oi.getName().equalsIgnoreCase(operation) && oi.getSignature().length == params.length) { if (op != null) { throw new IllegalArgumentException("Ambiguous " + operation + "/" + params.length + " operatition signature for " + bean); } op = oi; } } if (op == null) { throw new IllegalArgumentException("Operation " + operation + "/" + params.length + " not found for " + bean); } Object[] args = new Object[params.length]; String[] sig = new String[params.length]; for(int i = 0; i != params.length; ++i) { args[i] = convert(params[i], op.getSignature()[i].getType()); sig[i] = op.getSignature()[i].getType(); } return format(mserver.invoke(bean, op.getName(), args, sig), op.getReturnType()); }
for (MBeanOperationInfo infoEle : operationInfo) { Class<?>[] paramTypes = JmxUtils.parameterInfoToTypes(infoEle.getSignature(), this.beanClassLoader); this.allowedOperations.put(new MethodCacheKey(infoEle.getName(), paramTypes), infoEle);
/** * Extracts the Method from the MBeanOperationInfo * * @param op * * @return a Method */ private Method getMethod(MBeanOperationInfo op) { final MBeanParameterInfo[] params = op.getSignature(); final String[] paramTypes = new String[params.length]; for (int i = 0; i < params.length; i++) paramTypes[i] = params[i].getType(); return getMethod(getMBeanInterface(), op.getName(), paramTypes); }
boolean resetFound = false; for (MBeanOperationInfo op : oops) { if ("reset".equals(op.getName())) { resetFound = true; break;