Boxlang application descriptor

From ortus-docs/coldbox-docs · View interactive version

Boxlang application descriptor is an AI agent skill from the GitHub repository ortus-docs/coldbox-docs. Use this skill when designing or debugging Application.bx behavior: app discovery and nesting, multi-application isolation, lifecycle events, pseudo-constructor settings, session management, mappings/javaSettings resolution, and app-scoped schedulers/watchers via this.schedulers and this.watchers.

How to use this skill

Skill file

BoxLang Application Descriptor

Overview

Application.bx is BoxLang's application descriptor. It defines application-level settings and lifecycle callbacks, and it is the cornerstone for running multiple isolated applications in one BoxLang server/runtime.

Use this skill whenever the question involves:

Core Model

Multi-Application Isolation

Each unique this.name maps to a unique application memory space:

This enables running multiple apps side-by-side (public site, admin site, API site) in a single server process.

App Name Rules

class {
    this.name = "MyApp"
}

Best practices:

If no name is provided, runtime may auto-generate one from the descriptor path for class listeners, which is usually not what you want in production.

Lifecycle Callbacks

Primary callbacks in Application.bx:

class {

    this.name = "MyApp"
    this.sessionManagement = true

    function onApplicationStart() {
        application.bootedAt = now()
        return true
    }

    function onRequestStart( string targetPage ) {
        request.started = getTickCount()
        return true
    }

    function onError( any exception, string eventName ) {
        writeLog( text: "Error in #eventName#: #exception.message#", type: "Error" )
        return true
    }

}

Pseudo-Constructor Settings

Common this.* settings in Application.bx include:

App-Scoped Schedulers and Watchers

Application.bx can wire async infrastructure per app:

class {

    this.name = "MyApp"

    this.schedulers = [
        "schedulers.DailyMaintenance",
        "schedulers.HourlyReports"
    ]

    this.watchers = {
        sourceWatcher : {
            paths : [ expandPath( "./src" ) ],
            listener : "app.listeners.HotReloadListener",
            recursive : true,
            debounce : 250,
            atomicWrites : true,
            errorThreshold : 10
        }
    }

}

For deeper async details, see:

Runtime vs Application Configuration

Rule of thumb:

Troubleshooting

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.