[BEAN] 配置
<!-- JMX 对应的接口服务-->
<bean id="emailInterfaceServer" class="com.star.sms.business.collection.jmx.CollmgmtEmailJmx" />
<bean id="EmailServerMbeanExporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="starsms3:service=EmailManagerService"
value-ref="emailInterfaceServer" /> <!--页面显示的服务名称-->
</map>
</property>
<property name="assembler" ref="assemblerMBean" />
</bean>
<!-- 使用注解元数据创建管理接口 只要用于JMX页面中使用注解实现相关信息显示-->
<bean id="assemblerMBean"
class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
<property name="attributeSource" ref="jmxAttributeSource" />
</bean>
<bean id="jmxAttributeSource"
class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" />
[使用注解实现JMX页面显示]
package com.star.sms.business.collection.jmx;
// 省略
/**
* 客户帐单邮件提醒管理Bean
*
* @author liuyong 2014-01-22
* @version 5.4.4.9
*
*/
@ManagedResource(description = "Bill Remind Email Manager") //描述用于页面显示
public class CollmgmtEmailJmx {
@ManagedOperation(description = "Send remind Email for customer ,The email contains the billing information")
public void sendBillEmails() {
//这是一个无参数的方法
}
@ManagedOperation(description = "[ Testing ]: send remind Email to one cusomer by customer code")
//描述用于页面显示
@ManagedOperationParameters( {
@ManagedOperationParameter(name = "customerCode", description = "Customer Code"), //参数名称,及参数描述
@ManagedOperationParameter(name = "targetEmail", description = "Target Email") })
public void sendBillEmailTesting(String customerCode, String targetEmail) {
//这是一个带参数的方法
}
}
}
[JMX效果]
[JMX相关方法信息]