01: package example;
02:
03: import javax.management.ObjectName;
04: import javax.management.MBeanServer;
05: import javax.management.MBeanRegistration;
06:
07: /**
08: * Implements a resource which is a plain-old bean, which exposes
09: * the <code>getData()</code> method as a JMX-managed attribute.
10: */
11: public class Test implements TestMBean, MBeanRegistration {
12: /**
13: * The bean's name.
14: */
15: private ObjectName _name;
16:
17: /**
18: * Gets the name.
19: */
20: public ObjectName getObjectName() {
21: return _name;
22: }
23:
24: /**
25: * Called before the registration.
26: *
27: * @param server the mbean server to be registered
28: * @param name the client's name to be registered
29: *
30: * @return the name the object wans the be registered as
31: */
32: public ObjectName preRegister(MBeanServer server, ObjectName name)
33: throws Exception {
34: _name = name;
35:
36: return name;
37: }
38:
39: /**
40: * Called after the registration.
41: *
42: * @param registrationDone true if the registration was successful.
43: */
44: public void postRegister(Boolean registrationDone) {
45: }
46:
47: /**
48: * Called before deregistration.
49: */
50: public void preDeregister() throws Exception {
51: }
52:
53: /**
54: * Called after the deregistration.
55: */
56: public void postDeregister() {
57: }
58:
59: /**
60: * Returns a printable version of the resource.
61: */
62: public String toString() {
63: return "Test[" + _name + "]";
64: }
65: }
|