01: /* JFox, the OpenSource J2EE Application Server
02: *
03: * Copyright (C) 2002 huihoo.org
04: * Distributable under GNU LGPL license
05: * See the GNU Lesser General Public License for more details.
06: */
07:
08: package example.jmx.adaptor;
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.org">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: /*
32: server.createMBean("example.jmx.standard.SimpleStandard",new ObjectName(":type=standard1"));
33: server.createMBean("example.jmx.standard.SimpleStandard",new ObjectName(":type=standard2"));
34: server.createMBean("example.jmx.standard.SimpleStandard",new ObjectName(":type=standard3"));
35: server.createMBean("example.jmx.dynamic.SimpleDynamic",new ObjectName(":type=dynamic1"));
36: server.createMBean("example.jmx.dynamic.SimpleDynamic",new ObjectName(":type=dynamic2"));
37: server.createMBean("example.jmx.dynamic.SimpleDynamic",new ObjectName(":type=dynamic3"));
38:
39: // mlet test
40: ObjectName mletObjName = new ObjectName(":Service=MLet");
41: server.createMBean("javax.management.loading.MLet",mletObjName);
42: server.invoke(mletObjName,
43: "getMBeansFromURL",
44: new Object[]{new File("./conf/mlet.conf").getAbsoluteFile().toURL().toString()},
45: new String[]{"java.lang.String"}
46: );
47:
48: */
49: ha.setPort(8082);
50: ha.start();
51: Thread.sleep(1000L);
52: System.out.println("Now,you can connect http://" + ha.getHost()
53: + ":" + ha.getPort());
54: }
55: }
|