#1058: CustomScriptingHost.kt

projectforge-business/src/main/kotlin/org/projectforge/business/scripting/kotlin/CustomScriptingHost.kt Kotlin Scripting Host, projectforge-business/src/main/kotlin/org/projectforge/business/scripting/kotlin/CustomScriptingHost.kt 52 lines · 26 code · 22 comments · 4 blank
Extends BasicJvmScriptingHost to inject ProjectForge's ThreadLocal context (logged-in user and script logger) into Kotlin script evaluation threads. Ensures scripts run with the correct user identity and have access to the ScriptLogger via ThreadLocalScriptingContext.

Design

The eval override captures the current logged-in user and logger before evaluation, sets them in ThreadLocal storage, then restores/clears in the finally block. This is critical because Kotlin scripting executes in a separate thread pool where the normal Spring security context is not available.

Git History

868d6abb7 2025 -> 2026
801bf7c63 Scripting: ScriptLogger is added to ThreadLocal for usage in code.
63081666f Source file headers: 2024-> 2025.
0c7685b60 WIP: gradle...
921638f43 WIP
4c8365b88 Kotlin scripting refactored (All tests OK)
4efcbd0fb Migration stuff in progress...
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
5f7ef41b8 Copyright 2021 -> 2022
ceb63e8a1 Source code header: (C) 2001-2021.
7c79f1922 Copyright of source header -> 2020.
dd5ca38ac CopyRight of all java file-header updated or created.
9ebb88522 Initial commit