def initialize()

in kernel/src/main/scala/org/apache/toree/boot/KernelBootstrap.scala [58:137]


  def initialize() = {
    // TODO: Investigate potential to initialize System out/err/in to capture
    //       Console DynamicVariable initialization (since takes System fields)
    //       and redirect it to a workable location (like an actor) with the
    //       thread's current information attached
    //
    // E.G. System.setOut(customPrintStream) ... all new threads will have
    //      customPrintStream as their initial Console.out value
    //

    // ENSURE THAT WE SET THE RIGHT SPARK PROPERTIES
    val execUri = System.getenv("SPARK_EXECUTOR_URI")
    System.setProperty("spark.repl.class.outputDir", outputDir.getAbsolutePath)
    if (execUri != null) {
      System.setProperty("spark.executor.uri", execUri)
    }

    displayVersionInfo()

    // Do this first to support shutting down quickly before entire system
    // is ready
    initializeShutdownHook()

    // Initialize the bare minimum to report a starting message
    val (actorSystem, actorLoader, kernelMessageRelayActor, statusDispatch) =
      initializeBare(
        config = config,
        actorSystemName = DefaultActorSystemName
      )

    this.actorSystem = actorSystem
    this.actorLoader = actorLoader
    this.kernelMessageRelayActor = kernelMessageRelayActor
    this.statusDispatch = statusDispatch

    // Indicate that the kernel is now starting
    publishStatus(KernelStatusType.Starting)

    // Initialize components needed elsewhere
    val (commStorage, commRegistrar, commManager, interpreter,
      kernel, dependencyDownloader,
      magicManager, pluginManager, responseMap) =
      initializeComponents(
        config      = config,
        actorLoader = actorLoader
      )
    this.interpreters ++= Seq(interpreter)

    this.kernel = kernel

    // Initialize our handlers that take care of processing messages
    initializeHandlers(
      actorSystem   = actorSystem,
      actorLoader   = actorLoader,
      kernel        = kernel,
      interpreter   = interpreter,
      commRegistrar = commRegistrar,
      commStorage   = commStorage,
      pluginManager = pluginManager,
      magicManager = magicManager,
      responseMap   = responseMap
    )

    // Initialize our non-shutdown hooks that handle various JVM events
    initializeHooks(
      config = config,
      interpreter = interpreter
    )

    logger.debug("Initializing security manager")
    System.setSecurityManager(new KernelSecurityManager)

    logger.debug("Running postInit for interpreters")
    interpreters foreach {_.postInit()}

    logger.info("Marking relay as ready for receiving messages")
    kernelMessageRelayActor ! true

    this
  }