1 Reply Latest reply on Nov 13, 2001 3:05 PM by Charles Chan

    setobjectproperty

    Keith Newbie

      Hi

      A suggestion. For the Message's setObjectProperty() method, the SpyMessage's implementation checks for only certain types of objects:


      public void setObjectProperty(String name, Object value) throws JMSException
      {
      CheckPropertyName(name);
      if (!propReadWrite) throw new MessageNotWriteableException("Properties are read-only");

      if (value instanceof Boolean) prop.put(name,value);
      else if (value instanceof Byte) prop.put(name,value);
      else if (value instanceof Short) prop.put(name,value);
      else if (value instanceof Integer) prop.put(name,value);
      else if (value instanceof Long) prop.put(name,value);
      else if (value instanceof Float) prop.put(name,value);
      else if (value instanceof Double) prop.put(name,value);
      else if (value instanceof String) prop.put(name,value);
      else throw new MessageFormatException("Invalid object type");
      }

      If an object implements the Serializable interface, shouldn't it be allowed to be added too? That would be really useful.

      Keith

        • 1. Re: setobjectproperty
          Charles Chan Newbie

          According to JMS 1.0.2 API doc:

          "The setObjectProperty method accepts values of class Boolean, Byte, Short, Integer, Long, Float, Double, and String. An attempt to use any other class must throw a JMSException."

          So, I think it's better to leave it as is. I think the primary reason for this 'limitation' is that the property values must be usable with the message selector.

          Charles