标准MBean的描述 [英] Description for Standard MBean

查看:79
本文介绍了标准MBean的描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在JBoss jmx-console中使我的标准MBean详细。 DynamicMBean有getMBeanInfo()来做。方法返回MBeanInfo,其中包含MBean的描述。但是我怎么能为Standard MBean做同样的事情呢?例如。我有以下MBean接口:

I want to make my Standard MBean verbose in JBoss jmx-console. DynamicMBean has getMBeanInfo() to do it. Method return MBeanInfo with description of MBean. But how I can to do the same thing for Standard MBean? E.g. I have following MBean interface:

public interface MyMBean {
  String f();
}

...以下实施:

public class My implements MyMBean {
  public String f() {
    return "test";
  }
}

在这样的示例中应该怎么做才能添加描述?

What should be done to add description in such example?

谢谢

推荐答案

对于StandardMBeans,无法添加说明或其他元信息。

For StandardMBeans there is no way for adding description or other meta information.

来自JavaDoc MBeanInfo

From the JavaDoc of MBeanInfo:


未指定标准MBean的MBeanInfo的其余详细信息。这包括MBeanInfo和任何包含的构造函数,属性,操作和通知的描述;以及构造函数和操作的参数的名称和描述。

The remaining details of the MBeanInfo for a Standard MBean are not specified. This includes the description of the MBeanInfo and of any contained constructors, attributes, operations, and notifications; and the names and descriptions of parameters to constructors and operations.

所以你需要至少使用DynamicMBeans(或ModelMBean或OpenMBean)用于指定此信息。 Spring可以帮助您,因为它允许通过注释创建DynamicMBeans,最后使用它比编写自己的StandardMBeans更简单。示例(来自spring文档):

So you need to use at least DynamicMBeans (or a ModelMBean or OpenMBean) for specifying this information. Spring can help you insofar as it allows the creation of DynamicMBeans via annotations, which at the end is even simpler to use than to write own StandardMBeans. Example (from the spring documentation) :

@ManagedResource(objectName="bean:name=testBean4",
                 description="My Managed Bean")
public class AnnotationTestBean {

    private int age;

    @ManagedAttribute(description="The Age Attribute", currencyTimeLimit=15)
    public int getAge() {
        return age;
    }
}

参见本文了解详情。

这篇关于标准MBean的描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆