<commit_before>/*
 * Gretty
 *
 * Copyright (C) 2013-2015 <NAME> and contributors.
 *
 * See the file "LICENSE" for copying and usage permission.
 * See the file "CONTRIBUTORS" for complete list of contributors.
 */
package org.akhikhl.gretty

import org.apache.catalina.Context
import org.apache.catalina.connector.Connector
import org.apache.catalina.startup.Tomcat
import org.slf4j.Logger
import org.slf4j.LoggerFactory

/**
 *
 * @author akhikhl
 */
class TomcatServerStartInfo {

  protected final Logger log

  TomcatServerStartInfo() {
    log = LoggerFactory.getLogger(this.getClass())
  }

  def getInfo(Tomcat tomcat, Connector[] connectors, Map params) {

    if(connectors == null)
      connectors = tomcat.service.findConnectors()

    def portsInfo = connectors.collect { it.port }
    portsInfo = (portsInfo.size() == 1 ? 'port ' : 'ports ') + portsInfo.join(', ')
    log.info '{} started and listening on {}', params.servletContainerDescription, portsInfo

    Connector httpConn = connectors.find { it.scheme == 'http' }
    Connector httpsConn = connectors.find { it.scheme == 'https' }

    List contextInfo = []

    String host = tomcat.hostname == '0.0.0.0' ? 'localhost' : tomcat.hostname

    for(Context context in tomcat.host.findChildren().findAll { it instanceof Context }) {
      log.info '{} runs at:', (context.name - '/')
      if(httpConn) {
        log.info '  http://{}:{}{}', host, httpConn.port, context.path
        contextInfo.add([
          protocol: 'http',
          host: host,
          port: httpConn.port,
          contextPath: context.path,
          baseURI: "http://${host}:${httpConn.port}${context.path}"
        ])
      }
      if(httpsConn) {
        log.info '  https://{}:{}{}', host, httpsConn.port, context.path
        contextInfo.add([
          protocol: 'https',
          host: host,
          port: port,
          contextPath: context.path,
          baseURI: "https://${host}:${httpsConn.port}${context.path}"
        ])
      }
    }

    def serverStartInfo = [ status: 'successfully started' ]

    serverStartInfo.host = host

    if(httpConn)
      serverStartInfo.httpPort = httpConn.port

    if(httpsConn)
      serverStartInfo.httpsPort = httpsConn.port

    serverStartInfo.contexts = contextInfo
    serverStartInfo
  }
}

<commit_msg>fixed issue #163: MissingPropertyException when running Tomcat with HTTPS<commit_after>/*
 * Gretty
 *
 * Copyright (C) 2013-2015 <NAME> and contributors.
 *
 * See the file "LICENSE" for copying and usage permission.
 * See the file "CONTRIBUTORS" for complete list of contributors.
 */
package org.akhikhl.gretty

import org.apache.catalina.Context
import org.apache.catalina.connector.Connector
import org.apache.catalina.startup.Tomcat
import org.slf4j.Logger
import org.slf4j.LoggerFactory

/**
 *
 * @author akhikhl
 */
class TomcatServerStartInfo {

  protected final Logger log

  TomcatServerStartInfo() {
    log = LoggerFactory.getLogger(this.getClass())
  }

  def getInfo(Tomcat tomcat, Connector[] connectors, Map params) {

    if(connectors == null)
      connectors = tomcat.service.findConnectors()

    def portsInfo = connectors.collect { it.port }
    portsInfo = (portsInfo.size() == 1 ? 'port ' : 'ports ') + portsInfo.join(', ')
    log.info '{} started and listening on {}', params.servletContainerDescription, portsInfo

    Connector httpConn = connectors.find { it.scheme == 'http' }
    Connector httpsConn = connectors.find { it.scheme == 'https' }

    List contextInfo = []

    String host = tomcat.hostname == '0.0.0.0' ? 'localhost' : tomcat.hostname

    for(Context context in tomcat.host.findChildren().findAll { it instanceof Context }) {
      log.info '{} runs at:', (context.name - '/')
      if(httpConn) {
        log.info '  http://{}:{}{}', host, httpConn.port, context.path
        contextInfo.add([
          protocol: 'http',
          host: host,
          port: httpConn.port,
          contextPath: context.path,
          baseURI: "http://${host}:${httpConn.port}${context.path}"
        ])
      }
      if(httpsConn) {
        log.info '  https://{}:{}{}', host, httpsConn.port, context.path
        contextInfo.add([
          protocol: 'https',
          host: host,
          port: httpsConn.port,
          contextPath: context.path,
          baseURI: "https://${host}:${httpsConn.port}${context.path}"
        ])
      }
    }

    def serverStartInfo = [ status: 'successfully started' ]

    serverStartInfo.host = host

    if(httpConn)
      serverStartInfo.httpPort = httpConn.port

    if(httpsConn)
      serverStartInfo.httpsPort = httpsConn.port

    serverStartInfo.contexts = contextInfo
    serverStartInfo
  }
}


{'fraction_non_alphanumeric': 0.13201530612244897, 'fraction_numerical': 0.00701530612244898, 'mean_word_length': 2.8376835236541598, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2375376', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1406, 'n_words': 320}