KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jmx > MBeanServerDelegateImpl


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  * Free SoftwareFoundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.jmx;
30
31 import javax.management.MBeanNotificationInfo JavaDoc;
32 import javax.management.MBeanServerDelegate JavaDoc;
33 import javax.management.MBeanServerNotification JavaDoc;
34 import javax.management.NotificationFilter JavaDoc;
35 import javax.management.NotificationListener JavaDoc;
36 import javax.management.ObjectName JavaDoc;
37
38 /**
39  * The main interface for retrieving and managing JMX objects.
40  */

41 public class MBeanServerDelegateImpl extends MBeanServerDelegate JavaDoc {
42   private static final ObjectName JavaDoc DELEGATE_NAME;
43   
44   private String JavaDoc _agentId;
45   private long _seq;
46
47   MBeanServerDelegateImpl(String JavaDoc agentId)
48   {
49     _agentId = agentId;
50   }
51
52   /**
53    * Return the MBean server agent id.
54    */

55   public String JavaDoc getMBeanServerId()
56   {
57     return _agentId;
58   }
59
60   /**
61    * Returns the implementation vendor.
62    */

63   public String JavaDoc getImplementationName()
64   {
65     return "Resin-JMX";
66   }
67
68   /**
69    * Returns the implementation vendor.
70    */

71   public String JavaDoc getImplementationVendor()
72   {
73     return "Caucho Technology";
74   }
75
76   /**
77    * Returns the implementation version.
78    */

79   public String JavaDoc getImplementationVersion()
80   {
81     return "Resin-" + com.caucho.Version.VERSION;
82   }
83
84   /**
85    * Sends the register notification.
86    */

87   public void sendRegisterNotification(ObjectName JavaDoc name)
88   {
89     serverNotification(name, MBeanServerNotification.REGISTRATION_NOTIFICATION);
90   }
91
92   /**
93    * Sends the register notification.
94    */

95   public void sendUnregisterNotification(ObjectName JavaDoc name)
96   {
97     serverNotification(name, MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
98   }
99
100   public void addNotificationListener(NotificationListener JavaDoc listener,
101                       NotificationFilter JavaDoc filter,
102                       Object JavaDoc handback)
103   {
104     super.addNotificationListener(listener, filter, handback);
105   }
106
107   /**
108    * Sends the notification
109    */

110   private void serverNotification(ObjectName JavaDoc name, String JavaDoc type)
111   {
112     MBeanServerNotification JavaDoc notif;
113
114     notif = new MBeanServerNotification JavaDoc(type, DELEGATE_NAME, _seq++, name);
115
116     sendNotification(notif);
117   }
118
119   public MBeanNotificationInfo JavaDoc []getNotificationInfo()
120   {
121     MBeanNotificationInfo JavaDoc []notifs = super.getNotificationInfo();
122
123     return notifs;
124   }
125
126   static {
127     ObjectName JavaDoc name = null;
128     
129     try {
130       name = new ObjectName JavaDoc("JMImplementation:type=MBeanServerDelegate");
131     } catch (Throwable JavaDoc e) {
132       e.printStackTrace();
133     }
134     
135     DELEGATE_NAME = name;
136   }
137 }
138
Popular Tags