1 /* |
1 /* |
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
37 import java.io.ObjectInputStream; |
37 import java.io.ObjectInputStream; |
38 import java.io.ObjectOutputStream; |
38 import java.io.ObjectOutputStream; |
39 import java.io.ObjectStreamField; |
39 import java.io.ObjectStreamField; |
40 import java.lang.reflect.Method; |
40 import java.lang.reflect.Method; |
41 import java.security.AccessController; |
41 import java.security.AccessController; |
42 import java.util.logging.Level; |
42 import java.lang.System.Logger.Level; |
43 |
43 |
44 import javax.management.Descriptor; |
44 import javax.management.Descriptor; |
45 import javax.management.DescriptorKey; |
45 import javax.management.DescriptorKey; |
46 import javax.management.DescriptorAccess; |
46 import javax.management.DescriptorAccess; |
47 import javax.management.MBeanAttributeInfo; |
47 import javax.management.MBeanAttributeInfo; |
199 Method getter, |
199 Method getter, |
200 Method setter) |
200 Method setter) |
201 throws javax.management.IntrospectionException { |
201 throws javax.management.IntrospectionException { |
202 super(name, description, getter, setter); |
202 super(name, description, getter, setter); |
203 |
203 |
204 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
204 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
205 MODELMBEAN_LOGGER.logp(Level.FINER, |
205 MODELMBEAN_LOGGER.log(Level.TRACE, |
206 ModelMBeanAttributeInfo.class.getName(), |
|
207 "ModelMBeanAttributeInfo(" + |
206 "ModelMBeanAttributeInfo(" + |
208 "String,String,Method,Method)", |
207 "String,String,Method,Method) " + |
209 "Entry", name); |
208 "Entry " + name); |
210 } |
209 } |
211 |
210 |
212 attrDescriptor = validDescriptor(null); |
211 attrDescriptor = validDescriptor(null); |
213 // put getter and setter methods in operations list |
212 // put getter and setter methods in operations list |
214 // create default descriptor |
213 // create default descriptor |
249 Descriptor descriptor) |
248 Descriptor descriptor) |
250 throws javax.management.IntrospectionException { |
249 throws javax.management.IntrospectionException { |
251 |
250 |
252 super(name, description, getter, setter); |
251 super(name, description, getter, setter); |
253 // put getter and setter methods in operations list |
252 // put getter and setter methods in operations list |
254 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
253 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
255 MODELMBEAN_LOGGER.logp(Level.FINER, |
254 MODELMBEAN_LOGGER.log(Level.TRACE, |
256 ModelMBeanAttributeInfo.class.getName(), |
|
257 "ModelMBeanAttributeInfo(" + |
255 "ModelMBeanAttributeInfo(" + |
258 "String,String,Method,Method,Descriptor)", |
256 "String,String,Method,Method,Descriptor) " + |
259 "Entry", name); |
257 "Entry " + name); |
260 } |
258 } |
261 attrDescriptor = validDescriptor(descriptor); |
259 attrDescriptor = validDescriptor(descriptor); |
262 } |
260 } |
263 |
261 |
264 /** |
262 /** |
280 boolean isIs) |
278 boolean isIs) |
281 { |
279 { |
282 |
280 |
283 super(name, type, description, isReadable, isWritable, isIs); |
281 super(name, type, description, isReadable, isWritable, isIs); |
284 // create default descriptor |
282 // create default descriptor |
285 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
283 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
286 MODELMBEAN_LOGGER.logp(Level.FINER, |
284 MODELMBEAN_LOGGER.log(Level.TRACE, |
287 ModelMBeanAttributeInfo.class.getName(), |
285 ModelMBeanAttributeInfo.class.getName(), |
288 "ModelMBeanAttributeInfo(" + |
286 "ModelMBeanAttributeInfo(" + |
289 "String,String,String,boolean,boolean,boolean)", |
287 "String,String,String,boolean,boolean,boolean)", |
290 "Entry", name); |
288 "Entry", name); |
291 } |
289 } |
319 boolean isWritable, |
317 boolean isWritable, |
320 boolean isIs, |
318 boolean isIs, |
321 Descriptor descriptor) |
319 Descriptor descriptor) |
322 { |
320 { |
323 super(name, type, description, isReadable, isWritable, isIs); |
321 super(name, type, description, isReadable, isWritable, isIs); |
324 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
322 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
325 MODELMBEAN_LOGGER.logp(Level.FINER, |
323 MODELMBEAN_LOGGER.log(Level.TRACE, |
326 ModelMBeanAttributeInfo.class.getName(), |
|
327 "ModelMBeanAttributeInfo(String,String,String," + |
324 "ModelMBeanAttributeInfo(String,String,String," + |
328 "boolean,boolean,boolean,Descriptor)", |
325 "boolean,boolean,boolean,Descriptor)" + |
329 "Entry", name); |
326 "Entry " + name); |
330 } |
327 } |
331 attrDescriptor = validDescriptor(descriptor); |
328 attrDescriptor = validDescriptor(descriptor); |
332 } |
329 } |
333 |
330 |
334 /** |
331 /** |
345 inInfo.getType(), |
342 inInfo.getType(), |
346 inInfo.getDescription(), |
343 inInfo.getDescription(), |
347 inInfo.isReadable(), |
344 inInfo.isReadable(), |
348 inInfo.isWritable(), |
345 inInfo.isWritable(), |
349 inInfo.isIs()); |
346 inInfo.isIs()); |
350 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
347 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
351 MODELMBEAN_LOGGER.logp(Level.FINER, |
348 MODELMBEAN_LOGGER.log(Level.TRACE, |
352 ModelMBeanAttributeInfo.class.getName(), |
349 "ModelMBeanAttributeInfo(ModelMBeanAttributeInfo) " + |
353 "ModelMBeanAttributeInfo(ModelMBeanAttributeInfo)", |
|
354 "Entry"); |
350 "Entry"); |
355 } |
351 } |
356 Descriptor newDesc = inInfo.getDescriptor(); |
352 Descriptor newDesc = inInfo.getDescriptor(); |
357 attrDescriptor = validDescriptor(newDesc); |
353 attrDescriptor = validDescriptor(newDesc); |
358 } |
354 } |
366 * |
362 * |
367 * @see #setDescriptor |
363 * @see #setDescriptor |
368 */ |
364 */ |
369 |
365 |
370 public Descriptor getDescriptor() { |
366 public Descriptor getDescriptor() { |
371 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
367 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
372 MODELMBEAN_LOGGER.logp(Level.FINER, |
368 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
373 ModelMBeanAttributeInfo.class.getName(), |
|
374 "getDescriptor()", "Entry"); |
|
375 } |
369 } |
376 if (attrDescriptor == null) { |
370 if (attrDescriptor == null) { |
377 attrDescriptor = validDescriptor(null); |
371 attrDescriptor = validDescriptor(null); |
378 } |
372 } |
379 return((Descriptor)attrDescriptor.clone()); |
373 return((Descriptor)attrDescriptor.clone()); |
409 */ |
403 */ |
410 |
404 |
411 @Override |
405 @Override |
412 public Object clone() |
406 public Object clone() |
413 { |
407 { |
414 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
408 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
415 MODELMBEAN_LOGGER.logp(Level.FINER, |
409 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
416 ModelMBeanAttributeInfo.class.getName(), |
|
417 "clone()", "Entry"); |
|
418 } |
410 } |
419 return(new ModelMBeanAttributeInfo(this)); |
411 return(new ModelMBeanAttributeInfo(this)); |
420 } |
412 } |
421 |
413 |
422 /** |
414 /** |
452 |
444 |
453 Descriptor clone; |
445 Descriptor clone; |
454 boolean defaulted = (in == null); |
446 boolean defaulted = (in == null); |
455 if (defaulted) { |
447 if (defaulted) { |
456 clone = new DescriptorSupport(); |
448 clone = new DescriptorSupport(); |
457 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); |
449 MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new."); |
458 } else { |
450 } else { |
459 clone = (Descriptor) in.clone(); |
451 clone = (Descriptor) in.clone(); |
460 } |
452 } |
461 |
453 |
462 //Setting defaults. |
454 //Setting defaults. |
463 if (defaulted && clone.getFieldValue("name")==null) { |
455 if (defaulted && clone.getFieldValue("name")==null) { |
464 clone.setField("name", this.getName()); |
456 clone.setField("name", this.getName()); |
465 MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName()); |
457 MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getName()); |
466 } |
458 } |
467 if (defaulted && clone.getFieldValue("descriptorType")==null) { |
459 if (defaulted && clone.getFieldValue("descriptorType")==null) { |
468 clone.setField("descriptorType", "attribute"); |
460 clone.setField("descriptorType", "attribute"); |
469 MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"attribute\""); |
461 MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"attribute\""); |
470 } |
462 } |
471 if (clone.getFieldValue("displayName") == null) { |
463 if (clone.getFieldValue("displayName") == null) { |
472 clone.setField("displayName",this.getName()); |
464 clone.setField("displayName",this.getName()); |
473 MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName()); |
465 MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getName()); |
474 } |
466 } |
475 |
467 |
476 //Checking validity |
468 //Checking validity |
477 if (!clone.isValid()) { |
469 if (!clone.isValid()) { |
478 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), |
470 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), |