package wrox.ch12.jmx;
import java.util.Iterator;
import java.util.Set;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.Query;
import javax.management.QueryExp;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
public class RemoteClient {
MBeanServerConnection connection = null;
public RemoteClient() throws Exception {
JMXServiceURL url = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://localhost:9999/server");
JMXConnector connector = JMXConnectorFactory.connect(url);
connection = connector.getMBeanServerConnection();
}
void deploy() throws Exception {
connection.createMBean("wrox.ch12.jmx.Worker",
new ObjectName("wrox.ch12.jmx:type=Worker,number=1"));
connection.createMBean("wrox.ch12.jmx.Worker",
new ObjectName("wrox.ch12.jmx:type=Worker,number=2"));
connection.createMBean("wrox.ch12.jmx.Worker",
new ObjectName("wrox.ch12.jmx:type=Worker,number=3"));
}
void lookup() throws Exception {
ObjectName on = new ObjectName("wrox.ch12.jmx:*");
Set set = connection.queryNames(on, null);
for (Iterator iter = set.iterator(); iter.hasNext();) {
ObjectName bean = (ObjectName) iter.next();
System.out.println("deployed..=" + bean.toString());
}
}
void checkRunning() throws Exception {
ObjectName on = new ObjectName("wrox.ch12.jmx:*");
QueryExp exp = Query.eq(Query.attr("Running"), Query.value(true));
Set set = connection.queryNames(on, exp);
for (Iterator iter = set.iterator(); iter.hasNext();) {
ObjectName bean = (ObjectName) iter.next();
System.out.println("running.. MBean =" + bean.toString());
}
}
void remove() throws Exception {
ObjectName on = new ObjectName("wrox.ch12.jmx:*");
Set set = connection.queryNames(on, null);
for (Iterator iter = set.iterator(); iter.hasNext();) {
ObjectName bean = (ObjectName) iter.next();
System.out.println("removing..=" + bean.toString());
connection.unregisterMBean(bean);
}
}
public void addMonitor( ) throws Exception {
connection.createMBean("javax.management.monitor.StringMonitor", new ObjectName("wrox.ch12.jmx:name=WorkMonitor"));
}
public static void main(String[] args) throws Exception {
RemoteClient rc = new RemoteClient();
rc.remove();
rc.deploy();
rc.lookup();
rc.checkRunning();
rc.addMonitor();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本书全面而深入地探讨了Java技术的高级特性,包括许多与Java语言相关的开源技术,如Ant、Jmeter、Hibernate等。全书共14章,其中前3章介绍了高效Java开发人员所需的特定思维方式,包括关键的Java语言特性和库、用于开发Java解决方案的各种工具和技术,以及Java开发模式。后面部分详细探讨了开发Java解决方案的各种工具和技术,包括JFC、持久性、以页面为中心的开发技术、以组件为中心的开发技术、EJB3、组件通信、面向服务的集成、Java安全性、打包和部署等。 java高级编程jdk6源代码.总共14章节.
资源推荐
资源详情
资源评论
收起资源包目录
java高级编程jdk6源代码.rar (33个子文件)
wrox-ch12
bin
jndi.properties 174B
wrox
ch12
jmx
RemoteClient.class 4KB
Worker.class 1KB
RemoteAgent.class 1KB
Agent.class 1KB
WorkerMBean.class 274B
jms
PurchaseOrder.class 421B
JMSAgent.class 1KB
JMSWorker.class 3KB
JMSWorkerMBean.class 311B
PurchaseOrderAggregate.class 949B
RequestReply.class 3KB
Split.class 2KB
MessageClient.class 2KB
jbi
Simple.class 389B
jbossmq-destinations-service.xml 5KB
src
jndi.properties 174B
wrox
ch12
jmx
Agent.java 577B
RemoteAgent.java 701B
WorkerMBean.java 284B
RemoteClient.java 2KB
Worker.java 723B
jms
JMSWorkerMBean.java 269B
RequestReply.java 2KB
JMSAgent.java 645B
MessageClient.java 1KB
PurchaseOrderAggregate.java 471B
JMSWorker.java 2KB
PurchaseOrder.java 179B
jbossmq-destinations-service.xml 5KB
.project 385B
.classpath 294B
lib
jbossall-client.jar 3.14MB
共 33 条
- 1
资源评论
Oliver_Wu
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功