User: squirest Date: 01/12/08 14:20:06 Modified: src/main/javax/management MBeanInfo.java Log: changed constructor to replace null array args with zero size arrays implemented clone() formatted code Revision Changes Path 1.2 +66 -23 jmx/src/main/javax/management/MBeanInfo.java Index: MBeanInfo.java =================================================================== RCS file: /cvsroot/jboss/jmx/src/main/javax/management/MBeanInfo.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MBeanInfo.java 2001/12/03 02:01:30 1.1 +++ MBeanInfo.java 2001/12/08 22:20:05 1.2 @@ -3,58 +3,101 @@ */ package javax.management; -public class MBeanInfo implements Cloneable, java.io.Serializable { - +public class MBeanInfo implements Cloneable, java.io.Serializable +{ protected String className = null; protected String description = null; protected MBeanAttributeInfo[] attributes = null; protected MBeanConstructorInfo[] constructors = null; protected MBeanOperationInfo[] operations = null; protected MBeanNotificationInfo[] notifications = null; - + public MBeanInfo(java.lang.String className, java.lang.String description, MBeanAttributeInfo[] attributes, MBeanConstructorInfo[] constructors, MBeanOperationInfo[] operations, - MBeanNotificationInfo[] notifications) { + MBeanNotificationInfo[] notifications) + { this.className = className; this.description = description; - this.attributes = attributes; - this.constructors = constructors; - this.operations = operations; - this.notifications = notifications; - } - - public java.lang.Object clone() throws CloneNotSupportedException { - MBeanInfo clone = (MBeanInfo)super.clone(); - - // FIXME - throw new CloneNotSupportedException("NYI"); + this.attributes = (null == attributes) ? new MBeanAttributeInfo[0]: attributes; + this.constructors = (null == constructors) ? new MBeanConstructorInfo[0] : constructors; + this.operations = (null == operations) ? new MBeanOperationInfo[0] : operations; + this.notifications = (null == notifications) ? new MBeanNotificationInfo[0] : notifications; + } + + public java.lang.Object clone() throws CloneNotSupportedException + { + MBeanInfo clone = (MBeanInfo) super.clone(); + + clone.className = className; + clone.description = description; + + /** + * Clones of the internal arrays assumes that constructor replaces null args + * with zero sized arrays. + */ + + int asize = attributes.length; + clone.attributes = new MBeanAttributeInfo[asize]; + for (int i = 0; i < asize; i++) + { + clone.attributes[i] = (MBeanAttributeInfo) this.attributes[i].clone(); + } + + asize = constructors.length; + clone.constructors = new MBeanConstructorInfo[asize]; + for (int i = 0; i < asize; i++) + { + clone.constructors[i] = (MBeanConstructorInfo) this.constructors[i].clone(); + } + + asize = operations.length; + clone.operations = new MBeanOperationInfo[asize]; + for (int i = 0; i < asize; i++) + { + clone.operations[i] = (MBeanOperationInfo) this.operations[i].clone(); + } + + asize = notifications.length; + clone.notifications = new MBeanNotificationInfo[asize]; + for (int i = 0; i < asize; i++) + { + clone.notifications[i] = (MBeanNotificationInfo) this.notifications[i].clone(); + } + + return clone; } - public java.lang.String getClassName() { + public java.lang.String getClassName() + { return className; } - - public java.lang.String getDescription() { + + public java.lang.String getDescription() + { return description; } - public MBeanAttributeInfo[] getAttributes() { + public MBeanAttributeInfo[] getAttributes() + { return attributes; } - public MBeanOperationInfo[] getOperations() { + public MBeanOperationInfo[] getOperations() + { return operations; } - public MBeanConstructorInfo[] getConstructors() { + + public MBeanConstructorInfo[] getConstructors() + { return constructors; } - public MBeanNotificationInfo[] getNotifications() { + public MBeanNotificationInfo[] getNotifications() + { return notifications; } - }
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development