ConfigurationMBean.java 文件源码

java
阅读 29 收藏 0 点赞 0 评论 0

项目:sakai 作者:
@Override
public MBeanInfo getMBeanInfo() {
    List<MBeanAttributeInfo> attributeInfos = new ArrayList<>();
    for (ConfigItem item : serverConfigurationService.getConfigData().getItems()) {
        String type = item.getType();
        switch (type) {
            case ServerConfigurationService.TYPE_BOOLEAN:
                type = "boolean";
                break;
            case ServerConfigurationService.TYPE_INT:
                type = "int";
                break;
            case ServerConfigurationService.TYPE_STRING:
                type = "java.lang.String";
                break;
        }
        attributeInfos.add(new MBeanAttributeInfo(item.getName(), type, item.getDescription(), !item.isSecured(), true, false));
    }
    List<MBeanOperationInfo> operationInfos = new ArrayList<>();
    try {
        Method method = getClass().getMethod("addAttribute", String.class, String.class);
        operationInfos.add(new MBeanOperationInfo("addAttribute", method));
    } catch (NoSuchMethodException e) {
        // Ignore
    }
    Descriptor descriptor = new DescriptorSupport();
    descriptor.setField("immutableInfo", "false");
    return new MBeanInfo(getClass().getName(), "Sakai Server Configuration",
        attributeInfos.toArray(new MBeanAttributeInfo[]{}),
        null,
        operationInfos.toArray(new MBeanOperationInfo[]{}),
        null,
        descriptor);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号