From: Trevor S. <squ...@us...> - 2002-03-08 17:08:11
|
User: squirest Date: 02/03/08 09:04:43 Modified: src/main/javax/management/modelmbean ModelMBeanNotificationInfo.java Log: setDescriptor handling in constructors and clone impl Revision Changes Path 1.2 +31 -9 jmx/src/main/javax/management/modelmbean/ModelMBeanNotificationInfo.java Index: ModelMBeanNotificationInfo.java =================================================================== RCS file: /cvsroot/jboss/jmx/src/main/javax/management/modelmbean/ModelMBeanNotificationInfo.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ModelMBeanNotificationInfo.java 10 Dec 2001 17:24:35 -0000 1.1 +++ ModelMBeanNotificationInfo.java 8 Mar 2002 17:04:42 -0000 1.2 @@ -6,6 +6,8 @@ */ package javax.management.modelmbean; +import org.jboss.mx.modelmbean.ModelMBeanConstants; + import javax.management.MBeanNotificationInfo; import javax.management.Descriptor; import javax.management.DescriptorAccess; @@ -16,7 +18,7 @@ * @see javax.management.modelmbean.ModelMBeanAttributeInfo * * @author <a href="mailto:ju...@jb...">Juha Lindfors</a>. - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class ModelMBeanNotificationInfo extends MBeanNotificationInfo @@ -32,15 +34,18 @@ public ModelMBeanNotificationInfo(String[] notifTypes, String name, String description) { super(notifTypes, name, description); - // FIXME: create default descriptor + setDescriptor(createDefaultDescriptor()); } public ModelMBeanNotificationInfo(String[] notifTypes, String name, String description, Descriptor descriptor) { this(notifTypes, name, description); - setDescriptor(descriptor); + if (descriptor == null || !descriptor.isValid()) + setDescriptor(createDefaultDescriptor()); + else + setDescriptor(descriptor); } public ModelMBeanNotificationInfo(ModelMBeanNotificationInfo inInfo) @@ -58,17 +63,24 @@ public void setDescriptor(Descriptor inDescriptor) { - // FIXME: if null inDescriptor, create default descriptor - // FIXME: check validity of descriptor fields (name & descriptorType are required fields) - this.descriptor = descriptor; + if (inDescriptor == null) + inDescriptor = createDefaultDescriptor(); + + if (!inDescriptor.isValid()) + // FIXME: give more detailed error + throw new IllegalArgumentException("Invalid descriptor."); + + this.descriptor = inDescriptor; } // Cloneable implementation -------------------------------------- - public Object clone() + public Object clone() throws CloneNotSupportedException { - // FIXME: NYI - throw new Error("NYI"); + ModelMBeanNotificationInfo clone = (ModelMBeanNotificationInfo)super.clone(); + clone.descriptor = (Descriptor)this.descriptor.clone(); + + return clone; } // Object overrides ---------------------------------------------- @@ -77,6 +89,16 @@ // FIXME: human readable string return super.toString(); } + + // Private ------------------------------------------------------- + private Descriptor createDefaultDescriptor() + { + DescriptorSupport descr = new DescriptorSupport(); + descr.setField(ModelMBeanConstants.NAME, super.getName()); + descr.setField(ModelMBeanConstants.DESCRIPTOR_TYPE, ModelMBeanConstants.NOTIFICATION_DESCRIPTOR); + return descr; + } + } |