01: /* JFox, the OpenSource J2EE Application Server
02: *
03: * Copyright (C) 2002 huihoo.com
04: * Distributable under GNU LGPL license
05: * See the GNU Lesser General Public License for more details.
06: */
07:
08: package org.huihoo.jfox.jmx.adaptor.http;
09:
10: import java.io.File;
11:
12: import javax.management.MBeanServer;
13: import javax.management.MBeanServerFactory;
14: import javax.management.ObjectName;
15:
16: import org.huihoo.jfox.jmx.adaptor.http.HtmlAdaptorServer;
17:
18: /**
19: *
20: * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
21: */
22:
23: public class HtmlAdaptorAgent {
24:
25: public static void main(String[] args) throws Exception {
26: MBeanServer server = MBeanServerFactory.createMBeanServer();
27: ObjectName haName = new ObjectName(
28: "Adaptor:type=HtmlAdaptor,port=8088");
29: HtmlAdaptorServer ha = new HtmlAdaptorServer();
30: server.registerMBean(ha, haName);
31: server.createMBean("example.jmx.standard.SimpleStandard",
32: new ObjectName(":type=standard1"));
33: server.createMBean("example.jmx.standard.SimpleStandard",
34: new ObjectName(":type=standard2"));
35: server.createMBean("example.jmx.standard.SimpleStandard",
36: new ObjectName(":type=standard3"));
37: server.createMBean("example.jmx.dynamic.SimpleDynamic",
38: new ObjectName(":type=dynamic1"));
39: server.createMBean("example.jmx.dynamic.SimpleDynamic",
40: new ObjectName(":type=dynamic2"));
41: server.createMBean("example.jmx.dynamic.SimpleDynamic",
42: new ObjectName(":type=dynamic3"));
43:
44: // mlet test
45: ObjectName mletObjName = new ObjectName(":Service=MLet");
46: server
47: .createMBean("javax.management.loading.MLet",
48: mletObjName);
49: server.invoke(mletObjName, "getMBeansFromURL",
50: new Object[] { new File("./conf/mlet.conf")
51: .getAbsoluteFile().toURL().toString() },
52: new String[] { "java.lang.String" });
53:
54: ha.setPort(8088);
55: ha.start();
56: Thread.sleep(1000L);
57: System.out.println("Now,you can connect http://" + ha.getHost()
58: + ":" + ha.getPort());
59:
60: }
61: }
|