当前位置: 首页>>代码示例>>Java>>正文


Java MBeanInfo.getOperations方法代码示例

本文整理汇总了Java中javax.management.MBeanInfo.getOperations方法的典型用法代码示例。如果您正苦于以下问题:Java MBeanInfo.getOperations方法的具体用法?Java MBeanInfo.getOperations怎么用?Java MBeanInfo.getOperations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.MBeanInfo的用法示例。


在下文中一共展示了MBeanInfo.getOperations方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMethodInfo

import javax.management.MBeanInfo; //导入方法依赖的package包/类
/** Find the operation info for a method
 * 
 * @param oname
 * @param opName
 * @return the operation info for the specified operation
 */ 
public MBeanOperationInfo getMethodInfo( ObjectName oname, String opName )
{
    String type=null;
    MBeanInfo info=null;
    try {
        info=server.getMBeanInfo(oname);
    } catch (Exception e) {
        log.info( "Can't find metadata " + oname );
        return null;
    }
    MBeanOperationInfo attInfo[]=info.getOperations();
    for( int i=0; i<attInfo.length; i++ ) {
        if( opName.equals(attInfo[i].getName())) {
            return attInfo[i];
        }
    }
    return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Registry.java

示例2: getMethodInfo

import javax.management.MBeanInfo; //导入方法依赖的package包/类
/** Find the operation info for a method
 * 
 * @param oname
 * @param opName
 * @return the operation info for the specified operation
 */ 
public MBeanOperationInfo getMethodInfo( ObjectName oname, String opName )
{
    MBeanInfo info=null;
    try {
        info=server.getMBeanInfo(oname);
    } catch (Exception e) {
        log.info( "Can't find metadata " + oname );
        return null;
    }
    MBeanOperationInfo attInfo[]=info.getOperations();
    for( int i=0; i<attInfo.length; i++ ) {
        if( opName.equals(attInfo[i].getName())) {
            return attInfo[i];
        }
    }
    return null;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:24,代码来源:Registry.java

示例3: getMBeanInfo

import javax.management.MBeanInfo; //导入方法依赖的package包/类
/**
 * Return the MBeanInfo for the given resource, based on the given
 * per-interface data.
 */
final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface) {
    MBeanInfo mbi =
            getClassMBeanInfo(resource.getClass(), perInterface);
    MBeanNotificationInfo[] notifs = findNotifications(resource);
    if (notifs == null || notifs.length == 0)
        return mbi;
    else {
        return new MBeanInfo(mbi.getClassName(),
                mbi.getDescription(),
                mbi.getAttributes(),
                mbi.getConstructors(),
                mbi.getOperations(),
                notifs,
                mbi.getDescriptor());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:MBeanIntrospector.java

示例4: getMethodInfo

import javax.management.MBeanInfo; //导入方法依赖的package包/类
/**
 * Find the operation info for a method
 * 
 * @param oname
 * @param opName
 * @return the operation info for the specified operation
 */
public MBeanOperationInfo getMethodInfo(ObjectName oname, String opName) {
	MBeanInfo info = null;
	try {
		info = server.getMBeanInfo(oname);
	} catch (Exception e) {
		log.info("Can't find metadata " + oname);
		return null;
	}
	MBeanOperationInfo attInfo[] = info.getOperations();
	for (int i = 0; i < attInfo.length; i++) {
		if (opName.equals(attInfo[i].getName())) {
			return attInfo[i];
		}
	}
	return null;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:24,代码来源:Registry.java

示例5: printMBeanInfo

import javax.management.MBeanInfo; //导入方法依赖的package包/类
private void printMBeanInfo(MBeanInfo mbInfo) {
    System.out.println("Description " + mbInfo.getDescription());

    for (MBeanConstructorInfo ctor : mbInfo.getConstructors()) {
        System.out.println("Constructor " + ctor.getName());
    }

    for (MBeanAttributeInfo att : mbInfo.getAttributes()) {
        System.out.println("Attribute " + att.getName()
        + " [" + att.getType() + "]");
    }

    for (MBeanOperationInfo oper : mbInfo.getOperations()) {
        System.out.println("Operation " + oper.getName());
    }

    for (MBeanNotificationInfo notif : mbInfo.getNotifications()) {
        System.out.println("Notification " + notif.getName());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:MXBeanInteropTest2.java

示例6: doExploit

import javax.management.MBeanInfo; //导入方法依赖的package包/类
private static void doExploit ( final Object payloadObject, MBeanServerConnection mbc )
        throws IOException, InstanceNotFoundException, IntrospectionException, ReflectionException {
    Object[] params = new Object[1];
    params[ 0 ] = payloadObject;
    System.err.println("Querying MBeans");
    Set<ObjectInstance> testMBeans = mbc.queryMBeans(null, null);
    System.err.println("Found " + testMBeans.size() + " MBeans");
    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[] {});
                System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS");
                return;
            }
            catch ( Throwable e ) {
                String msg = e.getMessage();
                if ( msg.startsWith("java.lang.ClassNotFoundException:") ) {
                    int start = msg.indexOf('"');
                    int stop = msg.indexOf('"', start + 1);
                    String module = ( start >= 0 && stop > 0 ) ? msg.substring(start + 1, stop) : "<unknown>";
                    if ( !"<unknown>".equals(module) && !"org.jboss.as.jmx:main".equals(module) ) {
                        int cstart = msg.indexOf(':');
                        int cend = msg.indexOf(' ', cstart + 2);
                        String cls = msg.substring(cstart + 2, cend);
                        System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> FAIL CNFE " + cls + " (" + module + ")");
                    }
                }
                else {
                    System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS|ERROR " + msg);
                    return;
                }
            }
        }
    }
}
 
开发者ID:hucheat,项目名称:APacheSynapseSimplePOC,代码行数:37,代码来源:JBoss.java

示例7: check

import javax.management.MBeanInfo; //导入方法依赖的package包/类
private static void check(MBeanServer mbs, ObjectName on) throws Exception {
    MBeanInfo mbi = mbs.getMBeanInfo(on);

    // check the MBean itself
    check(mbi);

    // check attributes
    MBeanAttributeInfo[] attrs = mbi.getAttributes();
    for (MBeanAttributeInfo attr : attrs) {
        check(attr);
        if (attr.getName().equals("ReadOnly"))
            check("@Full", attr.getDescriptor(), expectedFullDescriptor);
    }

    // check operations
    MBeanOperationInfo[] ops = mbi.getOperations();
    for (MBeanOperationInfo op : ops) {
        check(op);
        check(op.getSignature());
    }

    MBeanConstructorInfo[] constrs = mbi.getConstructors();
    for (MBeanConstructorInfo constr : constrs) {
        check(constr);
        check(constr.getSignature());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:AnnotationTest.java

示例8: getOperationContext

import javax.management.MBeanInfo; //导入方法依赖的package包/类
private ResourcePermission getOperationContext(ObjectName objectName, String featureName,
    boolean isOp) throws InstanceNotFoundException, ReflectionException {
  MBeanInfo beanInfo = null;
  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 = null;
  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;
}
 
开发者ID:ampool,项目名称:monarch,代码行数:32,代码来源:MBeanServerWrapper.java

示例9: getMBeanInfo

import javax.management.MBeanInfo; //导入方法依赖的package包/类
@Override
public MBeanInfo getMBeanInfo() {
    MBeanInfo mbi = super.getMBeanInfo();
    Class<?> resourceClass = getResource().getClass();
    if (StandardMBeanIntrospector.isDefinitelyImmutableInfo(resourceClass))
        return mbi;
    return new MBeanInfo(mbi.getClassName(), mbi.getDescription(),
            mbi.getAttributes(), mbi.getConstructors(),
            mbi.getOperations(),
            MBeanIntrospector.findNotifications(getResource()),
            mbi.getDescriptor());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:StandardMBeanSupport.java

示例10: main

import javax.management.MBeanInfo; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    System.out.println("--->JRCMD MBean Test: invocation on \"operation info\"...");

    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
    JMXServiceURL url = new JMXServiceURL("rmi", null, 0);
    JMXConnectorServer cs = null;
    JMXConnector cc = null;
    try {
        cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
        cs.start();
        JMXServiceURL addr = cs.getAddress();
        cc = JMXConnectorFactory.connect(addr);
        MBeanServerConnection mbsc = cc.getMBeanServerConnection();
        ObjectName name = new ObjectName(HOTSPOT_DIAGNOSTIC_MXBEAN_NAME);
        MBeanInfo info = mbsc.getMBeanInfo(name);

        // the test should check that the MBean doesn't have any
        // Attribute, notification or constructor. Current version only
        // check operations
        System.out.println("Class Name:" + info.getClassName());
        System.out.println("Description:" + info.getDescription());
        MBeanOperationInfo[] opInfo = info.getOperations();
        System.out.println("Operations:");
        for (int i = 0; i < opInfo.length; i++) {
            printOperation(opInfo[i]);
            System.out.println("\[email protected]@@@@@\n");
        }
    } finally {
        try {
            cc.close();
            cs.stop();
        } catch (Exception e) {
        }
    }

    System.out.println("Test passed");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:DcmdMBeanTest.java

示例11: test

import javax.management.MBeanInfo; //导入方法依赖的package包/类
private static void test(Object child, String name, boolean mxbean)
    throws Exception {
    final ObjectName childName =
            new ObjectName("test:type=Child,name="+name);
    final MBeanServer server =
            ManagementFactory.getPlatformMBeanServer();
    server.registerMBean(child,childName);
    try {
        final MBeanInfo info = server.getMBeanInfo(childName);
        System.out.println(name+": " + info.getDescriptor());
        final int len = info.getOperations().length;
        if (len == OPCOUNT) {
            System.out.println(name+": OK, only "+OPCOUNT+
                    " operations here...");
        } else {
            final String qual = (len>OPCOUNT)?"many":"few";
            System.err.println(name+": Too "+qual+" foos! Found "+
                    len+", expected "+OPCOUNT);
            for (MBeanOperationInfo op : info.getOperations()) {
                System.err.println("public "+op.getReturnType()+" "+
                        op.getName()+"();");
            }
            throw new RuntimeException("Too " + qual +
                    " foos for "+name);
        }

        final Descriptor d = info.getDescriptor();
        final String mxstr = String.valueOf(d.getFieldValue("mxbean"));
        final boolean mxb =
                (mxstr==null)?false:Boolean.valueOf(mxstr).booleanValue();
        System.out.println(name+": mxbean="+mxb);
        if (mxbean && !mxb)
            throw new AssertionError("MXBean is not OpenMBean?");

        for (MBeanOperationInfo mboi : info.getOperations()) {

            // Sanity check
            if (mxbean && !mboi.getName().equals("foo")) {
                // The spec doesn't guarantee that the MBeanOperationInfo
                // of an MXBean will be an OpenMBeanOperationInfo, and in
                // some circumstances in our implementation it will not.
                // However, in thsi tests, for all methods but foo(),
                // it should.
                //
                if (!(mboi instanceof OpenMBeanOperationInfo))
                    throw new AssertionError("Operation "+mboi.getName()+
                            "() is not Open?");
            }

            final String exp = EXPECTED_TYPES.get(mboi.getName());

            // For MXBeans, we need to compare 'exp' with the original
            // type - because mboi.getReturnType() returns the OpenType
            //
            String type = (String)mboi.getDescriptor().
                        getFieldValue("originalType");
            if (type == null) type = mboi.getReturnType();
            if (type.equals(exp)) continue;
            System.err.println("Bad return type for "+
                    mboi.getName()+"! Found "+type+
                    ", expected "+exp);
            throw new RuntimeException("Bad return type for "+
                    mboi.getName());
        }
    } finally {
        server.unregisterMBean(childName);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:69,代码来源:TooManyFooTest.java

示例12: testProcessMBean

import javax.management.MBeanInfo; //导入方法依赖的package包/类
@Test
public void testProcessMBean() throws Exception {
  // validate basics of the ProcessMBean
  Set<ObjectName> mbeanNames = this.server.queryNames(objectName, null);
  assertFalse("Zero matching mbeans", mbeanNames.isEmpty());
  assertEquals(1, mbeanNames.size());
  final ObjectName name = mbeanNames.iterator().next();

  final MBeanInfo info = this.server.getMBeanInfo(name);

  final MBeanOperationInfo[] operInfo = info.getOperations();
  assertEquals(1, operInfo.length);
  assertEquals("stop", operInfo[0].getName());

  final MBeanAttributeInfo[] attrInfo = info.getAttributes();
  assertEquals(2, attrInfo.length);
  // The order of these attributes is indeterminate
  assertTrue("Pid".equals(attrInfo[0].getName()) || "Process".equals(attrInfo[0].getName()));
  assertTrue("Pid".equals(attrInfo[1].getName()) || "Process".equals(attrInfo[1].getName()));
  assertNotNull(this.server.getAttribute(name, "Pid"));
  assertNotNull(this.server.getAttribute(name, "Process"));

  assertEquals(pid, this.server.getAttribute(name, "Pid"));
  assertEquals(true, this.server.getAttribute(name, "Process"));

  // validate query using only Pid attribute
  QueryExp constraint = Query.eq(Query.attr("Pid"), Query.value(pid));
  mbeanNames = this.server.queryNames(objectName, constraint);
  assertFalse("Zero matching mbeans", mbeanNames.isEmpty());

  // validate query with wrong Pid finds nothing
  constraint = Query.eq(Query.attr("Pid"), Query.value(pid + 1));
  mbeanNames = this.server.queryNames(objectName, constraint);
  assertTrue("Found matching mbeans", mbeanNames.isEmpty());

  // validate query using both attributes
  constraint = Query.and(Query.eq(Query.attr("Process"), Query.value(true)),
      Query.eq(Query.attr("Pid"), Query.value(pid)));
  mbeanNames = this.server.queryNames(objectName, constraint);
  assertFalse("Zero matching mbeans", mbeanNames.isEmpty());

  // validate query with wrong attribute finds nothing
  constraint = Query.and(Query.eq(Query.attr("Process"), Query.value(false)),
      Query.eq(Query.attr("Pid"), Query.value(pid)));
  mbeanNames = this.server.queryNames(objectName, constraint);
  assertTrue("Found matching mbeans", mbeanNames.isEmpty());
}
 
开发者ID:ampool,项目名称:monarch,代码行数:48,代码来源:LocalProcessControllerJUnitTest.java

示例13: dumpOperation

import javax.management.MBeanInfo; //导入方法依赖的package包/类
@Test
public void dumpOperation() throws Exception {
    Field field = null;
    try {
        field = stopMBeanServer();
    } catch (Exception ex) {
        if (ex.getClass().getName().equals("java.lang.reflect.InaccessibleObjectException")) {
            // skip on JDK9
            return;
        }
    }
    assertNull("The platformMBeanServer isn't initialized now", field.get(null));

    ObjectName name;

    assertNotNull("Server is started", ManagementFactory.getPlatformMBeanServer());

    HotSpotGraalMBean realBean = HotSpotGraalMBean.create(null);

    assertNotNull("Bean is registered", name = realBean.ensureRegistered(false));
    final MBeanServer server = ManagementFactory.getPlatformMBeanServer();

    ObjectInstance bean = server.getObjectInstance(name);
    assertNotNull("Bean is registered", bean);

    MBeanInfo info = server.getMBeanInfo(name);
    assertNotNull("Info is found", info);

    final MBeanOperationInfo[] arr = info.getOperations();
    assertEquals("Currently three overloads", 3, arr.length);
    MBeanOperationInfo dumpOp = null;
    for (int i = 0; i < arr.length; i++) {
        assertEquals("dumpMethod", arr[i].getName());
        if (arr[i].getSignature().length == 3) {
            dumpOp = arr[i];
        }
    }
    assertNotNull("three args variant found", dumpOp);

    server.invoke(name, "dumpMethod", new Object[]{
                    "java.util.Arrays", "asList", ":3"
    }, null);

    MBeanAttributeInfo dump = (MBeanAttributeInfo) findAttributeInfo("Dump", info);
    Attribute dumpTo1 = new Attribute(dump.getName(), "");
    server.setAttribute(name, dumpTo1);
    Object after = server.getAttribute(name, dump.getName());
    assertEquals("", after);

    OptionValues empty = new OptionValues(EconomicMap.create());
    OptionValues unsetDump = realBean.optionsFor(empty, null);
    final MetaAccessProvider metaAccess = jdk.vm.ci.runtime.JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess();
    ResolvedJavaMethod method = metaAccess.lookupJavaMethod(Arrays.class.getMethod("asList", Object[].class));
    final OptionValues forMethod = realBean.optionsFor(unsetDump, method);
    assertNotSame(unsetDump, forMethod);
    Object nothing = unsetDump.getMap().get(DebugOptions.Dump);
    assertEquals("Empty string", "", nothing);

    Object specialValue = forMethod.getMap().get(DebugOptions.Dump);
    assertEquals(":3", specialValue);

    OptionValues normalMethod = realBean.optionsFor(unsetDump, null);
    Object noSpecialValue = normalMethod.getMap().get(DebugOptions.Dump);
    assertEquals("Empty string", "", noSpecialValue);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:66,代码来源:HotSpotGraalMBeanTest.java


注:本文中的javax.management.MBeanInfo.getOperations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。