/**
  * Static inspection method to determine if a named property exists for a given message.
  *
  * @param message the JmsMessageFacade instance to read from
  * @param name the property name that is being inspected.
  * @return true if the message contains the given property.
  * @throws JMSException if an error occurs while validating the defined property.
  */
 public static boolean propertyExists(JmsMessageFacade message, String name) throws JMSException {
   PropertyIntercepter jmsPropertyExpression = PROPERTY_INTERCEPTERS.get(name);
   if (jmsPropertyExpression != null) {
     return jmsPropertyExpression.propertyExists(message);
   } else {
     return message.propertyExists(name);
   }
 }
 /**
  * Static set method that takes a property name and sets the value either via a registered
  * property set object or through the JmsMessageFacade setProperty method.
  *
  * @param message the JmsMessageFacade instance to write to.
  * @param name the property name that is being written.
  * @param value the new value to assign for the named property.
  * @throws JMSException if an error occurs while writing the defined property.
  */
 public static void setProperty(JmsMessageFacade message, String name, Object value)
     throws JMSException {
   PropertyIntercepter jmsPropertyExpression = PROPERTY_INTERCEPTERS.get(name);
   if (jmsPropertyExpression != null) {
     jmsPropertyExpression.setProperty(message, value);
   } else {
     message.setProperty(name, value);
   }
 }
  /**
   * For each of the currently configured message property intercepter instances clear or reset the
   * value to its default. Once complete the method will direct the given provider message facade to
   * clear any message properties that might have been set.
   *
   * @param message the JmsMessageFacade instance to read from
   * @param excludeStandardJMSHeaders whether the standard JMS header names should be excluded from
   *     the returned set
   * @throws JMSException if an error occurs while validating the defined property.
   */
  public static void clearProperties(JmsMessageFacade message, boolean excludeStandardJMSHeaders)
      throws JMSException {
    for (Entry<String, PropertyIntercepter> entry : PROPERTY_INTERCEPTERS.entrySet()) {
      if (excludeStandardJMSHeaders && STANDARD_HEADERS.contains(entry.getKey())) {
        continue;
      }

      entry.getValue().clearProperty(message);
    }

    message.clearProperties();
  }
  /**
   * Static get method that takes a property name and gets the value either via a registered
   * property get object or through the JmsMessageFacade getProperty method.
   *
   * @param message the JmsMessageFacade instance to read from
   * @param name the property name that is being requested.
   * @return the correct value either mapped to an Message attribute of a Message property.
   * @throws JMSException if an error occurs while reading the defined property.
   */
  public static Object getProperty(JmsMessageFacade message, String name) throws JMSException {
    Object value = null;

    PropertyIntercepter jmsPropertyExpression = PROPERTY_INTERCEPTERS.get(name);
    if (jmsPropertyExpression != null) {
      value = jmsPropertyExpression.getProperty(message);
    } else {
      value = message.getProperty(name);
    }

    return value;
  }
  /**
   * For each of the currently configured message property intercepter instance a string key value
   * is inserted into an Set and returned if the property has a value and is available for a read
   * operation. The Set returned may be manipulated by the receiver without impacting the facade,
   * and an empty set will be returned if there are no matching properties.
   *
   * @param message the JmsMessageFacade instance to read from
   * @param excludeStandardJMSHeaders whether the standard JMS header names should be excluded from
   *     the returned set
   * @return a {@code Set<String>} containing the names of all intercepted properties with a value.
   * @throws JMSException if an error occurs while gathering the message property names.
   */
  public static Set<String> getPropertyNames(
      JmsMessageFacade message, boolean excludeStandardJMSHeaders) throws JMSException {
    Set<String> names = new HashSet<String>();
    for (Entry<String, PropertyIntercepter> entry : PROPERTY_INTERCEPTERS.entrySet()) {
      if (excludeStandardJMSHeaders && STANDARD_HEADERS.contains(entry.getKey())) {
        continue;
      }

      if (entry.getValue().propertyExists(message)) {
        names.add(entry.getKey());
      }
    }

    names.addAll(message.getPropertyNames());

    return names;
  }
 /**
  * For each of the currently configured message property intercepter instance a string key value
  * is inserted into an Set and returned.
  *
  * @param message the JmsMessageFacade instance to read property names from.
  * @return a {@code Set<String>} containing the names of all intercepted properties.
  * @throws JMSException if an error occurs while gathering the message property names.
  */
 public static Set<String> getAllPropertyNames(JmsMessageFacade message) throws JMSException {
   Set<String> names = new HashSet<String>(PROPERTY_INTERCEPTERS.keySet());
   names.addAll(message.getPropertyNames());
   return names;
 }