/** * 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; }
/** * Description of all of the operations available on the MBean. * * @return full description of each operation on the MBean */ public Collection<String> listOperationDescriptions() { List<String> list = new ArrayList<String>(); try { MBeanOperationInfo[] operations = beanInfo.getOperations(); for (MBeanOperationInfo operation : operations) { list.add(describeOperation(operation)); } } catch (Exception e) { throwException("Could not list operation descriptions. 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(); } } } } }
MBeanOperationInfo[] operations = info.getOperations(); if (operations.length > 0) { result.append("Operations:");
for ( ObjectInstance oi : testMBeans ) { MBeanInfo mBeanInfo = mbc.getMBeanInfo(oi.getObjectName()); for ( MBeanOperationInfo opInfo : mBeanInfo.getOperations() ) { try { mbc.invoke(oi.getObjectName(), opInfo.getName(), params, new String[] {});
/** * 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; }
MBeanOperationInfo[] operationInfo = info.getOperations(); this.allowedOperations = new HashMap<>(operationInfo.length); for (MBeanOperationInfo infoEle : operationInfo) {
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); } }
MBeanOperationInfo[] operationInfo = mbsc.getMBeanInfo(instance.getObjectName()).getOperations();
MBeanOperationInfo[] operationInfo = info.getOperations(); this.allowedOperations = new HashMap<>(operationInfo.length); for (MBeanOperationInfo infoEle : operationInfo) {
private ResourcePermission getOperationContext(ObjectName objectName, String featureName, boolean isOp) throws InstanceNotFoundException, ReflectionException { MBeanInfo beanInfo; try { beanInfo = mbs.getMBeanInfo(objectName); } catch (IntrospectionException e) { throw new GemFireSecurityException("error getting beanInfo of " + objectName, e); } // If there is no annotation defined either in the class level or method level, we should // consider this operation/attribute freely accessible ResourcePermission result = null; // find the context in the beanInfo if defined in the class level result = getOperationContext(beanInfo.getDescriptor(), result); MBeanFeatureInfo[] featureInfos; if (isOp) { featureInfos = beanInfo.getOperations(); } else { featureInfos = beanInfo.getAttributes(); } // still look into the attributes/operations to see if it's defined in the method level for (MBeanFeatureInfo info : featureInfos) { if (info.getName().equals(featureName)) { // found the featureInfo of this method on the bean result = getOperationContext(info.getDescriptor(), result); break; } } return result; }
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()); }
@Test public void testRegisterOperations() throws Exception { IJmxTestBean bean = getBean(); assertNotNull(bean); MBeanInfo inf = getMBeanInfo(); assertEquals("Incorrect number of operations registered", getExpectedOperationCount(), inf.getOperations().length); }
@Test public void testWithCglibProxy() throws Exception { IJmxTestBean tb = createJmxTestBean(); ProxyFactory pf = new ProxyFactory(); pf.setTarget(tb); pf.addAdvice(new NopInterceptor()); Object proxy = pf.getProxy(); MetadataMBeanInfoAssembler assembler = (MetadataMBeanInfoAssembler) getAssembler(); MBeanExporter exporter = new MBeanExporter(); exporter.setBeanFactory(getContext()); exporter.setAssembler(assembler); String objectName = "spring:bean=test,proxy=true"; Map<String, Object> beans = new HashMap<>(); beans.put(objectName, proxy); exporter.setBeans(beans); start(exporter); MBeanInfo inf = getServer().getMBeanInfo(ObjectNameManager.getInstance(objectName)); assertEquals("Incorrect number of operations", getExpectedOperationCount(), inf.getOperations().length); assertEquals("Incorrect number of attributes", getExpectedAttributeCount(), inf.getAttributes().length); assertTrue("Not included in autodetection", assembler.includeBean(proxy.getClass(), "some bean name")); }
assert info.getOperations().length == 2; for (MBeanOperationInfo opInfo : info.getOperations()) { if (opInfo.getDescription().equals("MBeanOperation.")) assert opInfo.getSignature().length == 2; for (MBeanParameterInfo paramInfo : info.getOperations()[0].getSignature()) { if (paramInfo.getName().equals("ignored")) assert paramInfo.getDescription().equals("MBeanOperationParameter1.") == true;
MBeanOperationInfo[] oops = mBeanInfo.getOperations(); boolean resetFound = false; for (MBeanOperationInfo op : oops) {