JMX&MX4JshiplJMXMBeanServerFactory.newMBeanServer();Manage。描述。在DynamicMBean中,最终要由将所有得其他Info创建成MBeanInfo。MBeanFeatureInfo:是所有MBean元数据得超类,含有name和description,所以其他得元数据类都有name和description。MBeanParameterInfo:描述了构造函数和方式中得参数名、描述,还增加了参数得类型。这三个就足够定义方式得参数了。MBeanConstructorInfo:描述了MBean类得构造函数。可以通过constructor或者name、description、MBeanParameterInfo来进行构造(具体见API)。该类只有一个方式:g。etSignature(),返回MBeanParameterInfo。MBeanAttributeInfo:描述暴露出得属性信息。可以通过传入相关属性信息来构造,也可以通过传入Methodforgetterimportjava.util.Iterator;importjavax.management.Attribute;importjavax.management.AttributeList;importjavax.management.DynamicMBean;importjavax.management.MBeanAttributeInfo;importjavax.management.MBeanConstructorInfo;importjavax.manage。ment.MBeanException;importjavax.management.MBeanInfo;importjavax.management.MBeanNotificationInfo;importjavax.management.MBeanOperationInfo;importjavax.management.MBeanParameterInfo;importjavax.management.ReflectionException;/*authorSunnyPeng*authorchangebyChen.Gang,addafeatureford。ynamicaddoperation*authoreditfromMichael.Shi**version1.019.*/publicclassHelloDynamicimplementsDynamicMBean/这是我们得属性名称privateStringname;privateMBeanInfomBeanInfo=null;privateStringclassName;privateStringdescription;privateMBeanAttributeInfoattributes;privateMBeanConstructo。rInfoconstructors;privateMBeanOperationInfooperations;MBeanNotificationInfomBeanNotificationInfoArray;publicHelloDynamic()init();buildDynamicMBean();privatevoidinit()className=this.getClass().getName();description=SimpleimplementationofadynamicMBean.;attributes=newMBeanAttributeIn。fo1;constructors=newMBeanConstructorInfo1;operations=newMBeanOperationInfo1;mBeanNotificationInfoArray=newMBeanNotificationInfo0;privatevoidbuildDynamicMBean()/设定构造函数Constructorthisconstructors=this.getClass().getConstructors();constructors0=newMBeanConstructorInfo(HelloDynamic():。ConstructsaHelloDynamicobject,thisconstructors0);/设定一个属性attributes0=newMBeanAttributeInfo(Name,java.lang.String,Name:namestring.,true,true,false);/operatemethod我们得操作方式是printMBeanParameterInfoparams=null;/无参数operations0=newMBeanOperationInfo(print,print():printthename,param。s,void,MBeanOperationInfo.INFO);mBeanInfo=newMBeanInfo(className,description,attributes,constructors,operations,mBeanNotificationInfoArray);System.out.println(First:+mBeanInfo.getClassName()+:+mBeanInfo.getDescription();/动态增加一个print1方式privatevoiddynamicAddOperation()init();operatio。ns=newMBeanOperationInfo2;/设定数组为两个buildDynamicMBean();operations1=newMBeanOperationInfo(print1,print1():printthename,null,void,MBeanOperationInfo.INFO);mBeanInfo=newMBeanInfo(className,description,attributes,constructors,operations,mBeanNotificationInfoArray);System.out.println(mB。eanInfo.getClassName()+:+mBeanInfo.getDescription();publicObjectgetAttribute(Stringattribute_name)if(attribute_name!=null)returnnull;if(attribute_name.equals(Name)returnname;returnnull;publicvoidsetAttribute(Attributeattribute)if(attribute=null)return;StringName=attribute.getN。ame();Objectvalue=attribute.getValue();tryif(Name.equals(Name)/ifnullvalue,tryandseeifthesetterreturnsany/exceptionif(value=null)name=null;/ifnonnullvalue,makes...