User: squirest
  Date: 01/12/11 13:19:47

  Modified:    src/main/javax/management MBeanConstructorInfo.java
                        MBeanInfo.java MBeanNotificationInfo.java
                        MBeanOperationInfo.java MBeanParameterInfo.java
  Log:
  changed constructors to shallow-clone input arrays
  changed getXXX() methods to return shallow array clones
  formatting and prettying
  
  Revision  Changes    Path
  1.3       +39 -19    jmx/src/main/javax/management/MBeanConstructorInfo.java
  
  Index: MBeanConstructorInfo.java
  ===================================================================
  RCS file: /cvsroot/jboss/jmx/src/main/javax/management/MBeanConstructorInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MBeanConstructorInfo.java 2001/12/05 14:12:46     1.2
  +++ MBeanConstructorInfo.java 2001/12/11 21:19:47     1.3
  @@ -1,44 +1,64 @@
   /*
  - * LGPL
  + * JBoss, the OpenSource J2EE webOS
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
    */
   package javax.management;
   
  +/**
  + * Describes a constructor exposed by an MBean
  + *
  + * This implementation protects its immutability by taking shallow clones of all 
arrays
  + * supplied in constructors and by returning shallow array clones in getXXX() 
methods.
  + *
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Juha Lindfors</a>.
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Trevor Squires</a>.
  + *
  + * @version $Revision: 1.3 $
  + */
   public class MBeanConstructorInfo extends MBeanFeatureInfo
  -   implements java.io.Serializable, Cloneable {
  +   implements java.io.Serializable, Cloneable
  +{
   
  +   // Attributes ----------------------------------------------------
      protected MBeanParameterInfo[] signature = null;
  -   
  +
  +   // Constructors --------------------------------------------------
      public MBeanConstructorInfo(java.lang.String description,
  -                               java.lang.reflect.Constructor constructor) {
  +                               java.lang.reflect.Constructor constructor)
  +   {
         super(constructor.getName(), description);
   
         Class[] sign = constructor.getParameterTypes();
         signature = new MBeanParameterInfo[sign.length];
  -      
  -      for (int i = 0; i < sign.length; ++i) {
  +
  +      for (int i = 0; i < sign.length; ++i)
  +      {
            String name = sign[i].getName();
            signature[i] = new MBeanParameterInfo(name, name, "MBean Constructor 
Parameter.");
         }
  -
      }
  -   
  +
      public MBeanConstructorInfo(java.lang.String name,
                                  java.lang.String description,
  -                               MBeanParameterInfo[] signature) {
  +                               MBeanParameterInfo[] signature)
  +   {
         super(name, description);
  -      this.signature = signature;
  +      this.signature = (null == signature) ? new MBeanParameterInfo[0] : 
(MBeanParameterInfo[]) signature.clone();
      }
   
  -   public java.lang.Object clone() throws CloneNotSupportedException {
  -      MBeanConstructorInfo clone = (MBeanConstructorInfo)super.clone();
  -      clone.signature = getSignature();   
  -      return clone;
  +   // Public --------------------------------------------------------
  +   public MBeanParameterInfo[] getSignature()
  +   {
  +      return (MBeanParameterInfo[]) signature.clone();
      }
   
  -   public MBeanParameterInfo[] getSignature() {
  -      return signature;
  +   // Cloneable implementation --------------------------------------
  +   public java.lang.Object clone() throws CloneNotSupportedException
  +   {
  +      MBeanConstructorInfo clone = (MBeanConstructorInfo) super.clone();
  +      clone.signature = getSignature();
  +      return clone;
      }
  -
  -
  -
   }
  
  
  
  1.4       +20 -47    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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MBeanInfo.java    2001/12/10 17:20:04     1.3
  +++ MBeanInfo.java    2001/12/11 21:19:47     1.4
  @@ -9,18 +9,21 @@
   /**
    * Describes an MBeans' management interface.
    *
  + * This implementation protects its immutability by taking shallow clones of all 
arrays
  + * supplied in constructors and by returning shallow array clones in getXXX() 
methods.
  + *
    * @see javax.management.MBeanServer
    *
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Juha Lindfors</a>.
    * @author  <a href="mailto:[EMAIL PROTECTED]";>Trevor Squires</a>.
  + *
  + * @version $Revision: 1.4 $
    *
  - * @version $Revision: 1.3 $
  - *   
    */
   public class MBeanInfo
      implements Cloneable, java.io.Serializable
   {
  -   
  +
      // Attributes ----------------------------------------------------
      protected String className = null;
      protected String description = null;
  @@ -38,10 +41,10 @@
      {
         this.className = className;
         this.description = description;
  -      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;
  +      this.attributes = (null == attributes) ? new MBeanAttributeInfo[0] : 
(MBeanAttributeInfo[]) attributes.clone();
  +      this.constructors = (null == constructors) ? new MBeanConstructorInfo[0] : 
(MBeanConstructorInfo[]) constructors.clone();
  +      this.operations = (null == operations) ? new MBeanOperationInfo[0] : 
(MBeanOperationInfo[]) operations.clone();
  +      this.notifications = (null == notifications) ? new MBeanNotificationInfo[0] : 
(MBeanNotificationInfo[]) notifications.clone();
      }
   
      // Public --------------------------------------------------------
  @@ -57,67 +60,37 @@
   
      public MBeanAttributeInfo[] getAttributes()
      {
  -      return attributes;
  +      return (MBeanAttributeInfo[]) attributes.clone();
      }
   
      public MBeanOperationInfo[] getOperations()
      {
  -      return operations;
  +      return (MBeanOperationInfo[]) operations.clone();
      }
   
      public MBeanConstructorInfo[] getConstructors()
      {
  -      return constructors;
  +      return (MBeanConstructorInfo[]) constructors.clone();
      }
   
      public MBeanNotificationInfo[] getNotifications()
      {
  -      return notifications;
  +      return (MBeanNotificationInfo[]) notifications.clone();
      }
  -   
  +
      // Cloneable implementation --------------------------------------
      public Object clone() throws CloneNotSupportedException
      {
         MBeanInfo clone = (MBeanInfo) super.clone();
   
  -      clone.className = className;
  -      clone.description = description;
  +      clone.className = getClassName();
  +      clone.description = getDescription();
   
  -      /**
  -       * 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();
  -      }
  +      clone.attributes = getAttributes();
  +      clone.constructors = getConstructors();
  +      clone.operations = getOperations();
  +      clone.notifications = getNotifications();
   
         return clone;
      }
  -   
   }
  -
  
  
  
  1.2       +31 -13    jmx/src/main/javax/management/MBeanNotificationInfo.java
  
  Index: MBeanNotificationInfo.java
  ===================================================================
  RCS file: /cvsroot/jboss/jmx/src/main/javax/management/MBeanNotificationInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MBeanNotificationInfo.java        2001/12/03 02:01:30     1.1
  +++ MBeanNotificationInfo.java        2001/12/11 21:19:47     1.2
  @@ -1,32 +1,50 @@
   /*
  - * LGPL
  + * JBoss, the OpenSource J2EE webOS
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
    */
   package javax.management;
   
  +/**
  + * Describes a notification emitted by an MBean
  + *
  + * This implementation protects its immutability by taking shallow clones of all 
arrays
  + * supplied in constructors and by returning shallow array clones in getXXX() 
methods.
  + *
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Juha Lindfors</a>.
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Trevor Squires</a>.
  + *
  + * @version $Revision: 1.2 $
  + */
   public class MBeanNotificationInfo extends MBeanFeatureInfo
  -   implements Cloneable, java.io.Serializable {
  +   implements Cloneable, java.io.Serializable
  +{
   
  +   // Attributes ----------------------------------------------------
      protected String[] notifsType = null;
   
  +   // Constructors --------------------------------------------------
      public MBeanNotificationInfo(String[] notifsType,
                                   String name,
  -                                String description) {
  -
  +                                String description)
  +   {
         super(name, description);
  -      this.notifsType = notifsType;
  -   }
  -
  -   public Object clone() throws CloneNotSupportedException {
  -      MBeanNotificationInfo clone = (MBeanNotificationInfo)super.clone();
  -      clone.notifsType = getNotifTypes();
  -
  -      return clone;
  +      this.notifsType = (null == notifsType) ? new String[0] : (String[]) 
notifsType.clone();
      }
   
  +   // Public -------------------------------------------------------
      public String[] getNotifTypes()
      {
  -      return notifsType;
  +      return (String[]) notifsType.clone();
      }
   
  +   // CLoneable implementation -------------------------------------
  +   public Object clone() throws CloneNotSupportedException
  +   {
  +      MBeanNotificationInfo clone = (MBeanNotificationInfo) super.clone();
  +      clone.notifsType = getNotifTypes();
   
  +      return clone;
  +   }
   }
  
  
  
  1.3       +48 -25    jmx/src/main/javax/management/MBeanOperationInfo.java
  
  Index: MBeanOperationInfo.java
  ===================================================================
  RCS file: /cvsroot/jboss/jmx/src/main/javax/management/MBeanOperationInfo.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MBeanOperationInfo.java   2001/12/05 14:12:46     1.2
  +++ MBeanOperationInfo.java   2001/12/11 21:19:47     1.3
  @@ -1,64 +1,87 @@
   /*
  - * LGPL
  + * JBoss, the OpenSource J2EE webOS
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
    */
   package javax.management;
   
  +/**
  + * Describes an operation exposed by an MBean
  + *
  + * This implementation protects its immutability by taking shallow clones of all 
arrays
  + * supplied in constructors and by returning shallow array clones in getXXX() 
methods.
  + *
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Juha Lindfors</a>.
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Trevor Squires</a>.
  + *
  + * @version $Revision: 1.3 $
  + */
   public class MBeanOperationInfo extends MBeanFeatureInfo
  -   implements java.io.Serializable, Cloneable {
  -
  +   implements java.io.Serializable, Cloneable
  +{
   
  +   // Attributes ----------------------------------------------------
      public static final int INFO        = 0x1234;
      public static final int ACTION      = 0x332;
      public static final int ACTION_INFO = 0xabcd;
      public static final int UNKNOWN     = 0xdead;
   
  -
      protected int impact = UNKNOWN;
      protected MBeanParameterInfo[] signature = null;
      protected String returnType = null;
  -   
  +
  +   // Constructors --------------------------------------------------
      public MBeanOperationInfo(java.lang.String description,
  -                             java.lang.reflect.Method method) {
  +                             java.lang.reflect.Method method)
  +   {
         super(method.getName(), description);
         this.returnType = method.getReturnType().getName();
  -      
  +
         Class[] sign = method.getParameterTypes();
         signature = new MBeanParameterInfo[sign.length];
  -      
  -      for (int i = 0; i < sign.length; ++i) {
  +
  +      for (int i = 0; i < sign.length; ++i)
  +      {
            String name = sign[i].getName();
            signature[i] = new MBeanParameterInfo(name, name, "MBean Operation 
Parameter.");
         }
      }
  -   
  +
      public MBeanOperationInfo(String name, String description,
                                MBeanParameterInfo[] signature,
  -                             String returnType, int impact) {
  +                             String returnType, int impact)
  +   {
         super(name, description);
  -      this.signature = signature;
  +      this.signature = (null == signature) ? new MBeanParameterInfo[0] : 
(MBeanParameterInfo[]) signature.clone();
         this.returnType = returnType;
         this.impact = impact;
      }
   
  -   public java.lang.Object clone() throws CloneNotSupportedException {
  -      MBeanOperationInfo clone = (MBeanOperationInfo)super.clone();
  -      clone.signature = getSignature();
  -      clone.returnType = getReturnType();
  -      clone.impact = getImpact();
  -      
  -      return clone;
  -   }
  -
  -   public String getReturnType() {
  +   // Public --------------------------------------------------------
  +   public String getReturnType()
  +   {
         return returnType;
      }
   
  -   public MBeanParameterInfo[] getSignature() {
  -      return signature;
  +   public MBeanParameterInfo[] getSignature()
  +   {
  +      return (MBeanParameterInfo[]) signature.clone();
      }
   
  -   public int getImpact() {
  +   public int getImpact()
  +   {
         return impact;
      }
   
  +   // Cloneable implementation --------------------------------------
  +   public java.lang.Object clone() throws CloneNotSupportedException
  +   {
  +      MBeanOperationInfo clone = (MBeanOperationInfo) super.clone();
  +      clone.signature = getSignature();
  +      clone.returnType = getReturnType();
  +      clone.impact = getImpact();
  +
  +      return clone;
  +   }
   }
  
  
  
  1.2       +28 -15    jmx/src/main/javax/management/MBeanParameterInfo.java
  
  Index: MBeanParameterInfo.java
  ===================================================================
  RCS file: /cvsroot/jboss/jmx/src/main/javax/management/MBeanParameterInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MBeanParameterInfo.java   2001/12/03 02:01:30     1.1
  +++ MBeanParameterInfo.java   2001/12/11 21:19:47     1.2
  @@ -1,31 +1,44 @@
   /*
  - * LGPL
  + * JBoss, the OpenSource J2EE webOS
  + *
  + * Distributable under LGPL license.
  + * See terms of license at gnu.org.
    */
   package javax.management;
   
  -public class MBeanParameterInfo extends MBeanFeatureInfo implements 
java.io.Serializable, Cloneable {
  -
  +/**
  + * Describes an argument of an operation exposed by an MBean
  + *
  + * @author  <a href="mailto:[EMAIL PROTECTED]";>Juha Lindfors</a>.
  + *
  + * @version $Revision: 1.2 $
  + */
  +public class MBeanParameterInfo extends MBeanFeatureInfo
  +   implements java.io.Serializable, Cloneable
  +{
  +   // Attributes ----------------------------------------------------
      protected String type = null;
  -   
  +
  +   // Constructors --------------------------------------------------
      public MBeanParameterInfo(java.lang.String name,
                                java.lang.String type,
  -                             java.lang.String description) {
  +                             java.lang.String description)
  +   {
         super(name, description);
         this.type = type;
      }
   
  -
  +   // Public --------------------------------------------------------
  +   public java.lang.String getType()
  +   {
  +      return type;
  +   }
   
  -   public java.lang.Object clone() throws CloneNotSupportedException {
  -      MBeanParameterInfo clone = (MBeanParameterInfo)super.clone();
  +   // Cloneable implementation --------------------------------------
  +   public java.lang.Object clone() throws CloneNotSupportedException
  +   {
  +      MBeanParameterInfo clone = (MBeanParameterInfo) super.clone();
         clone.type = getType();
         return clone;
      }
  -
  -   public java.lang.String getType() {
  -      return type;
  -   }
  -
  -
   }
  -
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to