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

Interceptors

Create module interceptors to listen and react to BoxLang runtime events

Interceptors follow the Observer/Intercepting Filter pattern, letting your module react to runtime events. Create them in pure BoxLang or Java.

Register interceptors in your ModuleConfig.bx configure() method:

ModuleConfig.bx:

function configure() {
    settings = {};

    // Register interceptors
    interceptors = [
        {
            class: "interceptors.RequestLogger",
            properties: {
                logHeaders: true,
                logBody: false
            }
        }
    ];

    // Declare custom interception points
    customInterceptionPoints = [
        "onBeforeGreeting",
        "onAfterGreeting"
    ];
}

File: interceptors/RequestLogger.bx

Lambda Interceptors

Register inline closures as interceptors for quick event handling:

Custom Interception Points

Declare your own events that other code can listen to:

Listening to Lifecycle Events

Your ModuleConfig.bx is automatically registered as an interceptor, so you can add any event method directly:

Interceptor names follow the convention ClassName@moduleName. If not specified, it's auto-derived from the class name.

Next Steps

  • Services — Global runtime services (Java only)

  • Schedulers — Scheduled task management (Java only)

  • Advanced Collaboration — System settings and class resolvers

Last updated

Was this helpful?