<commit_before>package de.wayofquality.blended.launcher

import java.io.File
import java.net.URLClassLoader
import java.util.ServiceLoader

import scala.collection.JavaConverters._
import scala.collection.immutable.Seq
import scala.util.Try
import scala.util.control.NonFatal

import org.osgi.framework.Bundle
import org.osgi.framework.Constants
import org.osgi.framework.FrameworkEvent
import org.osgi.framework.FrameworkListener
import org.osgi.framework.launch.Framework
import org.osgi.framework.launch.FrameworkFactory
import org.osgi.framework.startlevel.BundleStartLevel
import org.osgi.framework.startlevel.FrameworkStartLevel

import de.wayofquality.blended.launcher.internal.Logger

import com.typesafe.config.ConfigFactory

object Launcher {

  def main(args: Array[String]) {

    val configFile = args match {
      case Array(configFile) => new File(configFile).getAbsoluteFile()
      case _ =>
        Console.err.println("Usage: main configfile")
        sys.exit(1)
    }

    new Launcher(LauncherConfig.read(configFile)).run()
    sys.exit(0)

  }

}

case class BundleConfig(location: String, start: Boolean = false, startLevel: Int)

case class LauncherConfig(
  frameworkJar: String,
  systemProperties: Map[String, String],
  frameworkProperties: Map[String, String],
  startLevel: Int,
  defaultStartLevel: Int,
  bundles: Seq[BundleConfig])

object LauncherConfig {

  def read(file: File): LauncherConfig = {

    val config = ConfigFactory.parseFile(file).getConfig("de.wayofquality.blended.launcher.Launcher")

    LauncherConfig(
      frameworkJar = config.getString("frameworkBundle"),<commit_msg>Resolve config to allow substitutions<commit_after>package de.wayofquality.blended.launcher

import java.io.File
import java.net.URLClassLoader
import java.util.ServiceLoader

import scala.collection.JavaConverters._
import scala.collection.immutable.Seq
import scala.util.Try
import scala.util.control.NonFatal

import org.osgi.framework.Bundle
import org.osgi.framework.Constants
import org.osgi.framework.FrameworkEvent
import org.osgi.framework.FrameworkListener
import org.osgi.framework.launch.Framework
import org.osgi.framework.launch.FrameworkFactory
import org.osgi.framework.startlevel.BundleStartLevel
import org.osgi.framework.startlevel.FrameworkStartLevel

import de.wayofquality.blended.launcher.internal.Logger

import com.typesafe.config.ConfigFactory

object Launcher {

  def main(args: Array[String]) {

    val configFile = args match {
      case Array(configFile) => new File(configFile).getAbsoluteFile()
      case _ =>
        Console.err.println("Usage: main configfile")
        sys.exit(1)
    }

    new Launcher(LauncherConfig.read(configFile)).run()
    sys.exit(0)

  }

}

case class BundleConfig(location: String, start: Boolean = false, startLevel: Int)

case class LauncherConfig(
  frameworkJar: String,
  systemProperties: Map[String, String],
  frameworkProperties: Map[String, String],
  startLevel: Int,
  defaultStartLevel: Int,
  bundles: Seq[BundleConfig])

object LauncherConfig {

  def read(file: File): LauncherConfig = {

    val config = ConfigFactory.parseFile(file).getConfig("de.wayofquality.blended.launcher.Launcher").resolve()

    LauncherConfig(
      frameworkJar = config.getString("frameworkBundle"),
{'fraction_non_alphanumeric': 0.09811664641555286, 'fraction_numerical': 0.001215066828675577, 'mean_word_length': 4.965579710144928, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '5714203', 'n_tokens_mistral': 1011, 'n_tokens_neox': 969, 'n_words': 193}