-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KTNB-794: Initialize all bean variables on Spring kernel startup
- Loading branch information
Showing
8 changed files
with
68 additions
and
16 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
jupyter-lib/api/src/main/kotlin/org/jetbrains/kotlinx/jupyter/api/CodeEvaluator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.jetbrains.kotlinx.jupyter.api | ||
|
||
/** | ||
* Evaluates code. Returns rendered result or null in case of the error. | ||
*/ | ||
fun interface CodeEvaluator { | ||
fun eval(code: Code): Any? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
.../src/main/kotlin/org/jetbrains/kotlinx/jupyter/spring/starter/SpringJupyterIntegration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.jetbrains.kotlinx.jupyter.spring.starter | ||
|
||
import org.jetbrains.kotlinx.jupyter.api.libraries.JupyterIntegration | ||
|
||
@Suppress("unused") | ||
class SpringJupyterIntegration : JupyterIntegration() { | ||
override fun Builder.onLoaded() { | ||
declareAllBeansInLibrary() | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...rc/main/kotlin/org/jetbrains/kotlinx/jupyter/spring/starter/SpringProcessKernelRunMode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.jetbrains.kotlinx.jupyter.spring.starter | ||
|
||
import org.jetbrains.kotlinx.jupyter.api.CodeEvaluator | ||
import org.jetbrains.kotlinx.jupyter.api.EmbeddedKernelRunMode | ||
import org.jetbrains.kotlinx.jupyter.api.KernelRunMode | ||
import org.jetbrains.kotlinx.jupyter.api.Notebook | ||
|
||
object SpringProcessKernelRunMode : KernelRunMode by EmbeddedKernelRunMode { | ||
override fun initializeSession( | ||
notebook: Notebook, | ||
evaluator: CodeEvaluator, | ||
) { | ||
notebook.sessionOptions.serializeScriptData = true | ||
evaluator.eval("1") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters