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


Java MBeanServerConnection.getMBeanInfo方法代码示例

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


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

示例1: fetchKafkaMetrics

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
private static void fetchKafkaMetrics(String host, String jmxPort, String metric)
    throws Exception {

  Map<String, String[]> env = new HashMap<>();
  JMXServiceURL address = new JMXServiceURL(
      "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + jmxPort + "/jmxrmi");
  JMXConnector connector = JMXConnectorFactory.connect(address, env);
  MBeanServerConnection mbs = connector.getMBeanServerConnection();


  ObjectName name = ObjectName.getInstance(metric);
  MBeanInfo beanInfo = mbs.getMBeanInfo(name);
  for (MBeanAttributeInfo attributeInfo : beanInfo.getAttributes()) {
    Object obj = mbs.getAttribute(name, attributeInfo.getName());
    System.out.println(" attributeName = " + attributeInfo.getName() + " " + obj.toString());
  }
}
 
开发者ID:pinterest,项目名称:doctorkafka,代码行数:18,代码来源:MetricsFetcher.java

示例2: doExploit

import javax.management.MBeanServerConnection; //导入方法依赖的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

示例3: doOperatingSystemMXBeanTest

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
private final int doOperatingSystemMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- OperatingSystemMXBean") ;

    try {
        ObjectName operationName =
                new ObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(operationName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        OperatingSystemMXBean operation = null ;

        operation =
                JMX.newMXBeanProxy(mbsc,
                operationName,
                OperatingSystemMXBean.class) ;
        System.out.println("getArch\t\t"
                + operation.getArch());
        System.out.println("getAvailableProcessors\t\t"
                + operation.getAvailableProcessors());
        System.out.println("getName\t\t"
                + operation.getName());
        System.out.println("getVersion\t\t"
                + operation.getVersion());

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:MXBeanInteropTest1.java

示例4: getMBeanAttributeType

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
/**
 * Get MBean Attribute from Mbean Server
 * @param jmxServerConnection
 * @param name
 * @param attribute
 * @return The type
 * @throws Exception
 */
protected String getMBeanAttributeType(
        MBeanServerConnection jmxServerConnection,
        String name,
        String attribute) throws Exception {
    ObjectName oname = new ObjectName(name);
    String mattrType = null;
    MBeanInfo minfo = jmxServerConnection.getMBeanInfo(oname);
    MBeanAttributeInfo attrs[] = minfo.getAttributes();
    for (int i = 0; mattrType == null && i < attrs.length; i++) {
        if (attribute.equals(attrs[i].getName()))
            mattrType = attrs[i].getType();
    }
    return mattrType;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:JMXAccessorSetTask.java

示例5: doClassLoadingMXBeanTest

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
private final int doClassLoadingMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- ClassLoadingMXBean") ;

    try {
        ObjectName classLoadingName =
                new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(classLoadingName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t"
                + mbInfo);
        ClassLoadingMXBean classLoading = null;

        classLoading = JMX.newMXBeanProxy(mbsc,
                classLoadingName,
                ClassLoadingMXBean.class) ;
        System.out.println("getLoadedClassCount\t\t"
                + classLoading.getLoadedClassCount());
        System.out.println("getTotalLoadedClassCount\t\t"
                + classLoading.getTotalLoadedClassCount());
        System.out.println("getUnloadedClassCount\t\t"
                + classLoading.getUnloadedClassCount());
        System.out.println("isVerbose\t\t"
                + classLoading.isVerbose());

        System.out.println("---- OK\n") ;

    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:MXBeanInteropTest1.java

示例6: doMemoryMXBeanTest

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
private final int doMemoryMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- MemoryMXBean") ;

    try {
        ObjectName memoryName =
                new ObjectName(ManagementFactory.MEMORY_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(memoryName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t"
                + mbInfo);
        MemoryMXBean memory = null ;

        memory =
                JMX.newMXBeanProxy(mbsc,
                memoryName,
                MemoryMXBean.class,
                true) ;
        System.out.println("getMemoryHeapUsage\t\t"
                + memory.getHeapMemoryUsage());
        System.out.println("getNonHeapMemoryHeapUsage\t\t"
                + memory.getNonHeapMemoryUsage());
        System.out.println("getObjectPendingFinalizationCount\t\t"
                + memory.getObjectPendingFinalizationCount());
        System.out.println("isVerbose\t\t"
                + memory.isVerbose());

        System.out.println("---- OK\n") ;

    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:38,代码来源:MXBeanInteropTest1.java

示例7: doCompilationMXBeanTest

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
private final int doCompilationMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- CompilationMXBean") ;

    try {
        ObjectName compilationName =
                new ObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME);

        if ( mbsc.isRegistered(compilationName) ) {
            MBeanInfo mbInfo = mbsc.getMBeanInfo(compilationName);
            errorCount += checkNonEmpty(mbInfo);
            System.out.println("getMBeanInfo\t\t" + mbInfo);
            CompilationMXBean compilation = null ;

            compilation =
                    JMX.newMXBeanProxy(mbsc,
                    compilationName,
                    CompilationMXBean.class) ;
            System.out.println("getName\t\t"
                    + compilation.getName());
            boolean supported =
                    compilation.isCompilationTimeMonitoringSupported() ;
            System.out.println("isCompilationTimeMonitoringSupported\t\t"
                    + supported);

            if ( supported ) {
                System.out.println("getTotalCompilationTime\t\t"
                        + compilation.getTotalCompilationTime());
            }
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:41,代码来源:MXBeanInteropTest1.java

示例8: doMemoryManagerMXBeanTest

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
private final int doMemoryManagerMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- MemoryManagerMXBean") ;

    try {
        ObjectName filterName =
                new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
                + ",*");
        Set<ObjectName> onSet = mbsc.queryNames(filterName, null);

        for (Iterator<ObjectName> iter = onSet.iterator(); iter.hasNext(); ) {
            ObjectName memoryManagerName = iter.next() ;
            System.out.println("-------- " + memoryManagerName) ;
            MBeanInfo mbInfo = mbsc.getMBeanInfo(memoryManagerName);
            System.out.println("getMBeanInfo\t\t" + mbInfo);
            errorCount += checkNonEmpty(mbInfo);
            MemoryManagerMXBean memoryManager = null;

            memoryManager =
                    JMX.newMXBeanProxy(mbsc,
                    memoryManagerName,
                    MemoryManagerMXBean.class) ;
            System.out.println("getMemoryPoolNames\t\t"
                    + Arrays.deepToString(memoryManager.getMemoryPoolNames()));
            System.out.println("getName\t\t"
                    + memoryManager.getName());
            System.out.println("isValid\t\t"
                    + memoryManager.isValid());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:MXBeanInteropTest1.java

示例9: printAttrs

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
private static void printAttrs(
        MBeanServerConnection mbsc1, Class<? extends Exception> expectX)
throws Exception {
    Set<ObjectName> names = mbsc1.queryNames(null, null);
    for (ObjectName name : names) {
        System.out.println(name + ":");
        MBeanInfo mbi = mbsc1.getMBeanInfo(name);
        MBeanAttributeInfo[] mbais = mbi.getAttributes();
        for (MBeanAttributeInfo mbai : mbais) {
            String attr = mbai.getName();
            Object value;
            try {
                value = mbsc1.getAttribute(name, attr);
            } catch (Exception e) {
                if (expectX != null && expectX.isInstance(e))
                    value = "<" + e + ">";
                else
                    throw e;
            }
            String s = "  " + attr + " = " + value;
            if (s.length() > 80)
                s = s.substring(0, 77) + "...";
            System.out.println(s);
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:OldMBeanServerTest.java

示例10: doGarbageCollectorMXBeanTest

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
private final int doGarbageCollectorMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- GarbageCollectorMXBean") ;

    try {
        ObjectName filterName =
                new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE
                + ",*");
        Set<ObjectName> onSet = mbsc.queryNames(filterName, null);

        for (Iterator<ObjectName> iter = onSet.iterator(); iter.hasNext(); ) {
            ObjectName garbageName = iter.next() ;
            System.out.println("-------- " + garbageName) ;
            MBeanInfo mbInfo = mbsc.getMBeanInfo(garbageName);
            errorCount += checkNonEmpty(mbInfo);
            System.out.println("getMBeanInfo\t\t" + mbInfo);
            GarbageCollectorMXBean garbage = null ;

            garbage =
                    JMX.newMXBeanProxy(mbsc,
                    garbageName,
                    GarbageCollectorMXBean.class) ;
            System.out.println("getCollectionCount\t\t"
                    + garbage.getCollectionCount());
            System.out.println("getCollectionTime\t\t"
                    + garbage.getCollectionTime());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:MXBeanInteropTest1.java

示例11: main

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException,
        MalformedObjectNameException, InstanceNotFoundException,
        AttributeNotFoundException, InvalidAttributeValueException,
        MBeanException, ReflectionException, IntrospectionException {
    String domainName = "MyMBean";
    int rmiPort = 1099;
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:"+rmiPort+"/"+domainName);
    // 可以类比HelloAgent.java中的那句:
    // JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
    JMXConnector jmxc = JMXConnectorFactory.connect(url);
    MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();

    //print domains
    System.out.println("Domains:------------------");
    String domains[] = mbsc.getDomains();
    for(int i=0;i<domains.length;i++){
        System.out.println("\tDomain["+i+"] = "+domains[i]);
    }
    //MBean count
    System.out.println("MBean count = "+mbsc.getMBeanCount());
    //process attribute
    ObjectName mBeanName = new ObjectName(domainName+":name=HelloWorld");
    mbsc.setAttribute(mBeanName, new Attribute("Name","zzh"));//注意这里是Name而不是name
    System.out.println("Name = "+mbsc.getAttribute(mBeanName, "Name"));

    //接下去是执行Hello中的printHello方法,分别通过代理和rmi的方式执行
    //via proxy
    HelloMBean proxy = MBeanServerInvocationHandler.newProxyInstance(mbsc, mBeanName, HelloMBean.class, false);
    proxy.printHello();
    proxy.printHello("jizhi boy");
    //via rmi
    mbsc.invoke(mBeanName, "printHello", null, null);
    mbsc.invoke(mBeanName, "printHello", new String[]{"jizhi gril"}, new String[]{String.class.getName()});

    //get mbean information
    MBeanInfo info = mbsc.getMBeanInfo(mBeanName);
    System.out.println("Hello Class: "+info.getClassName());
    for(int i=0;i<info.getAttributes().length;i++){
        System.out.println("Hello Attribute:"+info.getAttributes()[i].getName());
    }
    for(int i=0;i<info.getOperations().length;i++){
        System.out.println("Hello Operation:"+info.getOperations()[i].getName());
    }

    //ObjectName of MBean
    System.out.println("all ObjectName:--------------");
    Set<ObjectInstance> set = mbsc.queryMBeans(null, null);
    for(Iterator<ObjectInstance> it = set.iterator();it.hasNext();){
        ObjectInstance oi = it.next();
        System.out.println("\t"+oi.getObjectName());
    }
    jmxc.close();
}
 
开发者ID:breakEval13,项目名称:rocketmq-flink-plugin,代码行数:54,代码来源:Client.java

示例12: getAttribute

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
Object getAttribute(MBeanServerConnection mbsc,
                    ObjectName object,
                    String attribute)
    throws AttributeNotFoundException,
           InstanceNotFoundException,
           MBeanException,
           ReflectionException,
           IOException {
    // Check for "ObservedAttribute" replacement.
    // This could happen if a thread A called setObservedAttribute()
    // while other thread B was in the middle of the monitor() method
    // and received the old observed attribute value.
    //
    final boolean lookupMBeanInfo;
    synchronized (this) {
        if (!isActive())
            throw new IllegalArgumentException(
                "The monitor has been stopped");
        if (!attribute.equals(getObservedAttribute()))
            throw new IllegalArgumentException(
                "The observed attribute has been changed");
        lookupMBeanInfo =
            (firstAttribute == null && attribute.indexOf('.') != -1);
    }

    // Look up MBeanInfo if needed
    //
    final MBeanInfo mbi;
    if (lookupMBeanInfo) {
        try {
            mbi = mbsc.getMBeanInfo(object);
        } catch (IntrospectionException e) {
            throw new IllegalArgumentException(e);
        }
    } else {
        mbi = null;
    }

    // Check for complex type attribute
    //
    final String fa;
    synchronized (this) {
        if (!isActive())
            throw new IllegalArgumentException(
                "The monitor has been stopped");
        if (!attribute.equals(getObservedAttribute()))
            throw new IllegalArgumentException(
                "The observed attribute has been changed");
        if (firstAttribute == null) {
            if (attribute.indexOf('.') != -1) {
                MBeanAttributeInfo mbaiArray[] = mbi.getAttributes();
                for (MBeanAttributeInfo mbai : mbaiArray) {
                    if (attribute.equals(mbai.getName())) {
                        firstAttribute = attribute;
                        break;
                    }
                }
                if (firstAttribute == null) {
                    String tokens[] = attribute.split("\\.", -1);
                    firstAttribute = tokens[0];
                    for (int i = 1; i < tokens.length; i++)
                        remainingAttributes.add(tokens[i]);
                    isComplexTypeAttribute = true;
                }
            } else {
                firstAttribute = attribute;
            }
        }
        fa = firstAttribute;
    }
    return mbsc.getAttribute(object, fa);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:73,代码来源:Monitor.java

示例13: doRuntimeMXBeanTest

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
private final int doRuntimeMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- RuntimeMXBean") ;

    try {
        ObjectName runtimeName =
                new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME) ;
        MBeanInfo mbInfo = mbsc.getMBeanInfo(runtimeName);
        errorCount += checkNonEmpty(mbInfo);
        System.out.println("getMBeanInfo\t\t" + mbInfo);
        RuntimeMXBean runtime = null;

        runtime =
                JMX.newMXBeanProxy(mbsc,
                runtimeName,
                RuntimeMXBean.class) ;
        System.out.println("getClassPath\t\t"
                + runtime.getClassPath());
        System.out.println("getInputArguments\t\t"
                + runtime.getInputArguments());
        System.out.println("getLibraryPath\t\t"
                + runtime.getLibraryPath());
        System.out.println("getManagementSpecVersion\t\t"
                + runtime.getManagementSpecVersion());
        System.out.println("getName\t\t"
                + runtime.getName());
        System.out.println("getSpecName\t\t"
                + runtime.getSpecName());
        System.out.println("getSpecVendor\t\t"
                + runtime.getSpecVendor());
        System.out.println("getSpecVersion\t\t"
                + runtime.getSpecVersion());
        System.out.println("getStartTime\t\t"
                + runtime.getStartTime());
        System.out.println("getSystemProperties\t\t"
                + runtime.getSystemProperties());
        System.out.println("getUptime\t\t"
                + runtime.getUptime());
        System.out.println("getVmName\t\t"
                + runtime.getVmName());
        System.out.println("getVmVendor\t\t"
                + runtime.getVmVendor());
        System.out.println("getVmVersion\t\t"
                + runtime.getVmVersion());
        boolean supported = runtime.isBootClassPathSupported() ;
        System.out.println("isBootClassPathSupported\t\t"
                + supported);

        if ( supported ) {
            System.out.println("getBootClassPath\t\t"
                    + runtime.getBootClassPath());
        }

        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:63,代码来源:MXBeanInteropTest1.java

示例14: doBasicMXBeanTest

import javax.management.MBeanServerConnection; //导入方法依赖的package包/类
private final int doBasicMXBeanTest(MBeanServerConnection mbsc) {
    int errorCount = 0 ;
    System.out.println("---- doBasicMXBeanTest") ;

    try {
        ObjectName objName =
                new ObjectName("sqe:type=BasicMXBean") ;
        mbsc.createMBean(BASIC_MXBEAN_CLASS_NAME, objName);
        MBeanInfo mbInfo = mbsc.getMBeanInfo(objName);
        printMBeanInfo(mbInfo);
        System.out.println("---- OK\n") ;
        System.out.println("getMBeanInfo\t\t"
                + mbInfo);
        System.out.println("---- OK\n") ;

        System.out.println("Check mxbean field in the MBeanInfo");
        String mxbeanField =
                (String)mbInfo.getDescriptor().getFieldValue(JMX.MXBEAN_FIELD);

        if ( mxbeanField == null || ! mxbeanField.equals("true")) {
            System.out.println("---- ERROR : Improper mxbean field value "
                    + mxbeanField);
            errorCount++;
        }
        System.out.println("---- OK\n") ;

        System.out.println("Set attribute ObjectNameAtt");
        Attribute att = new Attribute("ObjectNameAtt", objName);
        mbsc.setAttribute(objName, att);
        ObjectName value =
                (ObjectName)mbsc.getAttribute(objName, "ObjectNameAtt");

        if ( ! value.equals(objName) ) {
            errorCount++;
            System.out.println("---- ERROR : setAttribute failed, got "
                    + value
                    + " while expecting "
                    + objName);
        }
        System.out.println("---- OK\n") ;

        System.out.println("Call operation doNothing");
        mbsc.invoke(objName,  "doNothing", null, null);
        System.out.println("---- OK\n") ;

        System.out.println("Call operation getWeather");
        Object weather = mbsc.invoke(objName,
                "getWeather",
                new Object[]{Boolean.TRUE},
                new String[]{"boolean"});
        System.out.println("Weather is " + weather);
        System.out.println("---- OK\n") ;
    } catch (Exception e) {
        Utils.printThrowable(e, true) ;
        errorCount++ ;
        System.out.println("---- ERROR\n") ;
    }

    return errorCount ;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:61,代码来源:MXBeanInteropTest2.java


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