KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > Test


1 package example;
2
3 import javax.management.ObjectName JavaDoc;
4 import javax.management.MBeanServer JavaDoc;
5 import javax.management.MBeanRegistration JavaDoc;
6
7 /**
8  * Implements a resource which is a plain-old bean, which exposes
9  * the <code>getData()</code> method as a JMX-managed attribute.
10  */

11 public class Test implements TestMBean, MBeanRegistration JavaDoc {
12   /**
13    * The bean's name.
14    */

15   private ObjectName JavaDoc _name;
16
17   /**
18    * Gets the name.
19    */

20   public ObjectName JavaDoc getObjectName()
21   {
22     return _name;
23   }
24   
25   /**
26    * Called before the registration.
27    *
28    * @param server the mbean server to be registered
29    * @param name the client's name to be registered
30    *
31    * @return the name the object wans the be registered as
32    */

33   public ObjectName JavaDoc preRegister(MBeanServer JavaDoc server, ObjectName JavaDoc name)
34     throws Exception JavaDoc
35   {
36     _name = name;
37
38     return name;
39   }
40   
41   /**
42    * Called after the registration.
43    *
44    * @param registrationDone true if the registration was successful.
45    */

46   public void postRegister(Boolean JavaDoc registrationDone)
47   {
48   }
49   
50   /**
51    * Called before deregistration.
52    */

53   public void preDeregister()
54     throws Exception JavaDoc
55   {
56   }
57   
58   /**
59    * Called after the deregistration.
60    */

61   public void postDeregister()
62   {
63   }
64
65   /**
66    * Returns a printable version of the resource.
67    */

68   public String JavaDoc toString()
69   {
70     return "Test[" + _name + "]";
71   }
72 }
73
Popular Tags