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 example.jmx.standard;
09:
10: import javax.management.MBeanServer;
11: import javax.management.MBeanServerFactory;
12: import javax.management.ObjectName;
13: import javax.management.MBeanServerInvocationHandler;
14: import javax.management.StandardMBean;
15: import javax.management.NotCompliantMBeanException;
16:
17: /**
18: *
19: * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
20: */
21:
22: public class Test12 implements TestMBean {
23: private String state = "Running";
24:
25: public String getState() {
26: return state;
27: }
28:
29: public void reset() {
30: System.out.println("Reset");
31: }
32:
33: public static void main(String[] args) throws Exception {
34: MBeanServer server = MBeanServerFactory.createMBeanServer();
35: Test12 test = new Test12();
36: ObjectName on = new ObjectName(":class=Test12");
37: StandardMBean sm = new StandardMBean(test, TestMBean.class);
38: server.registerMBean(sm, on);
39:
40: // Test1_2 sm = new Test1_2(TestMBean.class);
41: // server.registerMBean(sm,on);
42:
43: System.out.println(sm.getAttribute("State"));
44: sm.invoke("reset", null, null);
45: System.out.println(server.getAttribute(on, "State"));
46: server.invoke(on, "reset", null, null);
47: }
48: }
|