@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);
      }
    }
  }
Beispiel #2
0
 public StringBuilder encode(StringBuilder buffer) {
   if (userInfo != null) {
     userInfo.encode(buffer);
     buffer.append(AT);
     hostPort.encode(buffer);
   } else {
     hostPort.encode(buffer);
   }
   return buffer;
 }
 /**
  * Returns the host part of this ViaHeader.
  *
  * @return the string value of the host
  */
 public String getHost() {
   if (sentBy == null) return null;
   else {
     Host host = sentBy.getHost();
     if (host == null) return null;
     else return host.getHostname();
   }
 }
 /**
  * Set the host part of this ViaHeader to the newly supplied <code>host</code> parameter.
  *
  * @return host - the new interger value of the host of this ViaHeader
  * @throws ParseException which signals that an error has been reached unexpectedly while parsing
  *     the host value.
  */
 public void setHost(String host) throws ParseException {
   if (sentBy == null) sentBy = new HostPort();
   try {
     Host h = new Host(host);
     sentBy.setHost(h);
   } catch (Exception e) {
     throw new NullPointerException(" host parameter is null");
   }
 }
 /** Encode the body of this header (the stuff that follows headerName). A.K.A headerValue. */
 protected String encodeBody() {
   StringBuffer encoding = new StringBuffer();
   encoding.append(sentProtocol.encode()).append(SP).append(sentBy.encode());
   if (!parameters.isEmpty()) {
     encoding.append(SEMICOLON).append(parameters.encode());
   }
   if (comment != null) {
     encoding.append(SP).append(LPAREN).append(comment).append(RPAREN);
   }
   return encoding.toString();
 }
  /**
   * Set the port part of this ViaHeader to the newly supplied <code>port</code> parameter.
   *
   * @param port - the new integer value of the port of this ViaHeader
   */
  public void setPort(int port) /*throws InvalidArgumentException*/ {

    /*
     * InvalidArgumentException not in 1.1 API
     *
    if ( port!=-1 && (port<1 || port>65535)) {
    	throw new InvalidArgumentException( "Port value out of range -1, [1..65535]" );
    }
    */

    if (sentBy == null) sentBy = new HostPort();
    sentBy.setPort(port);
  }
 /**
  * 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();
 }
 /**
  * set the Host of the Via Header
  *
  * @param host String to set
  */
 public void setHost(Host host) {
   if (sentBy == null) {
     sentBy = new HostPort();
   }
   sentBy.setHost(host);
 }
 /** remove the port. */
 public void removePort() {
   sentBy.removePort();
 }
Beispiel #10
0
 /**
  * Set the port.
  *
  * @param port int to set
  */
 public void setPort(int port) {
   if (hostPort == null) hostPort = new HostPort();
   hostPort.setPort(port);
 }
Beispiel #11
0
 /**
  * set the host.
  *
  * @param host Host to set
  */
 public void setHost(Host host) {
   if (hostPort == null) hostPort = new HostPort();
   hostPort.setHost(host);
 }
Beispiel #12
0
 /** remove the port. */
 public void removePort() {
   if (hostPort != null) hostPort.removePort();
 }
Beispiel #13
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();
 }
Beispiel #14
0
 /**
  * Get the host name.
  *
  * @return Host (null if not set)
  */
 public Host getHost() {
   if (hostPort == null) return null;
   else return hostPort.getHost();
 }