@Override
  public MessageChannel createMessageChannel(HostPort targetHostPort) throws IOException {
    if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
      logger.logDebug("NioTlsMessageProcessor::createMessageChannel: " + targetHostPort);
    }
    NioTlsMessageChannel retval = null;
    try {
      String key = MessageChannel.getKey(targetHostPort, "TLS");

      if (messageChannels.get(key) != null) {
        retval = (NioTlsMessageChannel) this.messageChannels.get(key);
        return retval;
      } else {
        retval =
            new NioTlsMessageChannel(
                targetHostPort.getInetAddress(), targetHostPort.getPort(), sipStack, this);

        //	retval.getSocketChannel().register(selector, SelectionKey.OP_READ);
        synchronized (messageChannels) {
          this.messageChannels.put(key, retval);
        }
        retval.isCached = true;
        if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
          logger.logDebug("key " + key);
          logger.logDebug("Creating " + retval);
        }
        selector.wakeup();
        return retval;
      }
    } finally {
      if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
        logger.logDebug("MessageChannel::createMessageChannel - exit " + retval);
      }
    }
  }
示例#2
0
 /**
  * Returns the port part of this ViaHeader.
  *
  * @return the integer value of the port
  */
 public int getPort() {
   if (sentBy == null) return -1;
   return sentBy.getPort();
 }
示例#3
0
 /**
  * Get the port.
  *
  * @return int port (-1) if port is not set.
  */
 public int getPort() {
   if (hostPort == null) return -1;
   else return hostPort.getPort();
 }