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

Mappings & Class Resolution

Understanding module mappings, class resolution, and the @moduleName notation

Every BoxLang module receives automatic mappings for class resolution and optional web access. Understanding these mappings is essential for importing classes and serving web content.

Internal Module Mapping

When a module is registered, BoxLang creates an internal mapping for class resolution:

Property
Value
Purpose

Path

bxModules.{moduleName}

Internal class path prefix

Physical

Module root directory

Where classes/BIFs/components live

Web Access

❌ No

Only for class resolution

For a module named myModule, the internal mapping bxModules.myModule points to the module root. This is used for class resolution only — it's not web-accessible.

Public Web Mapping

For serving static files via HTTP, BoxLang creates a public mapping:

Property
Default
Customizable

Folder

{moduleRoot}/public/

this.publicMapping

URL Path

/bxModules/{name}/public/

✅ Override mapping name

Files in myModule/public/css/style.css are accessible at:

http://yourserver.com/bxModules/myModule/public/css/style.css

Customizing Mappings

Override defaults in your module descriptor:

The @moduleName Notation

BoxLang provides a powerful syntax for explicitly addressing classes from specific modules using the @moduleName suffix. This improves performance and eliminates ambiguity.

Why Use @moduleName?

Without @moduleName:

  • BoxLang searches ALL modules

  • Slower with many modules loaded

  • Ambiguous if duplicates exist

With @moduleName:

  • Direct lookup in the specified module

  • Faster resolution

  • No ambiguity

Importing BoxLang Classes

Importing Java Classes from Modules

The same notation works for Java classes packaged in modules:

Using createObject()

Class Loading Hierarchy

When resolving a class with @moduleName, BoxLang searches:

  1. Module's compiled classes (modules.{moduleName} package prefix)

  2. Module's libs/ folder (JAR dependencies)

  3. Parent class loader (runtime classes — fallback)

This isolation ensures modules don't interfere with each other's dependencies.

Custom Class Resolvers

Modules can register custom class resolvers with unique prefixes (extending the built-in bx: and java: resolvers). See Advanced Collaboration for details.

Best Practices

1

Use @moduleName for Clarity

Always use @moduleName when importing classes from modules to avoid ambiguity and improve performance.

import models.UserService@myModuleimport models.UserService

2

Keep Public Folders Organized

Structure your public/ folder logically:

3

Document Your Mappings

In your module's README, document what mappings are created and how to import your classes.

Next Steps

Last updated

Was this helpful?