Jmx

〖摘要:〗


直接或间接实现DynamicMBean接口的类就是Dynamic MBean,动态MBean中的属性和操作只在运行时暴露出来,所以动态MBean适合于管理非静态的信息。

优势:
1.不用定义你自己的接口
2.属性和操作只在运行期暴露,可被动态控制
3.可以提供对MBean和他的属性和操作的描述

DynamicMBean interface定义了如下6个方法:
getMBeanInfo
getAttribute
setAttribute
getAttributes
setAttributes
invoke

getMBeanInfo方法返回一个MBeanInfo 对象,其中包括了可以获得的信息 attributes operations constructors notification,管理信息通过MBeanInfo获得,这是强于Standard MBeans的优势之一,Standard MBeans中管理信息通过Standard MBeans内省方式得到,所以实现类必须遵循方法的标准命名规范,动态MBean就没有这个限制,如果实现类中定义了一个printName()方法,他没有遵循命名规范,但他仍可以成为某属性的getter or setter 方法。

getAttribute and setAttribute 取得/设置某属性。
getAttributes and setAttributes 取得/设置某些属性。

Invoke 可以触发某方法。

下面创建一个简单的动态mbean,然后用agent调用它。

//实现动态MBean接口
//

继续阅读其余的  32586 字
irini   2007-05-14 22:54:15 阅读:133  评论:0  引用:0
〖摘要:〗
实现自己的MBean interface的class,叫做Standard MBean,它是最简单的类型,最适合静态管理信息。
Standard MBean 的语义规则:
1.非抽象类
2.至少一个public constructor
3.实现自己对应的MBean interface
4. Standard MBean所实现的接口的名字必须符合这个形式<implementing_class>MBean,如果MBean的名字是Library,那么他的接口名必须为LibraryMBean

下面创建一个Standard MBean,然后运行它。
MBean 接口:HelloWorldMBean
MBean 实现类:HelloWorld
Agent:HelloAgent


public interface HelloWorldMBean {
    public void setGreeting( String greeting );
    public String getGreeting();
    继续阅读其余的  4405 字
irini   2007-01-27 20:29:43 阅读:284  评论:0  引用:0
Copyright@2006 powered by YuLog