/**
   * Method description
   *
   * @param ht_def_key
   * @param ht_dev_val
   * @param st_def_key
   * @param st_def_val
   * @param prop_key
   * @param prop_val_class
   * @param params
   * @param props
   * @param <T>
   */
  protected <T> void checkHighThroughputProperty(
      String ht_def_key,
      T ht_dev_val,
      String st_def_key,
      T st_def_val,
      String prop_key,
      Class<T> prop_val_class,
      Map<String, Object> params,
      Map<String, Object> props) {
    T tmp = st_def_val;
    String str_tmp = null;

    if (isHighThroughput()) {
      tmp = ht_dev_val;
      str_tmp = (String) params.get(ht_def_key);
    } else {
      tmp = st_def_val;
      str_tmp = (String) params.get(st_def_key);
    }
    if (prop_val_class.isAssignableFrom(Integer.class)) {
      tmp = prop_val_class.cast(DataTypes.parseNum(str_tmp, Integer.class, (Integer) tmp));
    }
    if (prop_val_class.isAssignableFrom(Long.class)) {
      tmp = prop_val_class.cast(DataTypes.parseNum(str_tmp, Long.class, (Long) tmp));
    }
    if (prop_val_class.isAssignableFrom(String.class)) {
      tmp = prop_val_class.cast(str_tmp);
    }
    props.put(prop_key, tmp);
  }
  @Override
  public void setProperties(Map<String, Object> props) throws ConfigurationException {
    super.setProperties(props);
    if (props.get(MAX_INACTIVITY_TIME) != null) {
      maxInactivityTime = (Long) props.get(MAX_INACTIVITY_TIME) * SECOND;
    }
    if (props.get(WHITE_CHAR_ACK_PROP_KEY) != null) {
      white_char_ack = (Boolean) props.get(WHITE_CHAR_ACK_PROP_KEY);
    }
    if (props.get(XMPP_ACK_PROP_KEY) != null) {
      xmpp_ack = (Boolean) props.get(XMPP_ACK_PROP_KEY);
    }
    if (props.get(NET_BUFFER_PROP_KEY) != null) {
      net_buffer = (Integer) props.get(NET_BUFFER_PROP_KEY);
    }
    if (props.get(NET_BUFFER_LIMIT_PROP_KEY) != null) {
      net_buffer_limit = (Integer) props.get(NET_BUFFER_LIMIT_PROP_KEY);
    }
    if (props.get(TRAFFIC_THROTTLING_PROP_KEY) != null) {
      String[] tmp = ((String) props.get(TRAFFIC_THROTTLING_PROP_KEY)).split(",");

      for (String tmp_s : tmp) {
        String[] tmp_thr = tmp_s.split(":");

        if (tmp_thr[0].equalsIgnoreCase("xmpp")) {
          last_minute_packets_limit =
              DataTypes.parseNum(tmp_thr[1], Long.class, LAST_MINUTE_PACKETS_LIMIT_PROP_VAL);
          log.warning(getName() + " last_minute_packets_limit = " + last_minute_packets_limit);
          total_packets_limit =
              DataTypes.parseNum(tmp_thr[2], Long.class, TOTAL_PACKETS_LIMIT_PROP_VAL);
          log.warning(getName() + " total_packets_limit = " + total_packets_limit);
          if (tmp_thr[3].equalsIgnoreCase("disc")) {
            xmppLimitAction = LIMIT_ACTION.DISCONNECT;
          }
          if (tmp_thr[3].equalsIgnoreCase("drop")) {
            xmppLimitAction = LIMIT_ACTION.DROP_PACKETS;
          }
        }
        if (tmp_thr[0].equalsIgnoreCase("bin")) {
          last_minute_bin_limit =
              DataTypes.parseNum(tmp_thr[1], Long.class, LAST_MINUTE_BIN_LIMIT_PROP_VAL);
          log.warning(getName() + " last_minute_bin_limit = " + last_minute_bin_limit);
          total_bin_limit = DataTypes.parseNum(tmp_thr[2], Long.class, TOTAL_BIN_LIMIT_PROP_VAL);
          log.warning(getName() + " total_bin_limit = " + total_bin_limit);
        }
      }
    }

    if (props.get(ELEMENTS_NUMBER_LIMIT_PROP_KEY) != null) {
      elements_number_limit = (int) props.get(ELEMENTS_NUMBER_LIMIT_PROP_KEY);
    }

    if (props.get(WATCHDOG_DELAY) != null) {
      watchdogDelay = (long) props.get(WATCHDOG_DELAY);
    }
    if (props.get(WATCHDOG_TIMEOUT) != null) {
      watchdogTimeout = (long) props.get(WATCHDOG_TIMEOUT);
    }
    if (props.get(WATCHDOG_PING_TYPE_KEY) != null) {
      String value = String.valueOf(props.get(WATCHDOG_PING_TYPE_KEY));
      watchdogPingType = WATCHDOG_PING_TYPE.valueOf(value.toUpperCase());
    }

    if (props.size() == 1) {

      // If props.size() == 1, it means this is a single property update and
      // ConnectionManager does not support it yet.
      return;
    }
    if (isInitializationComplete()) {

      // Do we really need to do this again?
      // Looks like reconfiguration for the port is not working correctly anyway
      // so for now we do not want to do it.
      return;
    }
    releaseListeners();

    int[] ports = (int[]) props.get(PORTS_PROP_KEY);

    if (ports != null) {
      for (int i = 0; i < ports.length; i++) {
        Map<String, Object> port_props = new LinkedHashMap<String, Object>(20);

        for (Map.Entry<String, Object> entry : props.entrySet()) {
          if (entry.getKey().startsWith(PROP_KEY + ports[i])) {
            int idx = entry.getKey().lastIndexOf('/');
            String key = entry.getKey().substring(idx + 1);

            log.log(
                Level.CONFIG,
                "Adding port property key: {0}={1}",
                new Object[] {key, entry.getValue()});
            port_props.put(key, entry.getValue());
          } // end of if (entry.getKey().startsWith())
        } // end of for ()
        port_props.put(PORT_KEY, ports[i]);
        if (port_props.containsKey(PORT_TYPE_PROP_KEY)
            && !(port_props.get(PORT_TYPE_PROP_KEY) instanceof ConnectionType)) {
          Object val = port_props.get(PORT_TYPE_PROP_KEY);
          port_props.put(PORT_TYPE_PROP_KEY, ConnectionType.valueOf(val.toString()));
        }
        if (port_props.containsKey(PORT_SOCKET_PROP_KEY)
            && !(port_props.get(PORT_SOCKET_PROP_KEY) instanceof SocketType)) {
          Object val = port_props.get(PORT_SOCKET_PROP_KEY);
          port_props.put(PORT_SOCKET_PROP_KEY, SocketType.valueOf(val.toString()));
        }
        addWaitingTask(port_props);
        // reconnectService(port_props, startDelay);
      } // end of for (int i = 0; i < ports.length; i++)
    } // end of if (ports != null)
  }