Registering Values Programmatically

This guide shows how to register dynamic variable values directly using the DynamicExpressionRegistry API, without using configuration files.

Overview

Programmatic registration is useful for:

  • Testing with specific values

  • Entity-scoped values that vary per transaction

  • Integration with custom configuration systems

  • Custom ConfigurableValueSource implementations

Prerequisites

  • The kfextensions-utils dependency (should be transitively included already)

  • Access to DynamicExpressionRegistry

Global Registration

Basic Registration

Register values directly using the string key:

import com.iconsolutions.kfextensions.runtime.DynamicExpressionRegistry;

// Get the singleton instance
DynamicExpressionRegistry registry = DynamicExpressionRegistry.getInstance();

// Register a value
registry.register("paymentService_upperBound", BigInteger.valueOf(5000));

// Register a list value
registry.register("paymentService_allowedCurrencies", Arrays.asList("USD", "EUR", "GBP"));

Type-Safe Registration

For better type safety, use the generated DynamicVariable constants:

DynamicExpressionRegistry registry = DynamicExpressionRegistry.getInstance();

// Type-safe registration
registry.register(<Generated DEL>.upperBound, BigInteger.valueOf(5000));
registry.register(<Generated DEL>.allowedCurrencies, Arrays.asList("USD", "EUR"));

This approach:

  • Ensures the key is correct (no typos)

  • Provides compile-time type checking

  • Makes refactoring easier

Entity-Scoped Registration

Entity-scoped values are associated with a specific ProcessingEntity and override global values for that processing context.

When to Use Entity Scope

  • Multi-entity applications with per-entity configuration

Registration with Entity

ProcessingEntity entity = processingContext.getProcessingEntity();

registry.register(entity, "paymentService_upperBound", BigInteger.valueOf(10000));

// Or type-safe
registry.register(entity, <Generated DEL>.upperBound, BigInteger.valueOf(10000));