author | dfuchs |
Thu, 04 Sep 2008 14:46:36 +0200 | |
changeset 1156 | bbc2d15aaf7a |
parent 2 | 90ce3da70b43 |
child 1225 | 6ef6227d36eb |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright 1999-2006 Sun Microsystems, Inc. All Rights Reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package javax.management; |
|
27 |
||
1156
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
28 |
import com.sun.jmx.defaults.JmxProperties; |
2 | 29 |
import com.sun.jmx.defaults.ServiceName; |
1156
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
30 |
import com.sun.jmx.mbeanserver.Util; |
2 | 31 |
|
32 |
/** |
|
33 |
* Represents the MBean server from the management point of view. |
|
34 |
* The MBeanServerDelegate MBean emits the MBeanServerNotifications when |
|
35 |
* an MBean is registered/unregistered in the MBean server. |
|
36 |
* |
|
37 |
* @since 1.5 |
|
38 |
*/ |
|
39 |
public class MBeanServerDelegate implements MBeanServerDelegateMBean, |
|
40 |
NotificationEmitter { |
|
41 |
||
42 |
/** The MBean server agent identification.*/ |
|
43 |
private String mbeanServerId ; |
|
1156
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
44 |
private String mbeanServerName; |
2 | 45 |
|
46 |
/** The NotificationBroadcasterSupport object that sends the |
|
47 |
notifications */ |
|
48 |
private final NotificationBroadcasterSupport broadcaster; |
|
49 |
||
50 |
private static long oldStamp = 0; |
|
51 |
private final long stamp; |
|
52 |
private long sequenceNumber = 1; |
|
53 |
||
54 |
private static final MBeanNotificationInfo[] notifsInfo; |
|
55 |
||
56 |
static { |
|
57 |
final String[] types = { |
|
58 |
MBeanServerNotification.UNREGISTRATION_NOTIFICATION, |
|
59 |
MBeanServerNotification.REGISTRATION_NOTIFICATION |
|
60 |
}; |
|
61 |
notifsInfo = new MBeanNotificationInfo[1]; |
|
62 |
notifsInfo[0] = |
|
63 |
new MBeanNotificationInfo(types, |
|
64 |
"javax.management.MBeanServerNotification", |
|
65 |
"Notifications sent by the MBeanServerDelegate MBean"); |
|
66 |
} |
|
67 |
||
68 |
/** |
|
69 |
* Create a MBeanServerDelegate object. |
|
70 |
*/ |
|
71 |
public MBeanServerDelegate () { |
|
72 |
stamp = getStamp(); |
|
73 |
broadcaster = new NotificationBroadcasterSupport() ; |
|
1156
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
74 |
mbeanServerName=null; |
2 | 75 |
} |
76 |
||
77 |
||
78 |
/** |
|
79 |
* Returns the MBean server agent identity. |
|
80 |
* |
|
81 |
* @return the identity. |
|
82 |
*/ |
|
83 |
public synchronized String getMBeanServerId() { |
|
84 |
if (mbeanServerId == null) { |
|
85 |
String localHost; |
|
86 |
try { |
|
87 |
localHost = java.net.InetAddress.getLocalHost().getHostName(); |
|
88 |
} catch (java.net.UnknownHostException e) { |
|
1156
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
89 |
JmxProperties.MISC_LOGGER.finest("Can't get local host name, " + |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
90 |
"using \"localhost\" instead. Cause is: "+e); |
2 | 91 |
localHost = "localhost"; |
92 |
} |
|
1156
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
93 |
mbeanServerId = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
94 |
Util.insertMBeanServerName(localHost + "_" + stamp, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
95 |
mbeanServerName); |
2 | 96 |
} |
97 |
return mbeanServerId; |
|
98 |
} |
|
99 |
||
100 |
/** |
|
1156
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
101 |
* The name of the MBeanServer. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
102 |
* @return The name of the MBeanServer, or {@value |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
103 |
* javax.management.MBeanServerFactory#DEFAULT_MBEANSERVER_NAME} if no |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
104 |
* name was specified. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
105 |
* |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
106 |
* @since 1.7 |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
107 |
* @see #setMBeanServerName |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
108 |
*/ |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
109 |
public synchronized String getMBeanServerName() { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
110 |
if (Util.isMBeanServerNameUndefined(mbeanServerName)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
111 |
return MBeanServerFactory.DEFAULT_MBEANSERVER_NAME; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
112 |
return mbeanServerName; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
113 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
114 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
115 |
/** |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
116 |
* Sets the name of the MBeanServer. The name will be embedded into the |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
117 |
* {@link #getMBeanServerId MBeanServerId} using the following format:<br> |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
118 |
* {@code mbeanServerId: <mbeanServerId>;mbeanServerName=<mbeanServerName>} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
119 |
* <p>The characters {@code ':'} (colon), {@code ';'} (semicolon ), |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
120 |
* {@code '*'} (star) and {@code '?'} (question mark) are not legal in an |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
121 |
* MBean Server name.</p> |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
122 |
* <p>For instance, if the {@code mbeanServerName} provided is |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
123 |
* {@code "com.mycompany.myapp.server1"}, and the original |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
124 |
* {@code MBeanServerId} was {@code "myhost_1213353064145"}, |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
125 |
* then {@code mbeanServerName} will be |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
126 |
* embedded in the {@code MBeanServerId} - and the new value of the |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
127 |
* {@code MBeanServerId} will be: |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
128 |
* </p> |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
129 |
* <pre> |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
130 |
* "myhost_1213353064145;mbeanServerName=com.mycompany.myapp.server1" |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
131 |
* </pre> |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
132 |
* <p>Note: The {@code mbeanServerName} is usually set by the |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
133 |
* {@code MBeanServerFactory}. It is set only once, before the |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
134 |
* MBean Server is returned by the factory. Once the MBean Server name is |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
135 |
* set, it is not possible to change it. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
136 |
* </p> |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
137 |
* @param mbeanServerName The MBeanServer name. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
138 |
* @throws IllegalArgumentException if the MBeanServerName is already set |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
139 |
* to a different value, or if the provided name contains |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
140 |
* illegal characters, or if the provided name is {@code ""} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
141 |
* (the empty string) or "-" (dash). |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
142 |
* @throws UnsupportedOperationException if this object is of a legacy |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
143 |
* subclass of MBeanServerDelegate which overrides {@link |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
144 |
* #getMBeanServerId()} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
145 |
* in a way that doesn't support setting an MBeanServer name. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
146 |
* @see MBeanServerFactory#getMBeanServerName |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
147 |
* @since 1.7 |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
148 |
*/ |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
149 |
public synchronized void setMBeanServerName(String mbeanServerName) { |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
150 |
// Sets the name on the delegate. For complex backward |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
151 |
// compatibility reasons it is not possible to give the |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
152 |
// name to the MBeanServerDelegate constructor. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
153 |
// |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
154 |
// The method setMBeanServerName() will call getMBeanServerId() |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
155 |
// to check that the name is accurately set in the MBeanServerId. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
156 |
// If not (which could happen if a custom MBeanServerDelegate |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
157 |
// implementation overrides getMBeanServerId() and was not updated |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
158 |
// with respect to JMX 2.0 spec), this method will throw an |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
159 |
// IllegalStateException... |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
160 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
161 |
// will fail if mbeanServerName is illegal |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
162 |
final String name = Util.checkServerName(mbeanServerName); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
163 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
164 |
// can only set mbeanServerDelegate once. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
165 |
if (this.mbeanServerName != null && !this.mbeanServerName.equals(name)) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
166 |
throw new IllegalArgumentException( |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
167 |
"MBeanServerName already set to a different value"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
168 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
169 |
this.mbeanServerName = name; |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
170 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
171 |
// will fail if mbeanServerId already has a different mbeanServerName |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
172 |
mbeanServerId = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
173 |
Util.insertMBeanServerName(getMBeanServerId(),name); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
174 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
175 |
// check that we don't have a subclass which overrides |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
176 |
// getMBeanServerId() without setting mbeanServerName |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
177 |
if (!name.equals( |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
178 |
Util.extractMBeanServerName(getMBeanServerId()))) |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
179 |
throw new UnsupportedOperationException( |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
180 |
"Can't set MBeanServerName in MBeanServerId - " + |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
181 |
"unsupported by "+this.getClass().getName()+"?"); |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
182 |
// OK: at this point we know that we have correctly set mbeanServerName. |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
183 |
} |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
184 |
|
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
185 |
/** |
2 | 186 |
* Returns the full name of the JMX specification implemented |
187 |
* by this product. |
|
188 |
* |
|
189 |
* @return the specification name. |
|
190 |
*/ |
|
191 |
public String getSpecificationName() { |
|
192 |
return ServiceName.JMX_SPEC_NAME; |
|
193 |
} |
|
194 |
||
195 |
/** |
|
196 |
* Returns the version of the JMX specification implemented |
|
197 |
* by this product. |
|
198 |
* |
|
199 |
* @return the specification version. |
|
200 |
*/ |
|
201 |
public String getSpecificationVersion() { |
|
202 |
return ServiceName.JMX_SPEC_VERSION; |
|
203 |
} |
|
204 |
||
205 |
/** |
|
206 |
* Returns the vendor of the JMX specification implemented |
|
207 |
* by this product. |
|
208 |
* |
|
209 |
* @return the specification vendor. |
|
210 |
*/ |
|
211 |
public String getSpecificationVendor() { |
|
212 |
return ServiceName.JMX_SPEC_VENDOR; |
|
213 |
} |
|
214 |
||
215 |
/** |
|
216 |
* Returns the JMX implementation name (the name of this product). |
|
217 |
* |
|
218 |
* @return the implementation name. |
|
219 |
*/ |
|
220 |
public String getImplementationName() { |
|
221 |
return ServiceName.JMX_IMPL_NAME; |
|
222 |
} |
|
223 |
||
224 |
/** |
|
225 |
* Returns the JMX implementation version (the version of this product). |
|
226 |
* |
|
227 |
* @return the implementation version. |
|
228 |
*/ |
|
229 |
public String getImplementationVersion() { |
|
230 |
try { |
|
231 |
return System.getProperty("java.runtime.version"); |
|
232 |
} catch (SecurityException e) { |
|
233 |
return ""; |
|
234 |
} |
|
235 |
} |
|
236 |
||
237 |
/** |
|
238 |
* Returns the JMX implementation vendor (the vendor of this product). |
|
239 |
* |
|
240 |
* @return the implementation vendor. |
|
241 |
*/ |
|
242 |
public String getImplementationVendor() { |
|
243 |
return ServiceName.JMX_IMPL_VENDOR; |
|
244 |
} |
|
245 |
||
246 |
// From NotificationEmitter extends NotificationBroacaster |
|
247 |
// |
|
248 |
public MBeanNotificationInfo[] getNotificationInfo() { |
|
249 |
final int len = MBeanServerDelegate.notifsInfo.length; |
|
250 |
final MBeanNotificationInfo[] infos = |
|
251 |
new MBeanNotificationInfo[len]; |
|
252 |
System.arraycopy(MBeanServerDelegate.notifsInfo,0,infos,0,len); |
|
253 |
return infos; |
|
254 |
} |
|
255 |
||
256 |
// From NotificationEmitter extends NotificationBroacaster |
|
257 |
// |
|
258 |
public synchronized |
|
259 |
void addNotificationListener(NotificationListener listener, |
|
260 |
NotificationFilter filter, |
|
261 |
Object handback) |
|
262 |
throws IllegalArgumentException { |
|
263 |
broadcaster.addNotificationListener(listener,filter,handback) ; |
|
264 |
} |
|
265 |
||
266 |
// From NotificationEmitter extends NotificationBroacaster |
|
267 |
// |
|
268 |
public synchronized |
|
269 |
void removeNotificationListener(NotificationListener listener, |
|
270 |
NotificationFilter filter, |
|
271 |
Object handback) |
|
272 |
throws ListenerNotFoundException { |
|
273 |
broadcaster.removeNotificationListener(listener,filter,handback) ; |
|
274 |
} |
|
275 |
||
276 |
// From NotificationEmitter extends NotificationBroacaster |
|
277 |
// |
|
278 |
public synchronized |
|
279 |
void removeNotificationListener(NotificationListener listener) |
|
280 |
throws ListenerNotFoundException { |
|
281 |
broadcaster.removeNotificationListener(listener) ; |
|
282 |
} |
|
283 |
||
284 |
/** |
|
285 |
* Enables the MBean server to send a notification. |
|
286 |
* If the passed <var>notification</var> has a sequence number lesser |
|
287 |
* or equal to 0, then replace it with the delegate's own sequence |
|
288 |
* number. |
|
289 |
* @param notification The notification to send. |
|
290 |
* |
|
291 |
*/ |
|
292 |
public void sendNotification(Notification notification) { |
|
293 |
if (notification.getSequenceNumber() < 1) { |
|
294 |
synchronized (this) { |
|
295 |
notification.setSequenceNumber(this.sequenceNumber++); |
|
296 |
} |
|
297 |
} |
|
298 |
broadcaster.sendNotification(notification); |
|
299 |
} |
|
300 |
||
301 |
/** |
|
302 |
* Defines the default ObjectName of the MBeanServerDelegate. |
|
303 |
* |
|
304 |
* @since 1.6 |
|
305 |
*/ |
|
1156
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
306 |
public static final ObjectName DELEGATE_NAME = |
bbc2d15aaf7a
5072476: RFE: support cascaded (federated) MBean Servers
dfuchs
parents:
2
diff
changeset
|
307 |
Util.newObjectName("JMImplementation:type=MBeanServerDelegate"); |
2 | 308 |
|
309 |
/* Return a timestamp that is monotonically increasing even if |
|
310 |
System.currentTimeMillis() isn't (for example, if you call this |
|
311 |
constructor more than once in the same millisecond, or if the |
|
312 |
clock always returns the same value). This means that the ids |
|
313 |
for a given JVM will always be distinact, though there is no |
|
314 |
such guarantee for two different JVMs. */ |
|
315 |
private static synchronized long getStamp() { |
|
316 |
long s = System.currentTimeMillis(); |
|
317 |
if (oldStamp >= s) { |
|
318 |
s = oldStamp + 1; |
|
319 |
} |
|
320 |
oldStamp = s; |
|
321 |
return s; |
|
322 |
} |
|
323 |
} |