Skip to main content
Version: 2.3

SpEL Environment variables

The tsmRuntimeConfig provides a safe way to read configuration parameters at runtime. It offers a mechanism for accessing values defined in the application (e.g., in application.yaml) with an emphasis on security when used in dynamic scripts (SpEL).

Key Features

  • Priority Search: First, it searches in the "safe" tsm.runtime map, then in the Spring Environment.
  • Security (Whitelist): Access to the Environment is restricted to keys with allowed prefixes.

Configuration

Properties are configured using the tsm prefix.

tsm:
# Definition of safe parameters directly in the configuration
runtime:
prefix: "TSM-DEV-"
timeoutMs: "5000"
apiBaseUrl: "https://api.example.com"

# Environment access settings (optional)
spel-access:
allowed-prefixes:
- "tsm.runtime"
- "app.custom"
PropertyDescriptionDefault Value
tsm.runtimeA key-value map accessible without restrictions.empty map
tsm.spel-access.allowed-prefixesA list of prefixes allowed to be read from the Environment.["tsm.runtime"]

Usage in SpEL (Scripts, Camunda)

The component is available in the Spring context under the name tsmRuntimeConfig. The most common use is in dynamic expressions.

Get value:

@tsmRuntimeConfig.get("tsm.runtime.prefix")

Note: If the key does not exist and the prefix is not allowed, an AccessDeniedException may be thrown.

Get value with a default:

@tsmRuntimeConfig.getOrDefault("timeoutMs", "1000")

Require a value (throws an error if missing):

@tsmRuntimeConfig.require("apiBaseUrl")

The default allowed prefix is tsm.runtime. Therefore, if you want to access any system property (e.g., java.version), you must explicitly allow it in allowed-prefixes or use * (not recommended).