author | dfuchs |
Tue, 29 Jul 2008 19:21:59 +0200 | |
changeset 900 | 55c9c5a88bde |
parent 715 | f16baef3a20e |
child 1510 | e747d3193ef2 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
715 | 2 |
* Portions Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. |
2 | 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 |
* @author IBM Corp. |
|
27 |
* |
|
28 |
* Copyright IBM Corp. 1999-2000. All rights reserved. |
|
29 |
*/ |
|
30 |
||
31 |
package javax.management.modelmbean; |
|
32 |
||
33 |
import static com.sun.jmx.defaults.JmxProperties.MODELMBEAN_LOGGER; |
|
34 |
import static com.sun.jmx.mbeanserver.Util.cast; |
|
35 |
import com.sun.jmx.mbeanserver.GetPropertyAction; |
|
900
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
36 |
import com.sun.jmx.mbeanserver.Util; |
2 | 37 |
|
38 |
import java.io.IOException; |
|
39 |
import java.io.ObjectInputStream; |
|
40 |
import java.io.ObjectOutputStream; |
|
41 |
import java.io.ObjectStreamField; |
|
42 |
||
43 |
import java.lang.reflect.Constructor; |
|
44 |
||
45 |
import java.security.AccessController; |
|
46 |
import java.util.HashMap; |
|
47 |
import java.util.Iterator; |
|
48 |
import java.util.Map; |
|
49 |
import java.util.Set; |
|
50 |
import java.util.SortedMap; |
|
51 |
import java.util.StringTokenizer; |
|
52 |
import java.util.TreeMap; |
|
53 |
import java.util.logging.Level; |
|
54 |
||
55 |
import javax.management.Descriptor; |
|
56 |
import javax.management.ImmutableDescriptor; |
|
57 |
import javax.management.MBeanException; |
|
58 |
import javax.management.RuntimeOperationsException; |
|
59 |
||
60 |
import sun.reflect.misc.ReflectUtil; |
|
61 |
||
62 |
/** |
|
63 |
* This class represents the metadata set for a ModelMBean element. A |
|
64 |
* descriptor is part of the ModelMBeanInfo, |
|
65 |
* ModelMBeanNotificationInfo, ModelMBeanAttributeInfo, |
|
66 |
* ModelMBeanConstructorInfo, and ModelMBeanParameterInfo. |
|
67 |
* <P> |
|
68 |
* A descriptor consists of a collection of fields. Each field is in |
|
69 |
* fieldname=fieldvalue format. Field names are not case sensitive, |
|
70 |
* case will be preserved on field values. |
|
71 |
* <P> |
|
72 |
* All field names and values are not predefined. New fields can be |
|
73 |
* defined and added by any program. Some fields have been predefined |
|
74 |
* for consistency of implementation and support by the |
|
75 |
* ModelMBeanInfo, ModelMBeanAttributeInfo, ModelMBeanConstructorInfo, |
|
76 |
* ModelMBeanNotificationInfo, ModelMBeanOperationInfo and ModelMBean |
|
77 |
* classes. |
|
78 |
* |
|
79 |
* <p>The <b>serialVersionUID</b> of this class is <code>-6292969195866300415L</code>. |
|
80 |
* |
|
81 |
* @since 1.5 |
|
82 |
*/ |
|
83 |
@SuppressWarnings("serial") // serialVersionUID not constant |
|
84 |
public class DescriptorSupport |
|
85 |
implements javax.management.Descriptor |
|
86 |
{ |
|
87 |
||
88 |
// Serialization compatibility stuff: |
|
89 |
// Two serial forms are supported in this class. The selected form depends |
|
90 |
// on system property "jmx.serial.form": |
|
91 |
// - "1.0" for JMX 1.0 |
|
92 |
// - any other value for JMX 1.1 and higher |
|
93 |
// |
|
94 |
// Serial version for old serial form |
|
95 |
private static final long oldSerialVersionUID = 8071560848919417985L; |
|
96 |
// |
|
97 |
// Serial version for new serial form |
|
98 |
private static final long newSerialVersionUID = -6292969195866300415L; |
|
99 |
// |
|
100 |
// Serializable fields in old serial form |
|
101 |
private static final ObjectStreamField[] oldSerialPersistentFields = |
|
102 |
{ |
|
103 |
new ObjectStreamField("descriptor", HashMap.class), |
|
104 |
new ObjectStreamField("currClass", String.class) |
|
105 |
}; |
|
106 |
// |
|
107 |
// Serializable fields in new serial form |
|
108 |
private static final ObjectStreamField[] newSerialPersistentFields = |
|
109 |
{ |
|
110 |
new ObjectStreamField("descriptor", HashMap.class) |
|
111 |
}; |
|
112 |
// |
|
113 |
// Actual serial version and serial form |
|
114 |
private static final long serialVersionUID; |
|
115 |
/** |
|
116 |
* @serialField descriptor HashMap The collection of fields representing this descriptor |
|
117 |
*/ |
|
118 |
private static final ObjectStreamField[] serialPersistentFields; |
|
119 |
private static final String serialForm; |
|
120 |
static { |
|
121 |
String form = null; |
|
122 |
boolean compat = false; |
|
123 |
try { |
|
124 |
GetPropertyAction act = new GetPropertyAction("jmx.serial.form"); |
|
125 |
form = AccessController.doPrivileged(act); |
|
126 |
compat = "1.0".equals(form); // form may be null |
|
127 |
} catch (Exception e) { |
|
128 |
// OK: No compat with 1.0 |
|
129 |
} |
|
130 |
serialForm = form; |
|
131 |
if (compat) { |
|
132 |
serialPersistentFields = oldSerialPersistentFields; |
|
133 |
serialVersionUID = oldSerialVersionUID; |
|
134 |
} else { |
|
135 |
serialPersistentFields = newSerialPersistentFields; |
|
136 |
serialVersionUID = newSerialVersionUID; |
|
137 |
} |
|
138 |
} |
|
139 |
// |
|
140 |
// END Serialization compatibility stuff |
|
141 |
||
142 |
/* Spec says that field names are case-insensitive, but that case |
|
143 |
is preserved. This means that we need to be able to map from a |
|
144 |
name that may differ in case to the actual name that is used in |
|
145 |
the HashMap. Thus, descriptorMap is a TreeMap with a Comparator |
|
146 |
that ignores case. |
|
147 |
||
148 |
Previous versions of this class had a field called "descriptor" |
|
149 |
of type HashMap where the keys were directly Strings. This is |
|
150 |
hard to reconcile with the required semantics, so we fabricate |
|
151 |
that field virtually during serialization and deserialization |
|
152 |
but keep the real information in descriptorMap. |
|
153 |
*/ |
|
154 |
private transient SortedMap<String, Object> descriptorMap; |
|
155 |
||
156 |
private static final String currClass = "DescriptorSupport"; |
|
157 |
||
158 |
||
159 |
/** |
|
160 |
* Descriptor default constructor. |
|
161 |
* Default initial descriptor size is 20. It will grow as needed.<br> |
|
162 |
* Note that the created empty descriptor is not a valid descriptor |
|
163 |
* (the method {@link #isValid isValid} returns <CODE>false</CODE>) |
|
164 |
*/ |
|
165 |
public DescriptorSupport() { |
|
166 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
167 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
168 |
DescriptorSupport.class.getName(), |
|
169 |
"DescriptorSupport()" , "Constructor"); |
|
170 |
} |
|
171 |
init(null); |
|
172 |
} |
|
173 |
||
174 |
/** |
|
175 |
* Descriptor constructor. Takes as parameter the initial |
|
176 |
* capacity of the Map that stores the descriptor fields. |
|
177 |
* Capacity will grow as needed.<br> Note that the created empty |
|
178 |
* descriptor is not a valid descriptor (the method {@link |
|
179 |
* #isValid isValid} returns <CODE>false</CODE>). |
|
180 |
* |
|
181 |
* @param initNumFields The initial capacity of the Map that |
|
182 |
* stores the descriptor fields. |
|
183 |
* |
|
184 |
* @exception RuntimeOperationsException for illegal value for |
|
185 |
* initNumFields (<= 0) |
|
186 |
* @exception MBeanException Wraps a distributed communication Exception. |
|
187 |
*/ |
|
188 |
public DescriptorSupport(int initNumFields) |
|
189 |
throws MBeanException, RuntimeOperationsException { |
|
190 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
191 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
192 |
DescriptorSupport.class.getName(), |
|
193 |
"Descriptor(initNumFields = " + initNumFields + ")", |
|
194 |
"Constructor"); |
|
195 |
} |
|
196 |
if (initNumFields <= 0) { |
|
197 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
198 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
199 |
DescriptorSupport.class.getName(), |
|
200 |
"Descriptor(initNumFields)", |
|
201 |
"Illegal arguments: initNumFields <= 0"); |
|
202 |
} |
|
203 |
final String msg = |
|
204 |
"Descriptor field limit invalid: " + initNumFields; |
|
205 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
206 |
throw new RuntimeOperationsException(iae, msg); |
|
207 |
} |
|
208 |
init(null); |
|
209 |
} |
|
210 |
||
211 |
/** |
|
212 |
* Descriptor constructor taking a Descriptor as parameter. |
|
213 |
* Creates a new descriptor initialized to the values of the |
|
214 |
* descriptor passed in parameter. |
|
215 |
* |
|
216 |
* @param inDescr the descriptor to be used to initialize the |
|
217 |
* constructed descriptor. If it is null or contains no descriptor |
|
218 |
* fields, an empty Descriptor will be created. |
|
219 |
*/ |
|
220 |
public DescriptorSupport(DescriptorSupport inDescr) { |
|
221 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
222 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
223 |
DescriptorSupport.class.getName(), |
|
224 |
"Descriptor(Descriptor)", "Constructor"); |
|
225 |
} |
|
226 |
if (inDescr == null) |
|
227 |
init(null); |
|
228 |
else |
|
229 |
init(inDescr.descriptorMap); |
|
230 |
} |
|
231 |
||
232 |
||
233 |
/** |
|
234 |
* <p>Descriptor constructor taking an XML String.</p> |
|
235 |
* |
|
236 |
* <p>The format of the XML string is not defined, but an |
|
237 |
* implementation must ensure that the string returned by |
|
238 |
* {@link #toXMLString() toXMLString()} on an existing |
|
239 |
* descriptor can be used to instantiate an equivalent |
|
240 |
* descriptor using this constructor.</p> |
|
241 |
* |
|
242 |
* <p>In this implementation, all field values will be created |
|
243 |
* as Strings. If the field values are not Strings, the |
|
244 |
* programmer will have to reset or convert these fields |
|
245 |
* correctly.</p> |
|
246 |
* |
|
247 |
* @param inStr An XML-formatted string used to populate this |
|
248 |
* Descriptor. The format is not defined, but any |
|
249 |
* implementation must ensure that the string returned by |
|
250 |
* method {@link #toXMLString toXMLString} on an existing |
|
251 |
* descriptor can be used to instantiate an equivalent |
|
252 |
* descriptor when instantiated using this constructor. |
|
253 |
* |
|
254 |
* @exception RuntimeOperationsException If the String inStr |
|
255 |
* passed in parameter is null |
|
256 |
* @exception XMLParseException XML parsing problem while parsing |
|
257 |
* the input String |
|
258 |
* @exception MBeanException Wraps a distributed communication Exception. |
|
259 |
*/ |
|
260 |
/* At some stage we should rewrite this code to be cleverer. Using |
|
261 |
a StringTokenizer as we do means, first, that we accept a lot of |
|
262 |
bogus strings without noticing they are bogus, and second, that we |
|
263 |
split the string being parsed at characters like > even if they |
|
264 |
occur in the middle of a field value. */ |
|
265 |
public DescriptorSupport(String inStr) |
|
266 |
throws MBeanException, RuntimeOperationsException, |
|
267 |
XMLParseException { |
|
268 |
/* parse an XML-formatted string and populate internal |
|
269 |
* structure with it */ |
|
270 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
271 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
272 |
DescriptorSupport.class.getName(), |
|
273 |
"Descriptor(String = '" + inStr + "')", "Constructor"); |
|
274 |
} |
|
275 |
if (inStr == null) { |
|
276 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
277 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
278 |
DescriptorSupport.class.getName(), |
|
279 |
"Descriptor(String = null)", "Illegal arguments"); |
|
280 |
} |
|
281 |
final String msg = "String in parameter is null"; |
|
282 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
283 |
throw new RuntimeOperationsException(iae, msg); |
|
284 |
} |
|
285 |
||
286 |
final String lowerInStr = inStr.toLowerCase(); |
|
287 |
if (!lowerInStr.startsWith("<descriptor>") |
|
288 |
|| !lowerInStr.endsWith("</descriptor>")) { |
|
289 |
throw new XMLParseException("No <descriptor>, </descriptor> pair"); |
|
290 |
} |
|
291 |
||
292 |
// parse xmlstring into structures |
|
293 |
init(null); |
|
294 |
// create dummy descriptor: should have same size |
|
295 |
// as number of fields in xmlstring |
|
296 |
// loop through structures and put them in descriptor |
|
297 |
||
298 |
StringTokenizer st = new StringTokenizer(inStr, "<> \t\n\r\f"); |
|
299 |
||
300 |
boolean inFld = false; |
|
301 |
boolean inDesc = false; |
|
302 |
String fieldName = null; |
|
303 |
String fieldValue = null; |
|
304 |
||
305 |
||
306 |
while (st.hasMoreTokens()) { // loop through tokens |
|
307 |
String tok = st.nextToken(); |
|
308 |
||
309 |
if (tok.equalsIgnoreCase("FIELD")) { |
|
310 |
inFld = true; |
|
311 |
} else if (tok.equalsIgnoreCase("/FIELD")) { |
|
312 |
if ((fieldName != null) && (fieldValue != null)) { |
|
313 |
fieldName = |
|
314 |
fieldName.substring(fieldName.indexOf('"') + 1, |
|
315 |
fieldName.lastIndexOf('"')); |
|
316 |
final Object fieldValueObject = |
|
317 |
parseQuotedFieldValue(fieldValue); |
|
318 |
setField(fieldName, fieldValueObject); |
|
319 |
} |
|
320 |
fieldName = null; |
|
321 |
fieldValue = null; |
|
322 |
inFld = false; |
|
323 |
} else if (tok.equalsIgnoreCase("DESCRIPTOR")) { |
|
324 |
inDesc = true; |
|
325 |
} else if (tok.equalsIgnoreCase("/DESCRIPTOR")) { |
|
326 |
inDesc = false; |
|
327 |
fieldName = null; |
|
328 |
fieldValue = null; |
|
329 |
inFld = false; |
|
330 |
} else if (inFld && inDesc) { |
|
331 |
// want kw=value, eg, name="myname" value="myvalue" |
|
332 |
int eq_separator = tok.indexOf("="); |
|
333 |
if (eq_separator > 0) { |
|
334 |
String kwPart = tok.substring(0,eq_separator); |
|
335 |
String valPart = tok.substring(eq_separator+1); |
|
336 |
if (kwPart.equalsIgnoreCase("NAME")) |
|
337 |
fieldName = valPart; |
|
338 |
else if (kwPart.equalsIgnoreCase("VALUE")) |
|
339 |
fieldValue = valPart; |
|
340 |
else { // xml parse exception |
|
341 |
final String msg = |
|
342 |
"Expected `name' or `value', got `" + tok + "'"; |
|
343 |
throw new XMLParseException(msg); |
|
344 |
} |
|
345 |
} else { // xml parse exception |
|
346 |
final String msg = |
|
347 |
"Expected `keyword=value', got `" + tok + "'"; |
|
348 |
throw new XMLParseException(msg); |
|
349 |
} |
|
350 |
} |
|
351 |
} // while tokens |
|
352 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
353 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
354 |
DescriptorSupport.class.getName(), |
|
355 |
"Descriptor(XMLString)", "Exit"); |
|
356 |
} |
|
357 |
} |
|
358 |
||
359 |
/** |
|
360 |
* Constructor taking field names and field values. Neither array |
|
361 |
* can be null. |
|
362 |
* |
|
363 |
* @param fieldNames String array of field names. No elements of |
|
364 |
* this array can be null. |
|
365 |
* @param fieldValues Object array of the corresponding field |
|
366 |
* values. Elements of the array can be null. The |
|
367 |
* <code>fieldValue</code> must be valid for the |
|
368 |
* <code>fieldName</code> (as defined in method {@link #isValid |
|
369 |
* isValid}) |
|
370 |
* |
|
371 |
* <p>Note: array sizes of parameters should match. If both arrays |
|
372 |
* are empty, then an empty descriptor is created.</p> |
|
373 |
* |
|
374 |
* @exception RuntimeOperationsException for illegal value for |
|
375 |
* field Names or field Values. The array lengths must be equal. |
|
376 |
* If the descriptor construction fails for any reason, this |
|
377 |
* exception will be thrown. |
|
378 |
* |
|
379 |
*/ |
|
380 |
public DescriptorSupport(String[] fieldNames, Object[] fieldValues) |
|
381 |
throws RuntimeOperationsException { |
|
382 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
383 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
384 |
DescriptorSupport.class.getName(), |
|
385 |
"Descriptor(fieldNames,fieldObjects)", "Constructor"); |
|
386 |
} |
|
387 |
||
388 |
if ((fieldNames == null) || (fieldValues == null) || |
|
389 |
(fieldNames.length != fieldValues.length)) { |
|
390 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
391 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
392 |
DescriptorSupport.class.getName(), |
|
393 |
"Descriptor(fieldNames,fieldObjects)", |
|
394 |
"Illegal arguments"); |
|
395 |
} |
|
396 |
||
397 |
final String msg = |
|
398 |
"Null or invalid fieldNames or fieldValues"; |
|
399 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
400 |
throw new RuntimeOperationsException(iae, msg); |
|
401 |
} |
|
402 |
||
403 |
/* populate internal structure with fields */ |
|
404 |
init(null); |
|
405 |
for (int i=0; i < fieldNames.length; i++) { |
|
406 |
// setField will throw an exception if a fieldName is be null. |
|
407 |
// the fieldName and fieldValue will be validated in setField. |
|
408 |
setField(fieldNames[i], fieldValues[i]); |
|
409 |
} |
|
410 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
411 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
412 |
DescriptorSupport.class.getName(), |
|
413 |
"Descriptor(fieldNames,fieldObjects)", "Exit"); |
|
414 |
} |
|
415 |
} |
|
416 |
||
417 |
/** |
|
418 |
* Constructor taking fields in the <i>fieldName=fieldValue</i> |
|
419 |
* format. |
|
420 |
* |
|
421 |
* @param fields String array with each element containing a |
|
422 |
* field name and value. If this array is null or empty, then the |
|
423 |
* default constructor will be executed. Null strings or empty |
|
424 |
* strings will be ignored. |
|
425 |
* |
|
426 |
* <p>All field values should be Strings. If the field values are |
|
427 |
* not Strings, the programmer will have to reset or convert these |
|
428 |
* fields correctly. |
|
429 |
* |
|
430 |
* <p>Note: Each string should be of the form |
|
431 |
* <i>fieldName=fieldValue</i>. The field name |
|
432 |
* ends at the first {@code =} character; for example if the String |
|
433 |
* is {@code a=b=c} then the field name is {@code a} and its value |
|
434 |
* is {@code b=c}. |
|
435 |
* |
|
436 |
* @exception RuntimeOperationsException for illegal value for |
|
437 |
* field Names or field Values. The field must contain an |
|
438 |
* "=". "=fieldValue", "fieldName", and "fieldValue" are illegal. |
|
439 |
* FieldName cannot be null. "fieldName=" will cause the value to |
|
440 |
* be null. If the descriptor construction fails for any reason, |
|
441 |
* this exception will be thrown. |
|
442 |
* |
|
443 |
*/ |
|
444 |
public DescriptorSupport(String... fields) |
|
445 |
{ |
|
446 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
447 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
448 |
DescriptorSupport.class.getName(), |
|
449 |
"Descriptor(String... fields)", "Constructor"); |
|
450 |
} |
|
451 |
init(null); |
|
452 |
if (( fields == null ) || ( fields.length == 0)) |
|
453 |
return; |
|
454 |
||
455 |
init(null); |
|
456 |
||
457 |
for (int i=0; i < fields.length; i++) { |
|
458 |
if ((fields[i] == null) || (fields[i].equals(""))) { |
|
459 |
continue; |
|
460 |
} |
|
461 |
int eq_separator = fields[i].indexOf("="); |
|
462 |
if (eq_separator < 0) { |
|
463 |
// illegal if no = or is first character |
|
464 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
465 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
466 |
DescriptorSupport.class.getName(), |
|
467 |
"Descriptor(String... fields)", |
|
468 |
"Illegal arguments: field does not have " + |
|
469 |
"'=' as a name and value separator"); |
|
470 |
} |
|
471 |
final String msg = "Field in invalid format: no equals sign"; |
|
472 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
473 |
throw new RuntimeOperationsException(iae, msg); |
|
474 |
} |
|
475 |
||
476 |
String fieldName = fields[i].substring(0,eq_separator); |
|
477 |
String fieldValue = null; |
|
478 |
if (eq_separator < fields[i].length()) { |
|
479 |
// = is not in last character |
|
480 |
fieldValue = fields[i].substring(eq_separator+1); |
|
481 |
} |
|
482 |
||
483 |
if (fieldName.equals("")) { |
|
484 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
485 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
486 |
DescriptorSupport.class.getName(), |
|
487 |
"Descriptor(String... fields)", |
|
488 |
"Illegal arguments: fieldName is empty"); |
|
489 |
} |
|
490 |
||
491 |
final String msg = "Field in invalid format: no fieldName"; |
|
492 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
493 |
throw new RuntimeOperationsException(iae, msg); |
|
494 |
} |
|
495 |
||
496 |
setField(fieldName,fieldValue); |
|
497 |
} |
|
498 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
499 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
500 |
DescriptorSupport.class.getName(), |
|
501 |
"Descriptor(String... fields)", "Exit"); |
|
502 |
} |
|
503 |
} |
|
504 |
||
505 |
private void init(Map<String, ?> initMap) { |
|
506 |
descriptorMap = |
|
507 |
new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER); |
|
508 |
if (initMap != null) |
|
509 |
descriptorMap.putAll(initMap); |
|
510 |
} |
|
511 |
||
512 |
// Implementation of the Descriptor interface |
|
513 |
||
514 |
||
515 |
public synchronized Object getFieldValue(String fieldName) |
|
516 |
throws RuntimeOperationsException { |
|
517 |
||
518 |
if ((fieldName == null) || (fieldName.equals(""))) { |
|
519 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
520 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
521 |
DescriptorSupport.class.getName(), |
|
522 |
"getFieldValue(String fieldName)", |
|
523 |
"Illegal arguments: null field name"); |
|
524 |
} |
|
525 |
final String msg = "Fieldname requested is null"; |
|
526 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
527 |
throw new RuntimeOperationsException(iae, msg); |
|
528 |
} |
|
529 |
Object retValue = descriptorMap.get(fieldName); |
|
530 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
531 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
532 |
DescriptorSupport.class.getName(), |
|
533 |
"getFieldValue(String fieldName = " + fieldName + ")", |
|
534 |
"Returns '" + retValue + "'"); |
|
535 |
} |
|
536 |
return(retValue); |
|
537 |
} |
|
538 |
||
539 |
public synchronized void setField(String fieldName, Object fieldValue) |
|
540 |
throws RuntimeOperationsException { |
|
541 |
||
542 |
// field name cannot be null or empty |
|
543 |
if ((fieldName == null) || (fieldName.equals(""))) { |
|
544 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
545 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
546 |
DescriptorSupport.class.getName(), |
|
547 |
"setField(fieldName,fieldValue)", |
|
548 |
"Illegal arguments: null or empty field name"); |
|
549 |
} |
|
550 |
||
551 |
final String msg = "Field name to be set is null or empty"; |
|
552 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
553 |
throw new RuntimeOperationsException(iae, msg); |
|
554 |
} |
|
555 |
||
556 |
if (!validateField(fieldName, fieldValue)) { |
|
557 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
558 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
559 |
DescriptorSupport.class.getName(), |
|
560 |
"setField(fieldName,fieldValue)", |
|
561 |
"Illegal arguments"); |
|
562 |
} |
|
563 |
||
564 |
final String msg = |
|
565 |
"Field value invalid: " + fieldName + "=" + fieldValue; |
|
566 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
567 |
throw new RuntimeOperationsException(iae, msg); |
|
568 |
} |
|
569 |
||
570 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
571 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
572 |
DescriptorSupport.class.getName(), |
|
573 |
"setField(fieldName,fieldValue)", "Entry: setting '" |
|
574 |
+ fieldName + "' to '" + fieldValue + "'"); |
|
575 |
} |
|
576 |
||
577 |
// Since we do not remove any existing entry with this name, |
|
578 |
// the field will preserve whatever case it had, ignoring |
|
579 |
// any difference there might be in fieldName. |
|
580 |
descriptorMap.put(fieldName, fieldValue); |
|
581 |
} |
|
582 |
||
583 |
public synchronized String[] getFields() { |
|
584 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
585 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
586 |
DescriptorSupport.class.getName(), |
|
587 |
"getFields()", "Entry"); |
|
588 |
} |
|
589 |
int numberOfEntries = descriptorMap.size(); |
|
590 |
||
591 |
String[] responseFields = new String[numberOfEntries]; |
|
592 |
Set returnedSet = descriptorMap.entrySet(); |
|
593 |
||
594 |
int i = 0; |
|
595 |
||
596 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
597 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
598 |
DescriptorSupport.class.getName(), |
|
599 |
"getFields()", "Returning " + numberOfEntries + " fields"); |
|
600 |
} |
|
601 |
for (Iterator iter = returnedSet.iterator(); iter.hasNext(); i++) { |
|
526
61ba2d5ea9da
6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents:
2
diff
changeset
|
602 |
Map.Entry currElement = (Map.Entry) iter.next(); |
2 | 603 |
|
604 |
if (currElement == null) { |
|
605 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
606 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
607 |
DescriptorSupport.class.getName(), |
|
608 |
"getFields()", "Element is null"); |
|
609 |
} |
|
610 |
} else { |
|
526
61ba2d5ea9da
6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents:
2
diff
changeset
|
611 |
Object currValue = currElement.getValue(); |
2 | 612 |
if (currValue == null) { |
613 |
responseFields[i] = currElement.getKey() + "="; |
|
614 |
} else { |
|
615 |
if (currValue instanceof java.lang.String) { |
|
616 |
responseFields[i] = |
|
617 |
currElement.getKey() + "=" + currValue.toString(); |
|
618 |
} else { |
|
619 |
responseFields[i] = |
|
620 |
currElement.getKey() + "=(" + |
|
621 |
currValue.toString() + ")"; |
|
622 |
} |
|
623 |
} |
|
624 |
} |
|
625 |
} |
|
626 |
||
627 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
628 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
629 |
DescriptorSupport.class.getName(), |
|
630 |
"getFields()", "Exit"); |
|
631 |
} |
|
632 |
||
633 |
return responseFields; |
|
634 |
} |
|
635 |
||
636 |
public synchronized String[] getFieldNames() { |
|
637 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
638 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
639 |
DescriptorSupport.class.getName(), |
|
640 |
"getFieldNames()", "Entry"); |
|
641 |
} |
|
642 |
int numberOfEntries = descriptorMap.size(); |
|
643 |
||
644 |
String[] responseFields = new String[numberOfEntries]; |
|
645 |
Set returnedSet = descriptorMap.entrySet(); |
|
646 |
||
647 |
int i = 0; |
|
648 |
||
649 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
650 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
651 |
DescriptorSupport.class.getName(), |
|
652 |
"getFieldNames()", |
|
653 |
"Returning " + numberOfEntries + " fields"); |
|
654 |
} |
|
655 |
||
656 |
for (Iterator iter = returnedSet.iterator(); iter.hasNext(); i++) { |
|
657 |
Map.Entry currElement = (Map.Entry) iter.next(); |
|
658 |
||
659 |
if (( currElement == null ) || (currElement.getKey() == null)) { |
|
660 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
661 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
662 |
DescriptorSupport.class.getName(), |
|
663 |
"getFieldNames()", "Field is null"); |
|
664 |
} |
|
665 |
} else { |
|
666 |
responseFields[i] = currElement.getKey().toString(); |
|
667 |
} |
|
668 |
} |
|
669 |
||
670 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
671 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
672 |
DescriptorSupport.class.getName(), |
|
673 |
"getFieldNames()", "Exit"); |
|
674 |
} |
|
675 |
||
676 |
return responseFields; |
|
677 |
} |
|
678 |
||
679 |
||
680 |
public synchronized Object[] getFieldValues(String... fieldNames) { |
|
681 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
682 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
683 |
DescriptorSupport.class.getName(), |
|
684 |
"getFieldValues(String... fieldNames)", "Entry"); |
|
685 |
} |
|
686 |
// if fieldNames == null return all values |
|
687 |
// if fieldNames is String[0] return no values |
|
688 |
||
689 |
final int numberOfEntries = |
|
690 |
(fieldNames == null) ? descriptorMap.size() : fieldNames.length; |
|
691 |
final Object[] responseFields = new Object[numberOfEntries]; |
|
692 |
||
693 |
int i = 0; |
|
694 |
||
695 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
696 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
697 |
DescriptorSupport.class.getName(), |
|
698 |
"getFieldValues(String... fieldNames)", |
|
699 |
"Returning " + numberOfEntries + " fields"); |
|
700 |
} |
|
701 |
||
702 |
if (fieldNames == null) { |
|
703 |
for (Iterator iter = descriptorMap.values().iterator(); |
|
704 |
iter.hasNext(); i++) |
|
705 |
responseFields[i] = iter.next(); |
|
706 |
} else { |
|
707 |
for (i=0; i < fieldNames.length; i++) { |
|
708 |
if ((fieldNames[i] == null) || (fieldNames[i].equals(""))) { |
|
709 |
responseFields[i] = null; |
|
710 |
} else { |
|
711 |
responseFields[i] = getFieldValue(fieldNames[i]); |
|
712 |
} |
|
713 |
} |
|
714 |
} |
|
715 |
||
716 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
717 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
718 |
DescriptorSupport.class.getName(), |
|
719 |
"getFieldValues(String... fieldNames)", "Exit"); |
|
720 |
} |
|
721 |
||
722 |
return responseFields; |
|
723 |
} |
|
724 |
||
725 |
public synchronized void setFields(String[] fieldNames, |
|
726 |
Object[] fieldValues) |
|
727 |
throws RuntimeOperationsException { |
|
728 |
||
729 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
730 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
731 |
DescriptorSupport.class.getName(), |
|
732 |
"setFields(fieldNames,fieldValues)", "Entry"); |
|
733 |
} |
|
734 |
||
735 |
if ((fieldNames == null) || (fieldValues == null) || |
|
736 |
(fieldNames.length != fieldValues.length)) { |
|
737 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
738 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
739 |
DescriptorSupport.class.getName(), |
|
740 |
"setFields(fieldNames,fieldValues)", |
|
741 |
"Illegal arguments"); |
|
742 |
} |
|
743 |
||
744 |
final String msg = "fieldNames and fieldValues are null or invalid"; |
|
745 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
746 |
throw new RuntimeOperationsException(iae, msg); |
|
747 |
} |
|
748 |
||
749 |
for (int i=0; i < fieldNames.length; i++) { |
|
750 |
if (( fieldNames[i] == null) || (fieldNames[i].equals(""))) { |
|
751 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
752 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
753 |
DescriptorSupport.class.getName(), |
|
754 |
"setFields(fieldNames,fieldValues)", |
|
755 |
"Null field name encountered at element " + i); |
|
756 |
} |
|
757 |
final String msg = "fieldNames is null or invalid"; |
|
758 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
759 |
throw new RuntimeOperationsException(iae, msg); |
|
760 |
} |
|
761 |
setField(fieldNames[i], fieldValues[i]); |
|
762 |
} |
|
763 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
764 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
765 |
DescriptorSupport.class.getName(), |
|
766 |
"setFields(fieldNames,fieldValues)", "Exit"); |
|
767 |
} |
|
768 |
} |
|
769 |
||
770 |
/** |
|
771 |
* Returns a new Descriptor which is a duplicate of the Descriptor. |
|
772 |
* |
|
773 |
* @exception RuntimeOperationsException for illegal value for |
|
774 |
* field Names or field Values. If the descriptor construction |
|
775 |
* fails for any reason, this exception will be thrown. |
|
776 |
*/ |
|
777 |
||
900
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
778 |
@Override |
2 | 779 |
public synchronized Object clone() throws RuntimeOperationsException { |
780 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
781 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
782 |
DescriptorSupport.class.getName(), |
|
783 |
"clone()", "Entry"); |
|
784 |
} |
|
785 |
return(new DescriptorSupport(this)); |
|
786 |
} |
|
787 |
||
788 |
public synchronized void removeField(String fieldName) { |
|
789 |
if ((fieldName == null) || (fieldName.equals(""))) { |
|
790 |
return; |
|
791 |
} |
|
792 |
||
793 |
descriptorMap.remove(fieldName); |
|
794 |
} |
|
795 |
||
796 |
/** |
|
797 |
* Compares this descriptor to the given object. The objects are equal if |
|
798 |
* the given object is also a Descriptor, and if the two Descriptors have |
|
799 |
* the same field names (possibly differing in case) and the same |
|
800 |
* associated values. The respective values for a field in the two |
|
801 |
* Descriptors are equal if the following conditions hold:</p> |
|
802 |
* |
|
803 |
* <ul> |
|
804 |
* <li>If one value is null then the other must be too.</li> |
|
805 |
* <li>If one value is a primitive array then the other must be a primitive |
|
806 |
* array of the same type with the same elements.</li> |
|
807 |
* <li>If one value is an object array then the other must be too and |
|
808 |
* {@link java.util.Arrays#deepEquals(Object[],Object[]) Arrays.deepEquals} |
|
809 |
* must return true.</li> |
|
810 |
* <li>Otherwise {@link Object#equals(Object)} must return true.</li> |
|
811 |
* </ul> |
|
812 |
* |
|
813 |
* @param o the object to compare with. |
|
814 |
* |
|
815 |
* @return {@code true} if the objects are the same; {@code false} |
|
816 |
* otherwise. |
|
817 |
* |
|
818 |
*/ |
|
819 |
// Note: this Javadoc is copied from javax.management.Descriptor |
|
820 |
// due to 6369229. |
|
900
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
821 |
@Override |
2 | 822 |
public synchronized boolean equals(Object o) { |
823 |
if (o == this) |
|
824 |
return true; |
|
900
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
825 |
if (! (o instanceof Descriptor)) |
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
826 |
return false; |
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
827 |
if (o instanceof ImmutableDescriptor) |
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
828 |
return o.equals(this); |
2 | 829 |
return new ImmutableDescriptor(descriptorMap).equals(o); |
830 |
} |
|
831 |
||
832 |
/** |
|
833 |
* <p>Returns the hash code value for this descriptor. The hash |
|
834 |
* code is computed as the sum of the hash codes for each field in |
|
835 |
* the descriptor. The hash code of a field with name {@code n} |
|
836 |
* and value {@code v} is {@code n.toLowerCase().hashCode() ^ h}. |
|
837 |
* Here {@code h} is the hash code of {@code v}, computed as |
|
838 |
* follows:</p> |
|
839 |
* |
|
840 |
* <ul> |
|
841 |
* <li>If {@code v} is null then {@code h} is 0.</li> |
|
842 |
* <li>If {@code v} is a primitive array then {@code h} is computed using |
|
843 |
* the appropriate overloading of {@code java.util.Arrays.hashCode}.</li> |
|
844 |
* <li>If {@code v} is an object array then {@code h} is computed using |
|
845 |
* {@link java.util.Arrays#deepHashCode(Object[]) Arrays.deepHashCode}.</li> |
|
846 |
* <li>Otherwise {@code h} is {@code v.hashCode()}.</li> |
|
847 |
* </ul> |
|
848 |
* |
|
849 |
* @return A hash code value for this object. |
|
850 |
* |
|
851 |
*/ |
|
852 |
// Note: this Javadoc is copied from javax.management.Descriptor |
|
853 |
// due to 6369229. |
|
900
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
854 |
@Override |
2 | 855 |
public synchronized int hashCode() { |
900
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
856 |
final int size = descriptorMap.size(); |
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
857 |
// descriptorMap is sorted with a comparator that ignores cases. |
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
858 |
// |
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
859 |
return Util.hashCode( |
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
860 |
descriptorMap.keySet().toArray(new String[size]), |
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
861 |
descriptorMap.values().toArray(new Object[size])); |
2 | 862 |
} |
863 |
||
864 |
/** |
|
865 |
* Returns true if all of the fields have legal values given their |
|
866 |
* names. |
|
867 |
* <P> |
|
868 |
* This implementation does not support interoperating with a directory |
|
869 |
* or lookup service. Thus, conforming to the specification, no checking is |
|
870 |
* done on the <i>"export"</i> field. |
|
871 |
* <P> |
|
872 |
* Otherwise this implementation returns false if: |
|
873 |
* <P> |
|
874 |
* <UL> |
|
875 |
* <LI> name and descriptorType fieldNames are not defined, or |
|
876 |
* null, or empty, or not String |
|
877 |
* <LI> class, role, getMethod, setMethod fieldNames, if defined, |
|
878 |
* are null or not String |
|
879 |
* <LI> persistPeriod, currencyTimeLimit, lastUpdatedTimeStamp, |
|
880 |
* lastReturnedTimeStamp if defined, are null, or not a Numeric |
|
881 |
* String or not a Numeric Value >= -1 |
|
882 |
* <LI> log fieldName, if defined, is null, or not a Boolean or |
|
883 |
* not a String with value "t", "f", "true", "false". These String |
|
884 |
* values must not be case sensitive. |
|
885 |
* <LI> visibility fieldName, if defined, is null, or not a |
|
886 |
* Numeric String or a not Numeric Value >= 1 and <= 4 |
|
887 |
* <LI> severity fieldName, if defined, is null, or not a Numeric |
|
888 |
* String or not a Numeric Value >= 0 and <= 6<br> |
|
889 |
* <LI> persistPolicy fieldName, if defined, is null, or not one of |
|
890 |
* the following strings:<br> |
|
891 |
* "OnUpdate", "OnTimer", "NoMoreOftenThan", "OnUnregister", "Always", |
|
892 |
* "Never". These String values must not be case sensitive.<br> |
|
893 |
* </UL> |
|
894 |
* |
|
895 |
* @exception RuntimeOperationsException If the validity checking |
|
896 |
* fails for any reason, this exception will be thrown. |
|
897 |
*/ |
|
898 |
||
899 |
public synchronized boolean isValid() throws RuntimeOperationsException { |
|
900 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
901 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
902 |
DescriptorSupport.class.getName(), |
|
903 |
"isValid()", "Entry"); |
|
904 |
} |
|
905 |
// verify that the descriptor is valid, by iterating over each field... |
|
906 |
||
907 |
Set returnedSet = descriptorMap.entrySet(); |
|
908 |
||
909 |
if (returnedSet == null) { // null descriptor, not valid |
|
910 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
911 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
912 |
DescriptorSupport.class.getName(), |
|
913 |
"isValid()", "Returns false (null set)"); |
|
914 |
} |
|
915 |
return false; |
|
916 |
} |
|
917 |
// must have a name and descriptor type field |
|
918 |
String thisName = (String)(this.getFieldValue("name")); |
|
919 |
String thisDescType = (String)(getFieldValue("descriptorType")); |
|
920 |
||
921 |
if ((thisName == null) || (thisDescType == null) || |
|
922 |
(thisName.equals("")) || (thisDescType.equals(""))) { |
|
923 |
return false; |
|
924 |
} |
|
925 |
||
926 |
// According to the descriptor type we validate the fields contained |
|
927 |
||
928 |
for (Iterator iter = returnedSet.iterator(); iter.hasNext();) { |
|
929 |
Map.Entry currElement = (Map.Entry) iter.next(); |
|
930 |
||
931 |
if (currElement != null) { |
|
932 |
if (currElement.getValue() != null) { |
|
933 |
// validate the field valued... |
|
934 |
if (validateField((currElement.getKey()).toString(), |
|
935 |
(currElement.getValue()).toString())) { |
|
936 |
continue; |
|
937 |
} else { |
|
938 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
939 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
940 |
DescriptorSupport.class.getName(), |
|
941 |
"isValid()", |
|
942 |
"Field " + currElement.getKey() + "=" + |
|
943 |
currElement.getValue() + " is not valid"); |
|
944 |
} |
|
945 |
return false; |
|
946 |
} |
|
947 |
} |
|
948 |
} |
|
949 |
} |
|
950 |
||
951 |
// fell through, all fields OK |
|
952 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
953 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
954 |
DescriptorSupport.class.getName(), |
|
955 |
"isValid()", "Returns true"); |
|
956 |
} |
|
957 |
return true; |
|
958 |
} |
|
959 |
||
960 |
||
961 |
// worker routine for isValid() |
|
962 |
// name is not null |
|
963 |
// descriptorType is not null |
|
964 |
// getMethod and setMethod are not null |
|
965 |
// persistPeriod is numeric |
|
966 |
// currencyTimeLimit is numeric |
|
967 |
// lastUpdatedTimeStamp is numeric |
|
968 |
// visibility is 1-4 |
|
969 |
// severity is 0-6 |
|
970 |
// log is T or F |
|
971 |
// role is not null |
|
972 |
// class is not null |
|
973 |
// lastReturnedTimeStamp is numeric |
|
974 |
||
975 |
||
976 |
private boolean validateField(String fldName, Object fldValue) { |
|
977 |
if ((fldName == null) || (fldName.equals(""))) |
|
978 |
return false; |
|
979 |
String SfldValue = ""; |
|
980 |
boolean isAString = false; |
|
981 |
if ((fldValue != null) && (fldValue instanceof java.lang.String)) { |
|
982 |
SfldValue = (String) fldValue; |
|
983 |
isAString = true; |
|
984 |
} |
|
985 |
||
986 |
boolean nameOrDescriptorType = |
|
987 |
(fldName.equalsIgnoreCase("Name") || |
|
988 |
fldName.equalsIgnoreCase("DescriptorType")); |
|
989 |
if (nameOrDescriptorType || |
|
990 |
fldName.equalsIgnoreCase("SetMethod") || |
|
991 |
fldName.equalsIgnoreCase("GetMethod") || |
|
992 |
fldName.equalsIgnoreCase("Role") || |
|
993 |
fldName.equalsIgnoreCase("Class")) { |
|
994 |
if (fldValue == null || !isAString) |
|
995 |
return false; |
|
996 |
if (nameOrDescriptorType && SfldValue.equals("")) |
|
997 |
return false; |
|
998 |
return true; |
|
999 |
} else if (fldName.equalsIgnoreCase("visibility")) { |
|
1000 |
long v; |
|
1001 |
if ((fldValue != null) && (isAString)) { |
|
1002 |
v = toNumeric(SfldValue); |
|
1003 |
} else if (fldValue instanceof java.lang.Integer) { |
|
1004 |
v = ((Integer)fldValue).intValue(); |
|
1005 |
} else return false; |
|
1006 |
||
1007 |
if (v >= 1 && v <= 4) |
|
1008 |
return true; |
|
1009 |
else |
|
1010 |
return false; |
|
1011 |
} else if (fldName.equalsIgnoreCase("severity")) { |
|
1012 |
||
1013 |
long v; |
|
1014 |
if ((fldValue != null) && (isAString)) { |
|
1015 |
v = toNumeric(SfldValue); |
|
1016 |
} else if (fldValue instanceof java.lang.Integer) { |
|
1017 |
v = ((Integer)fldValue).intValue(); |
|
1018 |
} else return false; |
|
1019 |
||
1020 |
return (v >= 0 && v <= 6); |
|
1021 |
} else if (fldName.equalsIgnoreCase("PersistPolicy")) { |
|
1022 |
return (((fldValue != null) && (isAString)) && |
|
1023 |
( SfldValue.equalsIgnoreCase("OnUpdate") || |
|
1024 |
SfldValue.equalsIgnoreCase("OnTimer") || |
|
1025 |
SfldValue.equalsIgnoreCase("NoMoreOftenThan") || |
|
1026 |
SfldValue.equalsIgnoreCase("Always") || |
|
1027 |
SfldValue.equalsIgnoreCase("Never") || |
|
1028 |
SfldValue.equalsIgnoreCase("OnUnregister"))); |
|
1029 |
} else if (fldName.equalsIgnoreCase("PersistPeriod") || |
|
1030 |
fldName.equalsIgnoreCase("CurrencyTimeLimit") || |
|
1031 |
fldName.equalsIgnoreCase("LastUpdatedTimeStamp") || |
|
1032 |
fldName.equalsIgnoreCase("LastReturnedTimeStamp")) { |
|
1033 |
||
1034 |
long v; |
|
1035 |
if ((fldValue != null) && (isAString)) { |
|
1036 |
v = toNumeric(SfldValue); |
|
1037 |
} else if (fldValue instanceof java.lang.Number) { |
|
1038 |
v = ((Number)fldValue).longValue(); |
|
1039 |
} else return false; |
|
1040 |
||
1041 |
return (v >= -1); |
|
1042 |
} else if (fldName.equalsIgnoreCase("log")) { |
|
1043 |
return ((fldValue instanceof java.lang.Boolean) || |
|
1044 |
(isAString && |
|
1045 |
(SfldValue.equalsIgnoreCase("T") || |
|
1046 |
SfldValue.equalsIgnoreCase("true") || |
|
1047 |
SfldValue.equalsIgnoreCase("F") || |
|
1048 |
SfldValue.equalsIgnoreCase("false") ))); |
|
1049 |
} |
|
1050 |
||
1051 |
// default to true, it is a field we aren't validating (user etc.) |
|
1052 |
return true; |
|
1053 |
} |
|
1054 |
||
1055 |
||
1056 |
||
1057 |
/** |
|
1058 |
* <p>Returns an XML String representing the descriptor.</p> |
|
1059 |
* |
|
1060 |
* <p>The format is not defined, but an implementation must |
|
1061 |
* ensure that the string returned by this method can be |
|
1062 |
* used to build an equivalent descriptor when instantiated |
|
1063 |
* using the constructor {@link #DescriptorSupport(String) |
|
1064 |
* DescriptorSupport(String inStr)}.</p> |
|
1065 |
* |
|
1066 |
* <p>Fields which are not String objects will have toString() |
|
1067 |
* called on them to create the value. The value will be |
|
1068 |
* enclosed in parentheses. It is not guaranteed that you can |
|
1069 |
* reconstruct these objects unless they have been |
|
1070 |
* specifically set up to support toString() in a meaningful |
|
1071 |
* format and have a matching constructor that accepts a |
|
1072 |
* String in the same format.</p> |
|
1073 |
* |
|
1074 |
* <p>If the descriptor is empty the following String is |
|
1075 |
* returned: <Descriptor></Descriptor></p> |
|
1076 |
* |
|
1077 |
* @return the XML string. |
|
1078 |
* |
|
1079 |
* @exception RuntimeOperationsException for illegal value for |
|
1080 |
* field Names or field Values. If the XML formatted string |
|
1081 |
* construction fails for any reason, this exception will be |
|
1082 |
* thrown. |
|
1083 |
*/ |
|
1084 |
public synchronized String toXMLString() { |
|
1085 |
final StringBuilder buf = new StringBuilder("<Descriptor>"); |
|
1086 |
Set returnedSet = descriptorMap.entrySet(); |
|
1087 |
for (Iterator iter = returnedSet.iterator(); iter.hasNext(); ) { |
|
1088 |
final Map.Entry currElement = (Map.Entry) iter.next(); |
|
1089 |
final String name = currElement.getKey().toString(); |
|
1090 |
Object value = currElement.getValue(); |
|
1091 |
String valueString = null; |
|
1092 |
/* Set valueString to non-null if and only if this is a string that |
|
1093 |
cannot be confused with the encoding of an object. If it |
|
1094 |
could be so confused (surrounded by parentheses) then we |
|
1095 |
call makeFieldValue as for any non-String object and end |
|
1096 |
up with an encoding like "(java.lang.String/(thing))". */ |
|
1097 |
if (value instanceof String) { |
|
1098 |
final String svalue = (String) value; |
|
1099 |
if (!svalue.startsWith("(") || !svalue.endsWith(")")) |
|
1100 |
valueString = quote(svalue); |
|
1101 |
} |
|
1102 |
if (valueString == null) |
|
1103 |
valueString = makeFieldValue(value); |
|
1104 |
buf.append("<field name=\"").append(name).append("\" value=\"") |
|
1105 |
.append(valueString).append("\"></field>"); |
|
1106 |
} |
|
1107 |
buf.append("</Descriptor>"); |
|
1108 |
return buf.toString(); |
|
1109 |
} |
|
1110 |
||
1111 |
private static final String[] entities = { |
|
1112 |
"  ", |
|
1113 |
"\""", |
|
1114 |
"<<", |
|
1115 |
">>", |
|
1116 |
"&&", |
|
1117 |
"\r ", |
|
1118 |
"\t	", |
|
1119 |
"\n ", |
|
1120 |
"\f", |
|
1121 |
}; |
|
1122 |
private static final Map<String,Character> entityToCharMap = |
|
1123 |
new HashMap<String,Character>(); |
|
1124 |
private static final String[] charToEntityMap; |
|
1125 |
||
1126 |
static { |
|
1127 |
char maxChar = 0; |
|
1128 |
for (int i = 0; i < entities.length; i++) { |
|
1129 |
final char c = entities[i].charAt(0); |
|
1130 |
if (c > maxChar) |
|
1131 |
maxChar = c; |
|
1132 |
} |
|
1133 |
charToEntityMap = new String[maxChar + 1]; |
|
1134 |
for (int i = 0; i < entities.length; i++) { |
|
1135 |
final char c = entities[i].charAt(0); |
|
1136 |
final String entity = entities[i].substring(1); |
|
1137 |
charToEntityMap[c] = entity; |
|
526
61ba2d5ea9da
6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents:
2
diff
changeset
|
1138 |
entityToCharMap.put(entity, c); |
2 | 1139 |
} |
1140 |
} |
|
1141 |
||
1142 |
private static boolean isMagic(char c) { |
|
1143 |
return (c < charToEntityMap.length && charToEntityMap[c] != null); |
|
1144 |
} |
|
1145 |
||
1146 |
/* |
|
1147 |
* Quote the string so that it will be acceptable to the (String) |
|
1148 |
* constructor. Since the parsing code in that constructor is fairly |
|
1149 |
* stupid, we're obliged to quote apparently innocuous characters like |
|
1150 |
* space, <, and >. In a future version, we should rewrite the parser |
|
1151 |
* and only quote " plus either \ or & (depending on the quote syntax). |
|
1152 |
*/ |
|
1153 |
private static String quote(String s) { |
|
1154 |
boolean found = false; |
|
1155 |
for (int i = 0; i < s.length(); i++) { |
|
1156 |
if (isMagic(s.charAt(i))) { |
|
1157 |
found = true; |
|
1158 |
break; |
|
1159 |
} |
|
1160 |
} |
|
1161 |
if (!found) |
|
1162 |
return s; |
|
1163 |
final StringBuilder buf = new StringBuilder(); |
|
1164 |
for (int i = 0; i < s.length(); i++) { |
|
1165 |
char c = s.charAt(i); |
|
1166 |
if (isMagic(c)) |
|
1167 |
buf.append(charToEntityMap[c]); |
|
1168 |
else |
|
1169 |
buf.append(c); |
|
1170 |
} |
|
1171 |
return buf.toString(); |
|
1172 |
} |
|
1173 |
||
1174 |
private static String unquote(String s) throws XMLParseException { |
|
1175 |
if (!s.startsWith("\"") || !s.endsWith("\"")) |
|
1176 |
throw new XMLParseException("Value must be quoted: <" + s + ">"); |
|
1177 |
final StringBuilder buf = new StringBuilder(); |
|
1178 |
final int len = s.length() - 1; |
|
1179 |
for (int i = 1; i < len; i++) { |
|
1180 |
final char c = s.charAt(i); |
|
1181 |
final int semi; |
|
1182 |
final Character quoted; |
|
1183 |
if (c == '&' |
|
1184 |
&& (semi = s.indexOf(';', i + 1)) >= 0 |
|
1185 |
&& ((quoted = entityToCharMap.get(s.substring(i, semi+1))) |
|
1186 |
!= null)) { |
|
1187 |
buf.append(quoted); |
|
1188 |
i = semi; |
|
1189 |
} else |
|
1190 |
buf.append(c); |
|
1191 |
} |
|
1192 |
return buf.toString(); |
|
1193 |
} |
|
1194 |
||
1195 |
/** |
|
1196 |
* Make the string that will go inside "..." for a value that is not |
|
1197 |
* a plain String. |
|
1198 |
* @throws RuntimeOperationsException if the value cannot be encoded. |
|
1199 |
*/ |
|
1200 |
private static String makeFieldValue(Object value) { |
|
1201 |
if (value == null) |
|
1202 |
return "(null)"; |
|
1203 |
||
1204 |
Class<?> valueClass = value.getClass(); |
|
1205 |
try { |
|
1206 |
valueClass.getConstructor(String.class); |
|
1207 |
} catch (NoSuchMethodException e) { |
|
1208 |
final String msg = |
|
1209 |
"Class " + valueClass + " does not have a public " + |
|
1210 |
"constructor with a single string arg"; |
|
1211 |
final RuntimeException iae = new IllegalArgumentException(msg); |
|
1212 |
throw new RuntimeOperationsException(iae, |
|
1213 |
"Cannot make XML descriptor"); |
|
1214 |
} catch (SecurityException e) { |
|
1215 |
// OK: we'll pretend the constructor is there |
|
1216 |
// too bad if it's not: we'll find out when we try to |
|
1217 |
// reconstruct the DescriptorSupport |
|
1218 |
} |
|
1219 |
||
1220 |
final String quotedValueString = quote(value.toString()); |
|
1221 |
||
1222 |
return "(" + valueClass.getName() + "/" + quotedValueString + ")"; |
|
1223 |
} |
|
1224 |
||
1225 |
/* |
|
1226 |
* Parse a field value from the XML produced by toXMLString(). |
|
1227 |
* Given a descriptor XML containing <field name="nnn" value="vvv">, |
|
1228 |
* the argument to this method will be "vvv" (a string including the |
|
1229 |
* containing quote characters). If vvv begins and ends with parentheses, |
|
1230 |
* then it may contain: |
|
1231 |
* - the characters "null", in which case the result is null; |
|
1232 |
* - a value of the form "some.class.name/xxx", in which case the |
|
1233 |
* result is equivalent to `new some.class.name("xxx")'; |
|
1234 |
* - some other string, in which case the result is that string, |
|
1235 |
* without the parentheses. |
|
1236 |
*/ |
|
1237 |
private static Object parseQuotedFieldValue(String s) |
|
1238 |
throws XMLParseException { |
|
1239 |
s = unquote(s); |
|
1240 |
if (s.equalsIgnoreCase("(null)")) |
|
1241 |
return null; |
|
1242 |
if (!s.startsWith("(") || !s.endsWith(")")) |
|
1243 |
return s; |
|
1244 |
final int slash = s.indexOf('/'); |
|
1245 |
if (slash < 0) { |
|
1246 |
// compatibility: old code didn't include class name |
|
1247 |
return s.substring(1, s.length() - 1); |
|
1248 |
} |
|
1249 |
final String className = s.substring(1, slash); |
|
1250 |
final Constructor<?> constr; |
|
1251 |
try { |
|
1252 |
final ClassLoader contextClassLoader = |
|
1253 |
Thread.currentThread().getContextClassLoader(); |
|
1254 |
if (contextClassLoader == null) { |
|
1255 |
ReflectUtil.checkPackageAccess(className); |
|
1256 |
} |
|
1257 |
final Class<?> c = |
|
1258 |
Class.forName(className, false, contextClassLoader); |
|
1259 |
constr = c.getConstructor(new Class[] {String.class}); |
|
1260 |
} catch (Exception e) { |
|
1261 |
throw new XMLParseException(e, |
|
1262 |
"Cannot parse value: <" + s + ">"); |
|
1263 |
} |
|
1264 |
final String arg = s.substring(slash + 1, s.length() - 1); |
|
1265 |
try { |
|
1266 |
return constr.newInstance(new Object[] {arg}); |
|
1267 |
} catch (Exception e) { |
|
1268 |
final String msg = |
|
1269 |
"Cannot construct instance of " + className + |
|
1270 |
" with arg: <" + s + ">"; |
|
1271 |
throw new XMLParseException(e, msg); |
|
1272 |
} |
|
1273 |
} |
|
1274 |
||
1275 |
/** |
|
1276 |
* Returns <pv>a human readable string representing the |
|
1277 |
* descriptor</pv>. The string will be in the format of |
|
1278 |
* "fieldName=fieldValue,fieldName2=fieldValue2,..."<br> |
|
1279 |
* |
|
1280 |
* If there are no fields in the descriptor, then an empty String |
|
1281 |
* is returned.<br> |
|
1282 |
* |
|
1283 |
* If a fieldValue is an object then the toString() method is |
|
1284 |
* called on it and its returned value is used as the value for |
|
1285 |
* the field enclosed in parenthesis. |
|
1286 |
* |
|
1287 |
* @exception RuntimeOperationsException for illegal value for |
|
1288 |
* field Names or field Values. If the descriptor string fails |
|
1289 |
* for any reason, this exception will be thrown. |
|
1290 |
*/ |
|
900
55c9c5a88bde
6402254: Revisit ModelMBean DescriptorSupport implementation of equals and hashCode.
dfuchs
parents:
715
diff
changeset
|
1291 |
@Override |
2 | 1292 |
public synchronized String toString() { |
1293 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
1294 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
1295 |
DescriptorSupport.class.getName(), |
|
1296 |
"toString()", "Entry"); |
|
1297 |
} |
|
1298 |
||
1299 |
String respStr = ""; |
|
1300 |
String[] fields = getFields(); |
|
1301 |
||
1302 |
if ((fields == null) || (fields.length == 0)) { |
|
1303 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
1304 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
1305 |
DescriptorSupport.class.getName(), |
|
1306 |
"toString()", "Empty Descriptor"); |
|
1307 |
} |
|
1308 |
return respStr; |
|
1309 |
} |
|
1310 |
||
1311 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
1312 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
1313 |
DescriptorSupport.class.getName(), |
|
1314 |
"toString()", "Printing " + fields.length + " fields"); |
|
1315 |
} |
|
1316 |
||
1317 |
for (int i=0; i < fields.length; i++) { |
|
1318 |
if (i == (fields.length - 1)) { |
|
1319 |
respStr = respStr.concat(fields[i]); |
|
1320 |
} else { |
|
1321 |
respStr = respStr.concat(fields[i] + ", "); |
|
1322 |
} |
|
1323 |
} |
|
1324 |
||
1325 |
if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) { |
|
1326 |
MODELMBEAN_LOGGER.logp(Level.FINEST, |
|
1327 |
DescriptorSupport.class.getName(), |
|
1328 |
"toString()", "Exit returning " + respStr); |
|
1329 |
} |
|
1330 |
||
1331 |
return respStr; |
|
1332 |
} |
|
1333 |
||
1334 |
// utility to convert to int, returns -2 if bogus. |
|
1335 |
||
1336 |
private long toNumeric(String inStr) { |
|
1337 |
try { |
|
526
61ba2d5ea9da
6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents:
2
diff
changeset
|
1338 |
return java.lang.Long.parseLong(inStr); |
2 | 1339 |
} catch (Exception e) { |
1340 |
return -2; |
|
1341 |
} |
|
1342 |
} |
|
1343 |
||
1344 |
||
1345 |
/** |
|
1346 |
* Deserializes a {@link DescriptorSupport} from an {@link |
|
1347 |
* ObjectInputStream}. |
|
1348 |
*/ |
|
1349 |
private void readObject(ObjectInputStream in) |
|
1350 |
throws IOException, ClassNotFoundException { |
|
1351 |
ObjectInputStream.GetField fields = in.readFields(); |
|
1352 |
Map<String, Object> descriptor = cast(fields.get("descriptor", null)); |
|
1353 |
init(null); |
|
1354 |
if (descriptor != null) { |
|
1355 |
descriptorMap.putAll(descriptor); |
|
1356 |
} |
|
1357 |
} |
|
1358 |
||
1359 |
||
1360 |
/** |
|
1361 |
* Serializes a {@link DescriptorSupport} to an {@link ObjectOutputStream}. |
|
1362 |
*/ |
|
1363 |
/* If you set jmx.serial.form to "1.2.0" or "1.2.1", then we are |
|
1364 |
bug-compatible with those versions. Specifically, field names |
|
1365 |
are forced to lower-case before being written. This |
|
1366 |
contradicts the spec, which, though it does not mention |
|
1367 |
serialization explicitly, does say that the case of field names |
|
1368 |
is preserved. But in 1.2.0 and 1.2.1, this requirement was not |
|
1369 |
met. Instead, field names in the descriptor map were forced to |
|
1370 |
lower case. Those versions expect this to have happened to a |
|
1371 |
descriptor they deserialize and e.g. getFieldValue will not |
|
1372 |
find a field whose name is spelt with a different case. |
|
1373 |
*/ |
|
1374 |
private void writeObject(ObjectOutputStream out) throws IOException { |
|
1375 |
ObjectOutputStream.PutField fields = out.putFields(); |
|
1376 |
boolean compat = "1.0".equals(serialForm); |
|
1377 |
if (compat) |
|
1378 |
fields.put("currClass", currClass); |
|
1379 |
||
1380 |
/* Purge the field "targetObject" from the DescriptorSupport before |
|
1381 |
* serializing since the referenced object is typically not |
|
1382 |
* serializable. We do this here rather than purging the "descriptor" |
|
1383 |
* variable below because that HashMap doesn't do case-insensitivity. |
|
1384 |
* See CR 6332962. |
|
1385 |
*/ |
|
1386 |
SortedMap<String, Object> startMap = descriptorMap; |
|
1387 |
if (startMap.containsKey("targetObject")) { |
|
1388 |
startMap = new TreeMap<String, Object>(descriptorMap); |
|
1389 |
startMap.remove("targetObject"); |
|
1390 |
} |
|
1391 |
||
1392 |
final HashMap<String, Object> descriptor; |
|
1393 |
if (compat || "1.2.0".equals(serialForm) || |
|
1394 |
"1.2.1".equals(serialForm)) { |
|
1395 |
descriptor = new HashMap<String, Object>(); |
|
1396 |
for (Map.Entry<String, Object> entry : startMap.entrySet()) |
|
1397 |
descriptor.put(entry.getKey().toLowerCase(), entry.getValue()); |
|
1398 |
} else |
|
1399 |
descriptor = new HashMap<String, Object>(startMap); |
|
1400 |
||
1401 |
fields.put("descriptor", descriptor); |
|
1402 |
out.writeFields(); |
|
1403 |
} |
|
1404 |
||
1405 |
} |