SlideShare a Scribd company logo
WELCOME
Into the Box 2025: The Future is Dynamic!
www.intothebox.org
GET STARTED
Creating your first BoxLang Module
Customize your Runtime
Brad Wood
• Lead developer of CommandBox CLI
• BoxLang Framework Architect
• I’ve made 9,722 commits on GitHub since 2011
Senior Software Architect
brad@bradwood.com @bdw429s
● BoxLang’s entire runtime is modular and extensible
● This was the case from day one of this project
● We have a ModuleService which is very similar to
ColdBox/CommandBox/ContentBox, but at the runtime level
● The BoxLang core allows anything to be dynamically registered
● Modules can be written entirely in Java, in BoxLang, or in a mix of both. You choose!
● Ortus has written dozens of “official” modules
● You can write your own private or public modules
● Publish your modules directly to ForgeBox for the world to use
BoxLang Modules
● BIFs (Built In Functions)
● Components (formerly known as tags)
● Classes
● Interceptors (listening to core BL runtime event announcements)
● Custom Components (AKA Custom Tags)
● Jars
● Configuration
● Caches
● JDBC Drivers
● Custom Contexts/scopes
BoxLang Modules
● Default locations
○ boxlang_modules/ folder in the working directory
○ modules/ folder inside the BoxLang home folder
● You can configure additional folders in the boxlang.json file
● You can configure additional folders via env variable
Module Locations
● A folder
● A ModuleConfig.bx class
○ configure()
■ settings
■ interceptors
○ onLoad()
○ onUnload()
● bifs/ folder
● components/ folder
● libs/ folder
Module Structure
The only requirement is the
ModuleConfig.bx
Everything else is optional!
● A folder
● A ModuleConfig.bx class
○ configure()
■ settings
■ interceptors
○ onLoad()
○ onUnload()
● bifs/ folder
● components/ folder
● libs/ folder
Module Structure
● configure() method
○ Runs when module is registered, but before it’s activated. Responsible for
creating settings structure which defines default settings for the module.
The user can override these in their BoxLang config!
● onLoad() method
○ Runs when the module activates and can register additional items with
the runtime, or setup anything the module needs
● onUnload() method
○ Runs when the module is unloaded (or the runtime shuts down). Clean up
and unregister any custom items.
ModuleConfig.bx
function configure() {
variables.settings = {
mySetting= "value",
anotherSetting= "another value"
}
}
Module Settings
ModuleConfig .bx
{
"modules": {
"myModule": {
"settings": {
"mySetting": "override value"
}
}
}
}
Module Settings Override
boxlang.json
function onLoad() {
boxRuntime.getConfiguration().registerMapping( "/foobar", "C:/foo/bar");
println( "This module is LOADED!" )
}
Module onLoad
ModuleConfig.bx
● Every module gets an automatic class mapping created that points to the
root of the module
● /bxModules/moduleName/
● Customize the mapping name in your ModuleConfig.bx
this.mapping = "waffle"
● You can access files inside the module
fileRead( "/bxModules/myModule/resources/settings.json" )
● You can create classes from inside the module
new bxModules.myModule.models.FooService()
Automatic Mapping
● Each module has a dedicated class loader, pointed at the lib/ folder.
● This is for 3rd party jars, or even custom Java classes you write
● Each module is an “island” so they won’t cloud the system
classloader with potentially different versions of the same library
● There is a namespace registered for Java class paths
new com.foo.JavaClass@myModule()
Module Classloader
There is not a specific convention for custom tags, but since there is a
mapping created that points to the root of the module and custom tags
are searched for in any mapping, you can just place a .bxm or .bxs
folder in the root of your module and it will be usable as a custom
component/tag.
Module Custom Components
● BIFs -> Built In Functions
● First-class headless global functions like now() or fileRead()
● You can OVERWRITE core BIFs. Be careful! With great power comes
great responsibility.
● Add bx class to bifs/ folder
● Name of class is name of BIF
● Needs @BoxBIF annotation
● invoke() method runs it
● BIF arguments are passed along to the invoke() method
Register BIFs
import ortus.boxlang.runtime.types.DateTime;
@BoxBIF
class {
function invoke(){
return new DateTime();
}
}
BIF Example
bifs/Now.bx
● Create one alias for the BIF with
@BoxBIF( "nowButCooler" )
● Create many aliases with
@BoxBIF( [
"nowButCooler",
"now2point0",
"nowBrad"
] )
BIF Aliases
● Register BIF as member method on a type
@BoxMember( "array" )
● If the BIF name starts with the type name, then the
member method removes that text from the name
arrayAppend() becomes just myArr.append()
○ Get fancy
@BoxMember( { "string": { "name": "append", "objectArgument": "string" } })
BIF Member Methods
@BoxBIF
@BoxMember( "array" )
class {
function invoke( Array arr, string str ){
arr.append( str.ucase() );
return arr;
}
}
BIF Member Example
bifs/ArrayAppendUcase.bx
myArr = [];
arrayAppendUcase( myArr, "brad" )
myArr.appendUcase( "brad" )
BIF Member Example
● Components -> used to be called tags
● Components have both a template and a script sytnax
● First-class global like bx:http or bx:mail
● You can OVERWRITE core components. Be careful!
● Add bx class to components/ folder
● Name of class is name of component
● Needs @BoxComponent annotation
● invoke() method runs it
Register Components (tags)
Component Annotations
@BoxComponent
@BoxComponent( "MyAlias" )
@BoxComponent( "MyAlias", "AnotherAlias" )
@AllowsBody( false )
@RequiresBody( true )
● invoke() arguments
○ context - The BoxLang Context
○ Struct attributes - The attributes passed by the user
○ body - A function that represents the body of the component
○ Struct executionState - Data about execution
Component invoke() method
@BoxComponent
@AllowsBody( false )
class {
function invoke( context, attributes, body, executionState ){
echo( "hello " & attriutes.name ?: "world" );
}
}
Component Example
components/SayHello.bx
<!--- Templating --->
<bx:sayHello name="Brad">
// Scripting
bx:sayHello name="Brad";
Component Example
@BoxComponent
@RequiresBody( true )
class {
function invoke( context, attributes, body, executionState ){
var buffer = newBuffer();
var bodyResult = processBody( context, body, buffer );
// handle return, break, or continue
if ( bodyResult.isEarlyExit() ) {
return bodyResult;
}
echo( buffer.toString().Ucase() );
}
}
Component Example 2
components/Scream.bx
<!--- Templating --->
<bx:scream>
I like spam!
</bx:scream>
// Scripting
bx:sayHello {
echo( "I like spam!" );
}
Component Example 2
Thank You!
The Future of Modern Development Starts Here, with you! 🚀

More Related Content

Similar to Customize your Runtime Creating your first BoxLang Module.pdf (20)

PDF
CMake_Tutorial.pdf
Thejeswara Reddy
 
PPTX
C++.pptx
AbhimanyuKumarYadav3
 
PPTX
Intro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Blue Elephant Consulting
 
PDF
00-intro-to-classes.pdf
TamiratDejene1
 
PDF
Apache Calcite (a tutorial given at BOSS '21)
Julian Hyde
 
KEY
Reusable Ruby • Rt 9 Ruby Group • Jun 2012
skinandbones
 
PDF
Python with Firebird: FDB driver 101
Marius Adrian Popa
 
PPTX
Building services using windows azure
Suliman AlBattat
 
PDF
Objective-C Is Not Java
Chris Adamson
 
PDF
Gradle - small introduction
Igor Popov
 
PPTX
Creational pattern 2
Naga Muruga
 
PDF
Object Oriented Programming using C++ - Part 2
University College of Engineering Kakinada, JNTUK - Kakinada, India
 
PDF
Effective CMake
Daniel Pfeifer
 
PPTX
Custom gutenberg block development in react
Imran Sayed
 
PPTX
Codeinator
Muhammed Thanveer M
 
PPTX
Intro To C++ - Class 08 - Separate Files & Set Functions
Blue Elephant Consulting
 
PDF
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
Idiomatic Gradle Plugin Writing
Schalk Cronjé
 
PDF
CMake - Introduction and best practices
Daniel Pfeifer
 
PPT
An introduction to maven gradle and sbt
Fabio Fumarola
 
CMake_Tutorial.pdf
Thejeswara Reddy
 
Intro To C++ - Class 07 - Headers, Interfaces, & Prototypes
Blue Elephant Consulting
 
00-intro-to-classes.pdf
TamiratDejene1
 
Apache Calcite (a tutorial given at BOSS '21)
Julian Hyde
 
Reusable Ruby • Rt 9 Ruby Group • Jun 2012
skinandbones
 
Python with Firebird: FDB driver 101
Marius Adrian Popa
 
Building services using windows azure
Suliman AlBattat
 
Objective-C Is Not Java
Chris Adamson
 
Gradle - small introduction
Igor Popov
 
Creational pattern 2
Naga Muruga
 
Object Oriented Programming using C++ - Part 2
University College of Engineering Kakinada, JNTUK - Kakinada, India
 
Effective CMake
Daniel Pfeifer
 
Custom gutenberg block development in react
Imran Sayed
 
Intro To C++ - Class 08 - Separate Files & Set Functions
Blue Elephant Consulting
 
CFCamp2025 - Keynote Day 1 led by Luis Majano.pdf
Ortus Solutions, Corp
 
Idiomatic Gradle Plugin Writing
Schalk Cronjé
 
CMake - Introduction and best practices
Daniel Pfeifer
 
An introduction to maven gradle and sbt
Fabio Fumarola
 

More from Ortus Solutions, Corp (20)

PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
June Webinar: BoxLang-Dynamic-AWS-Lambda
Ortus Solutions, Corp
 
PDF
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
What's-New-with-BoxLang-Brad Wood.pptx.pdf
Ortus Solutions, Corp
 
PDF
Getting Started with BoxLang - CFCamp 2025.pdf
Ortus Solutions, Corp
 
PDF
What's New with BoxLang Led by Brad Wood.pdf
Ortus Solutions, Corp
 
PDF
Vector Databases and the BoxLangCFML Developer.pdf
Ortus Solutions, Corp
 
PDF
Using cbSSO in a ColdBox App Led by Jacob Beers.pdf
Ortus Solutions, Corp
 
PDF
Use JSON to Slash Your Database Performance.pdf
Ortus Solutions, Corp
 
PDF
Portable CI wGitLab and Github led by Gavin Pickin.pdf
Ortus Solutions, Corp
 
PDF
Tame the Mesh An intro to cross-platform tracing and troubleshooting.pdf
Ortus Solutions, Corp
 
PDF
Supercharging CommandBox with Let's Encrypt.pdf
Ortus Solutions, Corp
 
PDF
Spice up your site with cool animations using GSAP..pdf
Ortus Solutions, Corp
 
PDF
Passkeys and cbSecurity Led by Eric Peterson.pdf
Ortus Solutions, Corp
 
PDF
Legacy Code Nightmares , Hellscapes, and Lessons Learned.pdf
Ortus Solutions, Corp
 
PDF
Integrating the OpenAI API in Your Coldfusion Apps.pdf
Ortus Solutions, Corp
 
PDF
Hidden Gems in FusionReactor for BoxLang, ACF, and Lucee Users.pdf
Ortus Solutions, Corp
 
PDF
Geting-started with BoxLang Led By Raymon Camden.pdf
Ortus Solutions, Corp
 
PDF
From Zero to CRUD with ORM - Led by Annette Liskey.pdf
Ortus Solutions, Corp
 
PDF
CommandBox WebSockets - and SocketBox.pdf
Ortus Solutions, Corp
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
June Webinar: BoxLang-Dynamic-AWS-Lambda
Ortus Solutions, Corp
 
BoxLang-Dynamic-AWS-Lambda by Luis Majano.pdf
Ortus Solutions, Corp
 
What's-New-with-BoxLang-Brad Wood.pptx.pdf
Ortus Solutions, Corp
 
Getting Started with BoxLang - CFCamp 2025.pdf
Ortus Solutions, Corp
 
What's New with BoxLang Led by Brad Wood.pdf
Ortus Solutions, Corp
 
Vector Databases and the BoxLangCFML Developer.pdf
Ortus Solutions, Corp
 
Using cbSSO in a ColdBox App Led by Jacob Beers.pdf
Ortus Solutions, Corp
 
Use JSON to Slash Your Database Performance.pdf
Ortus Solutions, Corp
 
Portable CI wGitLab and Github led by Gavin Pickin.pdf
Ortus Solutions, Corp
 
Tame the Mesh An intro to cross-platform tracing and troubleshooting.pdf
Ortus Solutions, Corp
 
Supercharging CommandBox with Let's Encrypt.pdf
Ortus Solutions, Corp
 
Spice up your site with cool animations using GSAP..pdf
Ortus Solutions, Corp
 
Passkeys and cbSecurity Led by Eric Peterson.pdf
Ortus Solutions, Corp
 
Legacy Code Nightmares , Hellscapes, and Lessons Learned.pdf
Ortus Solutions, Corp
 
Integrating the OpenAI API in Your Coldfusion Apps.pdf
Ortus Solutions, Corp
 
Hidden Gems in FusionReactor for BoxLang, ACF, and Lucee Users.pdf
Ortus Solutions, Corp
 
Geting-started with BoxLang Led By Raymon Camden.pdf
Ortus Solutions, Corp
 
From Zero to CRUD with ORM - Led by Annette Liskey.pdf
Ortus Solutions, Corp
 
CommandBox WebSockets - and SocketBox.pdf
Ortus Solutions, Corp
 
Ad

Recently uploaded (20)

PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Linux Certificate of Completion - LabEx Certificate
VICTOR MAESTRE RAMIREZ
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Ad

Customize your Runtime Creating your first BoxLang Module.pdf

  • 1. WELCOME Into the Box 2025: The Future is Dynamic!
  • 2. www.intothebox.org GET STARTED Creating your first BoxLang Module Customize your Runtime
  • 3. Brad Wood • Lead developer of CommandBox CLI • BoxLang Framework Architect • I’ve made 9,722 commits on GitHub since 2011 Senior Software Architect [email protected] @bdw429s
  • 4. ● BoxLang’s entire runtime is modular and extensible ● This was the case from day one of this project ● We have a ModuleService which is very similar to ColdBox/CommandBox/ContentBox, but at the runtime level ● The BoxLang core allows anything to be dynamically registered ● Modules can be written entirely in Java, in BoxLang, or in a mix of both. You choose! ● Ortus has written dozens of “official” modules ● You can write your own private or public modules ● Publish your modules directly to ForgeBox for the world to use BoxLang Modules
  • 5. ● BIFs (Built In Functions) ● Components (formerly known as tags) ● Classes ● Interceptors (listening to core BL runtime event announcements) ● Custom Components (AKA Custom Tags) ● Jars ● Configuration ● Caches ● JDBC Drivers ● Custom Contexts/scopes BoxLang Modules
  • 6. ● Default locations ○ boxlang_modules/ folder in the working directory ○ modules/ folder inside the BoxLang home folder ● You can configure additional folders in the boxlang.json file ● You can configure additional folders via env variable Module Locations
  • 7. ● A folder ● A ModuleConfig.bx class ○ configure() ■ settings ■ interceptors ○ onLoad() ○ onUnload() ● bifs/ folder ● components/ folder ● libs/ folder Module Structure The only requirement is the ModuleConfig.bx Everything else is optional!
  • 8. ● A folder ● A ModuleConfig.bx class ○ configure() ■ settings ■ interceptors ○ onLoad() ○ onUnload() ● bifs/ folder ● components/ folder ● libs/ folder Module Structure
  • 9. ● configure() method ○ Runs when module is registered, but before it’s activated. Responsible for creating settings structure which defines default settings for the module. The user can override these in their BoxLang config! ● onLoad() method ○ Runs when the module activates and can register additional items with the runtime, or setup anything the module needs ● onUnload() method ○ Runs when the module is unloaded (or the runtime shuts down). Clean up and unregister any custom items. ModuleConfig.bx
  • 10. function configure() { variables.settings = { mySetting= "value", anotherSetting= "another value" } } Module Settings ModuleConfig .bx
  • 11. { "modules": { "myModule": { "settings": { "mySetting": "override value" } } } } Module Settings Override boxlang.json
  • 12. function onLoad() { boxRuntime.getConfiguration().registerMapping( "/foobar", "C:/foo/bar"); println( "This module is LOADED!" ) } Module onLoad ModuleConfig.bx
  • 13. ● Every module gets an automatic class mapping created that points to the root of the module ● /bxModules/moduleName/ ● Customize the mapping name in your ModuleConfig.bx this.mapping = "waffle" ● You can access files inside the module fileRead( "/bxModules/myModule/resources/settings.json" ) ● You can create classes from inside the module new bxModules.myModule.models.FooService() Automatic Mapping
  • 14. ● Each module has a dedicated class loader, pointed at the lib/ folder. ● This is for 3rd party jars, or even custom Java classes you write ● Each module is an “island” so they won’t cloud the system classloader with potentially different versions of the same library ● There is a namespace registered for Java class paths new com.foo.JavaClass@myModule() Module Classloader
  • 15. There is not a specific convention for custom tags, but since there is a mapping created that points to the root of the module and custom tags are searched for in any mapping, you can just place a .bxm or .bxs folder in the root of your module and it will be usable as a custom component/tag. Module Custom Components
  • 16. ● BIFs -> Built In Functions ● First-class headless global functions like now() or fileRead() ● You can OVERWRITE core BIFs. Be careful! With great power comes great responsibility. ● Add bx class to bifs/ folder ● Name of class is name of BIF ● Needs @BoxBIF annotation ● invoke() method runs it ● BIF arguments are passed along to the invoke() method Register BIFs
  • 17. import ortus.boxlang.runtime.types.DateTime; @BoxBIF class { function invoke(){ return new DateTime(); } } BIF Example bifs/Now.bx
  • 18. ● Create one alias for the BIF with @BoxBIF( "nowButCooler" ) ● Create many aliases with @BoxBIF( [ "nowButCooler", "now2point0", "nowBrad" ] ) BIF Aliases
  • 19. ● Register BIF as member method on a type @BoxMember( "array" ) ● If the BIF name starts with the type name, then the member method removes that text from the name arrayAppend() becomes just myArr.append() ○ Get fancy @BoxMember( { "string": { "name": "append", "objectArgument": "string" } }) BIF Member Methods
  • 20. @BoxBIF @BoxMember( "array" ) class { function invoke( Array arr, string str ){ arr.append( str.ucase() ); return arr; } } BIF Member Example bifs/ArrayAppendUcase.bx
  • 21. myArr = []; arrayAppendUcase( myArr, "brad" ) myArr.appendUcase( "brad" ) BIF Member Example
  • 22. ● Components -> used to be called tags ● Components have both a template and a script sytnax ● First-class global like bx:http or bx:mail ● You can OVERWRITE core components. Be careful! ● Add bx class to components/ folder ● Name of class is name of component ● Needs @BoxComponent annotation ● invoke() method runs it Register Components (tags)
  • 23. Component Annotations @BoxComponent @BoxComponent( "MyAlias" ) @BoxComponent( "MyAlias", "AnotherAlias" ) @AllowsBody( false ) @RequiresBody( true )
  • 24. ● invoke() arguments ○ context - The BoxLang Context ○ Struct attributes - The attributes passed by the user ○ body - A function that represents the body of the component ○ Struct executionState - Data about execution Component invoke() method
  • 25. @BoxComponent @AllowsBody( false ) class { function invoke( context, attributes, body, executionState ){ echo( "hello " & attriutes.name ?: "world" ); } } Component Example components/SayHello.bx
  • 26. <!--- Templating ---> <bx:sayHello name="Brad"> // Scripting bx:sayHello name="Brad"; Component Example
  • 27. @BoxComponent @RequiresBody( true ) class { function invoke( context, attributes, body, executionState ){ var buffer = newBuffer(); var bodyResult = processBody( context, body, buffer ); // handle return, break, or continue if ( bodyResult.isEarlyExit() ) { return bodyResult; } echo( buffer.toString().Ucase() ); } } Component Example 2 components/Scream.bx
  • 28. <!--- Templating ---> <bx:scream> I like spam! </bx:scream> // Scripting bx:sayHello { echo( "I like spam!" ); } Component Example 2
  • 29. Thank You! The Future of Modern Development Starts Here, with you! 🚀