本文整理汇总了Java中com.sun.jdmk.comm.HtmlAdaptorServer类的典型用法代码示例。如果您正苦于以下问题:Java HtmlAdaptorServer类的具体用法?Java HtmlAdaptorServer怎么用?Java HtmlAdaptorServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HtmlAdaptorServer类属于com.sun.jdmk.comm包,在下文中一共展示了HtmlAdaptorServer类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: start
import com.sun.jdmk.comm.HtmlAdaptorServer; //导入依赖的package包/类
public
void start() {
MBeanServer server = MBeanServerFactory.createMBeanServer();
HtmlAdaptorServer html = new HtmlAdaptorServer();
try {
log.info("Registering HtmlAdaptorServer instance.");
server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
log.info("Registering HierarchyDynamicMBean instance.");
HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
} catch(Exception e) {
log.error("Problem while regitering MBeans instances.", e);
return;
}
html.start();
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:20,代码来源:Agent.java
示例2: main
import com.sun.jdmk.comm.HtmlAdaptorServer; //导入依赖的package包/类
public static void main(String[] args) {
// CREATE the MBeanServer
//
System.out.println("\n\tCREATE the MBeanServer.");
MBeanServer server = MBeanServerFactory.createMBeanServer();
// CREATE and START a new HTML adaptor
//
System.out.println("\n\tCREATE, REGISTER and START a new HTML adaptor:");
HtmlAdaptorServer html = new HtmlAdaptorServer();
ObjectName html_name = null;
try {
html_name = new ObjectName("Adaptor:name=html,port=8082");
System.out.println("\tOBJECT NAME = " + html_name);
server.registerMBean(html, html_name);
} catch(Exception e) {
System.out.println("\t!!! Could not create the HTML adaptor !!!");
e.printStackTrace();
return;
}
html.start();
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:24,代码来源:BaseAgent.java
示例3: start
import com.sun.jdmk.comm.HtmlAdaptorServer; //导入依赖的package包/类
public void start() {
final MBeanServer server = MBeanServerFactory.createMBeanServer();
final HtmlAdaptorServer html = new HtmlAdaptorServer();
try {
log.info("Registering HtmlAdaptorServer instance.");
server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
log.info("Registering HierarchyDynamicMBean instance.");
final HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
} catch (Exception e) {
log.error("Problem while regitering MBeans instances.", e);
return;
}
html.start();
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:19,代码来源:Agent.java
示例4: main
import com.sun.jdmk.comm.HtmlAdaptorServer; //导入依赖的package包/类
public static void main(String[] args) throws MalformedObjectNameException,
NotCompliantMBeanException, InstanceAlreadyExistsException,
MBeanRegistrationException, IOException {
// 下面这种方式不能再JConsole中使用
// MBeanServer server = MBeanServerFactory.createMBeanServer();
// 首先建立一个MBeanServer,MBeanServer用来管理我们的MBean,通常是通过MBeanServer来获取我们MBean的信息,间接
// 调用MBean的方法,然后生产我们的资源的一个对象。
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
String domainName = "MyMBean";
//为MBean(下面的new Hello())创建ObjectName实例
ObjectName helloName = new ObjectName(domainName+":name=HelloWorld");
// 将new Hello()这个对象注册到MBeanServer上去
mbs.registerMBean(new Hello(),helloName);
// Distributed Layer, 提供了一个HtmlAdaptor。支持Http访问协议,并且有一个不错的HTML界面,这里的Hello就是用这个作为远端管理的界面
// 事实上HtmlAdaptor是一个简单的HttpServer,它将Http请求转换为JMX Agent的请求
ObjectName adapterName = new ObjectName(domainName+":name=htmladapter,port=8082");
HtmlAdaptorServer adapter = new HtmlAdaptorServer();
adapter.start();
mbs.registerMBean(adapter,adapterName);
int rmiPort = 1099;
Registry registry = LocateRegistry.createRegistry(rmiPort);
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:"+rmiPort+"/"+domainName);
JMXConnectorServer jmxConnector = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
jmxConnector.start();
}
开发者ID:breakEval13,项目名称:rocketmq-flink-plugin,代码行数:31,代码来源:HelloAgent.java
示例5: stop
import com.sun.jdmk.comm.HtmlAdaptorServer; //导入依赖的package包/类
/**
* 直接调用{@link HtmlAdaptorServer#stop HtmlAdaptorServer.stop}会提示空指针,需要用反射停止服务
*
* @param communicatorServer communicatorServer
*/
public static void stop(CommunicatorServer communicatorServer) {
try {
Field stopRequestedField = CommunicatorServer.class.getDeclaredField("stopRequested");
stopRequestedField.setAccessible(true);
stopRequestedField.set(communicatorServer, true);
Field sockListenField = HtmlAdaptorServer.class.getDeclaredField("sockListen");
sockListenField.setAccessible(true);
ServerSocket sockListen = (ServerSocket) sockListenField.get(communicatorServer);
sockListen.close();
} catch (Exception e) {
throw new ConnectionPoolException(e);
}
}
开发者ID:xionghuiCoder,项目名称:clearpool,代码行数:20,代码来源:HtmlAdaptorHook.java
注:本文中的com.sun.jdmk.comm.HtmlAdaptorServer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论