For the complete documentation index, see llms.txt. This page is also available as Markdown.

Advanced Collaboration

Advanced integration patterns, system setting providers, custom class resolvers, and inter-module communication

Modules can integrate deeply with the BoxLang runtime through system setting providers, custom class resolvers, and runtime configuration APIs.

System Setting Providers

Modules can register custom providers for the getSystemSetting() BIF, enabling centralized configuration management from various sources.

How It Works

The getSystemSetting() BIF checks registered providers in order before falling back to environment variables.

Registering a Provider

function onLoad() {
    boxRuntime.getConfiguration().registerSystemSettingProvider(
        "my-settings",
        ( settingName ) => {
            // Only handle your prefixed settings
            if ( settingName.startsWith( "MYAPP_" ) ) {
                return lookupFromDatabase( settingName )
            }
            // Return null to let other providers try
            return null
        }
    )
}

function onUnload() {
    boxRuntime.getConfiguration().unregisterSystemSettingProvider( "my-settings" )
}

Provider Resolution Order

When getSystemSetting("MY_KEY") is called:

  1. Named providers checked in registration order

  2. Default provider (environment variables)

  3. Returns null if not found

Custom Class Resolvers

Register custom class resolvers with unique prefixes (extending the built-in bx: and java: resolvers).

Built-in Resolvers

Prefix
Resolver
Purpose

java:

JavaResolver

Load Java classes explicitly

bx:

BoxResolver

Load BoxLang components/classes

Creating a Custom Resolver

Implement the IClassResolver interface:

Registration in ModuleConfig.bx:

Usage After Registration

Runtime Configuration APIs

Registering Additional Mappings

Modifying Runtime Settings

Best Practices

1

Always Clean Up

Unregister providers and resolvers in onUnload(). Use try/catch so one failure doesn't prevent other cleanup.

2

Return Null Gracefully

System setting providers must return null for settings they don't handle.

3

Use Unique Names

Prefix provider and resolver names with your module name to avoid conflicts: mymodule-settings, mymodule-custom.

4

Test Isolation

Verify your module works when loaded/unloaded multiple times and alongside other modules.

Next Steps

Last updated

Was this helpful?