public static Hashtable getDataTable(Message message) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) {
      return DATA_TABLE_DEF;
    }

    return (Hashtable) message.getObjectProperty(MessagePropertyNames.DATA_TABLE);
  }
 public static Hashtable getAttachments(Message message) throws JMSException {
   if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) {
     return ATTACHMENT_TABLE_DEF;
   }
   Hashtable attachments = new Hashtable();
   attachments.putAll((Map) message.getObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE));
   return attachments;
 }
  public static Object getDataEntry(Message message, Object name) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) {
      return DATA_PROP_DEF;
    }

    Hashtable datTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.DATA_TABLE);

    return datTable.get(name);
  }
  public static Object getAttachment(Message message, String name) throws JMSException {
    if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) {
      return ATTACHMENT_PROP_DEF;
    }

    Hashtable attachmentTable;
    attachmentTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE);
    return attachmentTable.get(name);
  }
  public static Object getPropertyValue(String propertyName, Message jmsMessage)
      throws JMSException {
    if (jmsMessage == null) {
      return null;
    }

    if (propertyName == null) {
      return null;
    }

    return jmsMessage.getObjectProperty(propertyName);
  }
  public static byte[] getBytesData(Message message) throws JMSException {
    if (message instanceof BytesMessage) {
      BytesMessage bytesMessage = (BytesMessage) message;
      byte bytes[] = new byte[(int) bytesMessage.getBodyLength()];
      bytesMessage.readBytes(bytes);
      return bytes;
    }

    if (!message.propertyExists(MessagePropertyNames.BYTES_DATA)) {
      return BYTES_DATA_DEF;
    }

    return (byte[]) message.getObjectProperty(MessagePropertyNames.BYTES_DATA);
  }
  public static void addDataEntry(Message message, Object name, Object value) throws JMSException {
    Hashtable dataTable = null;

    if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) {
      dataTable = new Hashtable();
    } else {
      dataTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.DATA_TABLE);
    }

    dataTable.put(name, value);

    if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) {
      message.setObjectProperty(MessagePropertyNames.DATA_TABLE, dataTable);
    }
  }
  public static void addAttachment(Message message, Object name, Object value) throws JMSException {
    Hashtable headerTable = null;

    if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) {
      headerTable = new Hashtable();
    } else {
      headerTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE);
    }

    headerTable.put(name, value);

    if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) {
      message.setObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE, headerTable);
    }
  }