1 /* |
1 /* |
2 * Copyright (c) 2000, 2008, 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 |
36 import java.io.IOException; |
36 import java.io.IOException; |
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.security.AccessController; |
40 import java.security.AccessController; |
41 import java.util.logging.Level; |
41 import java.lang.System.Logger.Level; |
42 |
42 |
43 import javax.management.Descriptor; |
43 import javax.management.Descriptor; |
44 import javax.management.MBeanAttributeInfo; |
44 import javax.management.MBeanAttributeInfo; |
45 import javax.management.MBeanConstructorInfo; |
45 import javax.management.MBeanConstructorInfo; |
46 import javax.management.MBeanException; |
46 import javax.management.MBeanException; |
229 try { |
229 try { |
230 Descriptor mbeandescriptor = mbi.getMBeanDescriptor(); |
230 Descriptor mbeandescriptor = mbi.getMBeanDescriptor(); |
231 modelMBeanDescriptor = validDescriptor(mbeandescriptor); |
231 modelMBeanDescriptor = validDescriptor(mbeandescriptor); |
232 } catch (MBeanException mbe) { |
232 } catch (MBeanException mbe) { |
233 modelMBeanDescriptor = validDescriptor(null); |
233 modelMBeanDescriptor = validDescriptor(null); |
234 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
234 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
235 MODELMBEAN_LOGGER.logp(Level.FINER, |
235 MODELMBEAN_LOGGER.log(Level.TRACE, |
236 ModelMBeanInfoSupport.class.getName(), |
236 "ModelMBeanInfo(ModelMBeanInfo) " + |
237 "ModelMBeanInfo(ModelMBeanInfo)", |
|
238 "Could not get a valid modelMBeanDescriptor, " + |
237 "Could not get a valid modelMBeanDescriptor, " + |
239 "setting a default Descriptor"); |
238 "setting a default Descriptor"); |
240 } |
239 } |
241 } |
240 } |
242 |
241 |
243 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
242 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
244 MODELMBEAN_LOGGER.logp(Level.FINER, |
243 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
245 ModelMBeanInfoSupport.class.getName(), |
|
246 "ModelMBeanInfo(ModelMBeanInfo)", "Exit"); |
|
247 } |
244 } |
248 } |
245 } |
249 |
246 |
250 /** |
247 /** |
251 * Creates a ModelMBeanInfoSupport with the provided information, |
248 * Creates a ModelMBeanInfoSupport with the provided information, |
328 modelMBeanAttributes = attributes; |
325 modelMBeanAttributes = attributes; |
329 modelMBeanConstructors = constructors; |
326 modelMBeanConstructors = constructors; |
330 modelMBeanOperations = operations; |
327 modelMBeanOperations = operations; |
331 modelMBeanNotifications = notifications; |
328 modelMBeanNotifications = notifications; |
332 modelMBeanDescriptor = validDescriptor(mbeandescriptor); |
329 modelMBeanDescriptor = validDescriptor(mbeandescriptor); |
333 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
330 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
334 MODELMBEAN_LOGGER.logp(Level.FINER, |
331 MODELMBEAN_LOGGER.log(Level.TRACE, |
335 ModelMBeanInfoSupport.class.getName(), |
|
336 "ModelMBeanInfoSupport(String,String,ModelMBeanAttributeInfo[]," + |
332 "ModelMBeanInfoSupport(String,String,ModelMBeanAttributeInfo[]," + |
337 "ModelMBeanConstructorInfo[],ModelMBeanOperationInfo[]," + |
333 "ModelMBeanConstructorInfo[],ModelMBeanOperationInfo[]," + |
338 "ModelMBeanNotificationInfo[],Descriptor)", |
334 "ModelMBeanNotificationInfo[],Descriptor) " + |
339 "Exit"); |
335 "Exit"); |
340 } |
336 } |
341 } |
337 } |
342 |
338 |
343 private static final ModelMBeanAttributeInfo[] NO_ATTRIBUTES = |
339 private static final ModelMBeanAttributeInfo[] NO_ATTRIBUTES = |
365 } |
361 } |
366 |
362 |
367 |
363 |
368 public Descriptor[] getDescriptors(String inDescriptorType) |
364 public Descriptor[] getDescriptors(String inDescriptorType) |
369 throws MBeanException, RuntimeOperationsException { |
365 throws MBeanException, RuntimeOperationsException { |
370 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
366 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
371 MODELMBEAN_LOGGER.logp(Level.FINER, |
367 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
372 ModelMBeanInfoSupport.class.getName(), |
|
373 "getDescriptors(String)", "Entry"); |
|
374 } |
368 } |
375 |
369 |
376 if ((inDescriptorType == null) || (inDescriptorType.equals(""))) { |
370 if ((inDescriptorType == null) || (inDescriptorType.equals(""))) { |
377 inDescriptorType = "all"; |
371 inDescriptorType = "all"; |
378 } |
372 } |
472 new IllegalArgumentException("Descriptor Type is invalid"); |
466 new IllegalArgumentException("Descriptor Type is invalid"); |
473 final String msg = "Exception occurred trying to find"+ |
467 final String msg = "Exception occurred trying to find"+ |
474 " the descriptors of the MBean"; |
468 " the descriptors of the MBean"; |
475 throw new RuntimeOperationsException(iae,msg); |
469 throw new RuntimeOperationsException(iae,msg); |
476 } |
470 } |
477 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
471 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
478 MODELMBEAN_LOGGER.logp(Level.FINER, |
472 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
479 ModelMBeanInfoSupport.class.getName(), |
|
480 "getDescriptors(String)", "Exit"); |
|
481 } |
473 } |
482 |
474 |
483 return retList; |
475 return retList; |
484 } |
476 } |
485 |
477 |
486 |
478 |
487 public void setDescriptors(Descriptor[] inDescriptors) |
479 public void setDescriptors(Descriptor[] inDescriptors) |
488 throws MBeanException, RuntimeOperationsException { |
480 throws MBeanException, RuntimeOperationsException { |
489 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
481 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
490 MODELMBEAN_LOGGER.logp(Level.FINER, |
482 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
491 ModelMBeanInfoSupport.class.getName(), |
|
492 "setDescriptors(Descriptor[])", "Entry"); |
|
493 } |
483 } |
494 if (inDescriptors==null) { |
484 if (inDescriptors==null) { |
495 // throw RuntimeOperationsException - invalid descriptor |
485 // throw RuntimeOperationsException - invalid descriptor |
496 throw new RuntimeOperationsException( |
486 throw new RuntimeOperationsException( |
497 new IllegalArgumentException("Descriptor list is invalid"), |
487 new IllegalArgumentException("Descriptor list is invalid"), |
528 * @see #setDescriptor |
516 * @see #setDescriptor |
529 */ |
517 */ |
530 |
518 |
531 public Descriptor getDescriptor(String inDescriptorName) |
519 public Descriptor getDescriptor(String inDescriptorName) |
532 throws MBeanException, RuntimeOperationsException { |
520 throws MBeanException, RuntimeOperationsException { |
533 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
521 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
534 MODELMBEAN_LOGGER.logp(Level.FINER, |
522 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
535 ModelMBeanInfoSupport.class.getName(), |
|
536 "getDescriptor(String)", "Entry"); |
|
537 } |
523 } |
538 return(getDescriptor(inDescriptorName, null)); |
524 return(getDescriptor(inDescriptorName, null)); |
539 } |
525 } |
540 |
526 |
541 |
527 |
604 public void setDescriptor(Descriptor inDescriptor, |
590 public void setDescriptor(Descriptor inDescriptor, |
605 String inDescriptorType) |
591 String inDescriptorType) |
606 throws MBeanException, RuntimeOperationsException { |
592 throws MBeanException, RuntimeOperationsException { |
607 final String excMsg = |
593 final String excMsg = |
608 "Exception occurred trying to set the descriptors of the MBean"; |
594 "Exception occurred trying to set the descriptors of the MBean"; |
609 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
595 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
610 MODELMBEAN_LOGGER.logp(Level.FINER, |
596 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
611 ModelMBeanInfoSupport.class.getName(), |
|
612 "setDescriptor(Descriptor,String)", "Entry"); |
|
613 } |
597 } |
614 |
598 |
615 if (inDescriptor==null) { |
599 if (inDescriptor==null) { |
616 inDescriptor = new DescriptorSupport(); |
600 inDescriptor = new DescriptorSupport(); |
617 } |
601 } |
619 if ((inDescriptorType == null) || (inDescriptorType.equals(""))) { |
603 if ((inDescriptorType == null) || (inDescriptorType.equals(""))) { |
620 inDescriptorType = |
604 inDescriptorType = |
621 (String) inDescriptor.getFieldValue("descriptorType"); |
605 (String) inDescriptor.getFieldValue("descriptorType"); |
622 |
606 |
623 if (inDescriptorType == null) { |
607 if (inDescriptorType == null) { |
624 MODELMBEAN_LOGGER.logp(Level.FINER, |
608 MODELMBEAN_LOGGER.log(Level.TRACE, |
625 ModelMBeanInfoSupport.class.getName(), |
609 "descriptorType null in both String parameter " + |
626 "setDescriptor(Descriptor,String)", |
610 "and Descriptor, defaulting to "+ MMB); |
627 "descriptorType null in both String parameter and Descriptor, defaulting to "+ MMB); |
|
628 inDescriptorType = MMB; |
611 inDescriptorType = MMB; |
629 } |
612 } |
630 } |
613 } |
631 |
614 |
632 String inDescriptorName = |
615 String inDescriptorName = |
633 (String) inDescriptor.getFieldValue("name"); |
616 (String) inDescriptor.getFieldValue("name"); |
634 if (inDescriptorName == null) { |
617 if (inDescriptorName == null) { |
635 MODELMBEAN_LOGGER.logp(Level.FINER, |
618 MODELMBEAN_LOGGER.log(Level.TRACE, |
636 ModelMBeanInfoSupport.class.getName(), |
619 "descriptor name null, defaulting to " + |
637 "setDescriptor(Descriptor,String)", |
620 this.getClassName()); |
638 "descriptor name null, defaulting to "+ this.getClassName()); |
|
639 inDescriptorName = this.getClassName(); |
621 inDescriptorName = this.getClassName(); |
640 } |
622 } |
641 boolean found = false; |
623 boolean found = false; |
642 if (inDescriptorType.equalsIgnoreCase(MMB)) { |
624 if (inDescriptorType.equalsIgnoreCase(MMB)) { |
643 setMBeanDescriptor(inDescriptor); |
625 setMBeanDescriptor(inDescriptor); |
651 if (inDescriptorName.equals(attrList[i].getName())) { |
633 if (inDescriptorName.equals(attrList[i].getName())) { |
652 found = true; |
634 found = true; |
653 ModelMBeanAttributeInfo mmbai = |
635 ModelMBeanAttributeInfo mmbai = |
654 (ModelMBeanAttributeInfo) attrList[i]; |
636 (ModelMBeanAttributeInfo) attrList[i]; |
655 mmbai.setDescriptor(inDescriptor); |
637 mmbai.setDescriptor(inDescriptor); |
656 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
638 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
657 StringBuilder strb = new StringBuilder() |
639 StringBuilder strb = new StringBuilder() |
658 .append("Setting descriptor to ").append(inDescriptor) |
640 .append("Setting descriptor to ").append(inDescriptor) |
659 .append("\t\n local: AttributeInfo descriptor is ") |
641 .append("\t\n local: AttributeInfo descriptor is ") |
660 .append(mmbai.getDescriptor()) |
642 .append(mmbai.getDescriptor()) |
661 .append("\t\n modelMBeanInfo: AttributeInfo descriptor is ") |
643 .append("\t\n modelMBeanInfo: AttributeInfo descriptor is ") |
662 .append(this.getDescriptor(inDescriptorName,"attribute")); |
644 .append(this.getDescriptor(inDescriptorName,"attribute")); |
663 MODELMBEAN_LOGGER.logp(Level.FINER, |
645 MODELMBEAN_LOGGER.log(Level.TRACE, strb::toString); |
664 ModelMBeanInfoSupport.class.getName(), |
|
665 "setDescriptor(Descriptor,String)", |
|
666 strb.toString()); |
|
667 } |
646 } |
668 } |
647 } |
669 } |
648 } |
670 } else if (inDescriptorType.equalsIgnoreCase(OPER)) { |
649 } else if (inDescriptorType.equalsIgnoreCase(OPER)) { |
671 MBeanOperationInfo[] operList = modelMBeanOperations; |
650 MBeanOperationInfo[] operList = modelMBeanOperations; |
718 new IllegalArgumentException("Descriptor name is invalid: " + |
697 new IllegalArgumentException("Descriptor name is invalid: " + |
719 "type=" + inDescriptorType + |
698 "type=" + inDescriptorType + |
720 "; name=" + inDescriptorName); |
699 "; name=" + inDescriptorName); |
721 throw new RuntimeOperationsException(iae, excMsg); |
700 throw new RuntimeOperationsException(iae, excMsg); |
722 } |
701 } |
723 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
702 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
724 MODELMBEAN_LOGGER.logp(Level.FINER, |
703 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
725 ModelMBeanInfoSupport.class.getName(), |
|
726 "setDescriptor(Descriptor,String)", "Exit"); |
|
727 } |
704 } |
728 |
705 |
729 } |
706 } |
730 |
707 |
731 |
708 |
732 public ModelMBeanAttributeInfo getAttribute(String inName) |
709 public ModelMBeanAttributeInfo getAttribute(String inName) |
733 throws MBeanException, RuntimeOperationsException { |
710 throws MBeanException, RuntimeOperationsException { |
734 ModelMBeanAttributeInfo retInfo = null; |
711 ModelMBeanAttributeInfo retInfo = null; |
735 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
712 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
736 MODELMBEAN_LOGGER.logp(Level.FINER, |
713 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
737 ModelMBeanInfoSupport.class.getName(), |
|
738 "getAttribute(String)", "Entry"); |
|
739 } |
714 } |
740 if (inName == null) { |
715 if (inName == null) { |
741 throw new RuntimeOperationsException( |
716 throw new RuntimeOperationsException( |
742 new IllegalArgumentException("Attribute Name is null"), |
717 new IllegalArgumentException("Attribute Name is null"), |
743 "Exception occurred trying to get the " + |
718 "Exception occurred trying to get the " + |
746 MBeanAttributeInfo[] attrList = modelMBeanAttributes; |
721 MBeanAttributeInfo[] attrList = modelMBeanAttributes; |
747 int numAttrs = 0; |
722 int numAttrs = 0; |
748 if (attrList != null) numAttrs = attrList.length; |
723 if (attrList != null) numAttrs = attrList.length; |
749 |
724 |
750 for (int i=0; (i < numAttrs) && (retInfo == null); i++) { |
725 for (int i=0; (i < numAttrs) && (retInfo == null); i++) { |
751 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
726 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
752 final StringBuilder strb = new StringBuilder() |
727 final StringBuilder strb = new StringBuilder() |
753 .append("\t\n this.getAttributes() MBeanAttributeInfo Array ") |
728 .append("\t\n this.getAttributes() MBeanAttributeInfo Array ") |
754 .append(i).append(":") |
729 .append(i).append(":") |
755 .append(((ModelMBeanAttributeInfo)attrList[i]).getDescriptor()) |
730 .append(((ModelMBeanAttributeInfo)attrList[i]).getDescriptor()) |
756 .append("\t\n this.modelMBeanAttributes MBeanAttributeInfo Array ") |
731 .append("\t\n this.modelMBeanAttributes MBeanAttributeInfo Array ") |
757 .append(i).append(":") |
732 .append(i).append(":") |
758 .append(((ModelMBeanAttributeInfo)modelMBeanAttributes[i]).getDescriptor()); |
733 .append(((ModelMBeanAttributeInfo)modelMBeanAttributes[i]).getDescriptor()); |
759 MODELMBEAN_LOGGER.logp(Level.FINER, |
734 MODELMBEAN_LOGGER.log(Level.TRACE, strb::toString); |
760 ModelMBeanInfoSupport.class.getName(), |
|
761 "getAttribute(String)", strb.toString()); |
|
762 } |
735 } |
763 if (inName.equals(attrList[i].getName())) { |
736 if (inName.equals(attrList[i].getName())) { |
764 retInfo = ((ModelMBeanAttributeInfo)attrList[i].clone()); |
737 retInfo = ((ModelMBeanAttributeInfo)attrList[i].clone()); |
765 } |
738 } |
766 } |
739 } |
767 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
740 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
768 MODELMBEAN_LOGGER.logp(Level.FINER, |
741 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
769 ModelMBeanInfoSupport.class.getName(), |
|
770 "getAttribute(String)", "Exit"); |
|
771 } |
742 } |
772 |
743 |
773 return retInfo; |
744 return retInfo; |
774 } |
745 } |
775 |
746 |
776 |
747 |
777 |
748 |
778 public ModelMBeanOperationInfo getOperation(String inName) |
749 public ModelMBeanOperationInfo getOperation(String inName) |
779 throws MBeanException, RuntimeOperationsException { |
750 throws MBeanException, RuntimeOperationsException { |
780 ModelMBeanOperationInfo retInfo = null; |
751 ModelMBeanOperationInfo retInfo = null; |
781 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
752 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
782 MODELMBEAN_LOGGER.logp(Level.FINER, |
753 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
783 ModelMBeanInfoSupport.class.getName(), |
|
784 "getOperation(String)", "Entry"); |
|
785 } |
754 } |
786 if (inName == null) { |
755 if (inName == null) { |
787 throw new RuntimeOperationsException( |
756 throw new RuntimeOperationsException( |
788 new IllegalArgumentException("inName is null"), |
757 new IllegalArgumentException("inName is null"), |
789 "Exception occurred trying to get the " + |
758 "Exception occurred trying to get the " + |
796 for (int i=0; (i < numOpers) && (retInfo == null); i++) { |
765 for (int i=0; (i < numOpers) && (retInfo == null); i++) { |
797 if (inName.equals(operList[i].getName())) { |
766 if (inName.equals(operList[i].getName())) { |
798 retInfo = ((ModelMBeanOperationInfo) operList[i].clone()); |
767 retInfo = ((ModelMBeanOperationInfo) operList[i].clone()); |
799 } |
768 } |
800 } |
769 } |
801 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
770 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
802 MODELMBEAN_LOGGER.logp(Level.FINER, |
771 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
803 ModelMBeanInfoSupport.class.getName(), |
|
804 "getOperation(String)", "Exit"); |
|
805 } |
772 } |
806 |
773 |
807 return retInfo; |
774 return retInfo; |
808 } |
775 } |
809 |
776 |
822 */ |
789 */ |
823 |
790 |
824 public ModelMBeanConstructorInfo getConstructor(String inName) |
791 public ModelMBeanConstructorInfo getConstructor(String inName) |
825 throws MBeanException, RuntimeOperationsException { |
792 throws MBeanException, RuntimeOperationsException { |
826 ModelMBeanConstructorInfo retInfo = null; |
793 ModelMBeanConstructorInfo retInfo = null; |
827 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
794 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
828 MODELMBEAN_LOGGER.logp(Level.FINER, |
795 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
829 ModelMBeanInfoSupport.class.getName(), |
|
830 "getConstructor(String)", "Entry"); |
|
831 } |
796 } |
832 if (inName == null) { |
797 if (inName == null) { |
833 throw new RuntimeOperationsException( |
798 throw new RuntimeOperationsException( |
834 new IllegalArgumentException("Constructor name is null"), |
799 new IllegalArgumentException("Constructor name is null"), |
835 "Exception occurred trying to get the " + |
800 "Exception occurred trying to get the " + |
842 for (int i=0; (i < numCons) && (retInfo == null); i++) { |
807 for (int i=0; (i < numCons) && (retInfo == null); i++) { |
843 if (inName.equals(consList[i].getName())) { |
808 if (inName.equals(consList[i].getName())) { |
844 retInfo = ((ModelMBeanConstructorInfo) consList[i].clone()); |
809 retInfo = ((ModelMBeanConstructorInfo) consList[i].clone()); |
845 } |
810 } |
846 } |
811 } |
847 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
812 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
848 MODELMBEAN_LOGGER.logp(Level.FINER, |
813 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
849 ModelMBeanInfoSupport.class.getName(), |
|
850 "getConstructor(String)", "Exit"); |
|
851 } |
814 } |
852 |
815 |
853 return retInfo; |
816 return retInfo; |
854 } |
817 } |
855 |
818 |
856 |
819 |
857 public ModelMBeanNotificationInfo getNotification(String inName) |
820 public ModelMBeanNotificationInfo getNotification(String inName) |
858 throws MBeanException, RuntimeOperationsException { |
821 throws MBeanException, RuntimeOperationsException { |
859 ModelMBeanNotificationInfo retInfo = null; |
822 ModelMBeanNotificationInfo retInfo = null; |
860 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
823 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
861 MODELMBEAN_LOGGER.logp(Level.FINER, |
824 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
862 ModelMBeanInfoSupport.class.getName(), |
|
863 "getNotification(String)", "Entry"); |
|
864 } |
825 } |
865 if (inName == null) { |
826 if (inName == null) { |
866 throw new RuntimeOperationsException( |
827 throw new RuntimeOperationsException( |
867 new IllegalArgumentException("Notification name is null"), |
828 new IllegalArgumentException("Notification name is null"), |
868 "Exception occurred trying to get the " + |
829 "Exception occurred trying to get the " + |
875 for (int i=0; (i < numNotifs) && (retInfo == null); i++) { |
836 for (int i=0; (i < numNotifs) && (retInfo == null); i++) { |
876 if (inName.equals(notifList[i].getName())) { |
837 if (inName.equals(notifList[i].getName())) { |
877 retInfo = ((ModelMBeanNotificationInfo) notifList[i].clone()); |
838 retInfo = ((ModelMBeanNotificationInfo) notifList[i].clone()); |
878 } |
839 } |
879 } |
840 } |
880 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
841 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
881 MODELMBEAN_LOGGER.logp(Level.FINER, |
842 MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); |
882 ModelMBeanInfoSupport.class.getName(), |
|
883 "getNotification(String)", "Exit"); |
|
884 } |
843 } |
885 |
844 |
886 return retInfo; |
845 return retInfo; |
887 } |
846 } |
888 |
847 |
899 public Descriptor getMBeanDescriptor() throws MBeanException { |
858 public Descriptor getMBeanDescriptor() throws MBeanException { |
900 return getMBeanDescriptorNoException(); |
859 return getMBeanDescriptorNoException(); |
901 } |
860 } |
902 |
861 |
903 private Descriptor getMBeanDescriptorNoException() { |
862 private Descriptor getMBeanDescriptorNoException() { |
904 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
863 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
905 MODELMBEAN_LOGGER.logp(Level.FINER, |
864 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
906 ModelMBeanInfoSupport.class.getName(), |
|
907 "getMBeanDescriptorNoException()", "Entry"); |
|
908 } |
865 } |
909 |
866 |
910 if (modelMBeanDescriptor == null) |
867 if (modelMBeanDescriptor == null) |
911 modelMBeanDescriptor = validDescriptor(null); |
868 modelMBeanDescriptor = validDescriptor(null); |
912 |
869 |
913 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
870 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
914 MODELMBEAN_LOGGER.logp(Level.FINER, |
871 MODELMBEAN_LOGGER.log(Level.TRACE, |
915 ModelMBeanInfoSupport.class.getName(), |
|
916 "getMBeanDescriptorNoException()", |
|
917 "Exit, returning: " + modelMBeanDescriptor); |
872 "Exit, returning: " + modelMBeanDescriptor); |
918 } |
873 } |
919 return (Descriptor) modelMBeanDescriptor.clone(); |
874 return (Descriptor) modelMBeanDescriptor.clone(); |
920 } |
875 } |
921 |
876 |
922 public void setMBeanDescriptor(Descriptor inMBeanDescriptor) |
877 public void setMBeanDescriptor(Descriptor inMBeanDescriptor) |
923 throws MBeanException, RuntimeOperationsException { |
878 throws MBeanException, RuntimeOperationsException { |
924 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { |
879 if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { |
925 MODELMBEAN_LOGGER.logp(Level.FINER, |
880 MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); |
926 ModelMBeanInfoSupport.class.getName(), |
|
927 "setMBeanDescriptor(Descriptor)", "Entry"); |
|
928 } |
881 } |
929 modelMBeanDescriptor = validDescriptor(inMBeanDescriptor); |
882 modelMBeanDescriptor = validDescriptor(inMBeanDescriptor); |
930 } |
883 } |
931 |
884 |
932 |
885 |
946 private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { |
899 private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException { |
947 Descriptor clone; |
900 Descriptor clone; |
948 boolean defaulted = (in == null); |
901 boolean defaulted = (in == null); |
949 if (defaulted) { |
902 if (defaulted) { |
950 clone = new DescriptorSupport(); |
903 clone = new DescriptorSupport(); |
951 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new."); |
904 MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new."); |
952 } else { |
905 } else { |
953 clone = (Descriptor) in.clone(); |
906 clone = (Descriptor) in.clone(); |
954 } |
907 } |
955 |
908 |
956 //Setting defaults. |
909 //Setting defaults. |
957 if (defaulted && clone.getFieldValue("name")==null) { |
910 if (defaulted && clone.getFieldValue("name")==null) { |
958 clone.setField("name", this.getClassName()); |
911 clone.setField("name", this.getClassName()); |
959 MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getClassName()); |
912 MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getClassName()); |
960 } |
913 } |
961 if (defaulted && clone.getFieldValue("descriptorType")==null) { |
914 if (defaulted && clone.getFieldValue("descriptorType")==null) { |
962 clone.setField("descriptorType", MMB); |
915 clone.setField("descriptorType", MMB); |
963 MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"" + MMB + "\""); |
916 MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"" + MMB + "\""); |
964 } |
917 } |
965 if (clone.getFieldValue("displayName") == null) { |
918 if (clone.getFieldValue("displayName") == null) { |
966 clone.setField("displayName",this.getClassName()); |
919 clone.setField("displayName",this.getClassName()); |
967 MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getClassName()); |
920 MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getClassName()); |
968 } |
921 } |
969 if (clone.getFieldValue("persistPolicy") == null) { |
922 if (clone.getFieldValue("persistPolicy") == null) { |
970 clone.setField("persistPolicy","never"); |
923 clone.setField("persistPolicy","never"); |
971 MODELMBEAN_LOGGER.finer("Defaulting Descriptor persistPolicy to \"never\""); |
924 MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor persistPolicy to \"never\""); |
972 } |
925 } |
973 if (clone.getFieldValue("log") == null) { |
926 if (clone.getFieldValue("log") == null) { |
974 clone.setField("log","F"); |
927 clone.setField("log","F"); |
975 MODELMBEAN_LOGGER.finer("Defaulting Descriptor \"log\" field to \"F\""); |
928 MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor \"log\" field to \"F\""); |
976 } |
929 } |
977 if (clone.getFieldValue("visibility") == null) { |
930 if (clone.getFieldValue("visibility") == null) { |
978 clone.setField("visibility","1"); |
931 clone.setField("visibility","1"); |
979 MODELMBEAN_LOGGER.finer("Defaulting Descriptor visibility to 1"); |
932 MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor visibility to 1"); |
980 } |
933 } |
981 |
934 |
982 //Checking validity |
935 //Checking validity |
983 if (!clone.isValid()) { |
936 if (!clone.isValid()) { |
984 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), |
937 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), |