geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx GBeanMBeanAttribute.java
Date Thu, 29 Jan 2004 06:03:35 GMT
dain        2004/01/28 22:03:35

  Modified:    modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        GBeanMBeanAttribute.java
  Log:
  Intialize primitive values to zero equivalent
  
  Revision  Changes    Path
  1.5       +31 -1     incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanAttribute.java
  
  Index: GBeanMBeanAttribute.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanAttribute.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- GBeanMBeanAttribute.java	20 Jan 2004 06:09:42 -0000	1.4
  +++ GBeanMBeanAttribute.java	29 Jan 2004 06:03:35 -0000	1.5
  @@ -226,6 +226,28 @@
                   readable,
                   writable,
                   isIs);
  +
  +        if(persistent && type.isPrimitive()) {
  +            if (type == Boolean.TYPE) {
  +                persistentValue = Boolean.FALSE;
  +            } else if (type == Character.TYPE) {
  +                persistentValue = new Character((char) 0);
  +            } else if (type == Byte.TYPE) {
  +                persistentValue = new Byte((byte) 0);
  +            } else if (type == Short.TYPE) {
  +                persistentValue = new Short((short) 0);
  +            } else if (type == Integer.TYPE) {
  +                persistentValue = new Integer(0);
  +            } else if (type == Long.TYPE) {
  +                persistentValue = new Long(0);
  +            } else if (type == Float.TYPE) {
  +                persistentValue = new Float(0);
  +            } else if (type == Double.TYPE) {
  +                persistentValue = new Double(0);
  +            } else {
  +                throw new IllegalArgumentException("Unknown primitive type: " + type.getName());
  +            }
  +        }
       }
   
       public String getName() {
  @@ -312,6 +334,10 @@
       public void setValue(Object value) throws ReflectionException {
           if (gmbean.isOffline()) {
               if (persistent) {
  +                if(value == null && type.isPrimitive()) {
  +                    throw new IllegalArgumentException("Can not assign null to a primitive
attribute");
  +                }
  +                // @todo actually check type
                   this.persistentValue = value;
               } else {
                   throw new IllegalStateException("Only persistent attributes can be modified
while offline");
  @@ -324,6 +350,10 @@
                       throw new IllegalArgumentException("This attribute is not writable");
                   }
               }
  +            if(value == null && type.isPrimitive()) {
  +                throw new IllegalArgumentException("Can not assign null to a primitive
attribute");
  +            }
  +            // @todo actually check type
               ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
               try {
                   Thread.currentThread().setContextClassLoader(gmbean.getClassLoader());
  
  
  

Mime
View raw message