Registering a Custom DSL
To register a custom namespace in WireBox, place the following configuration in the wirebox struct defined within the configure() method of your WireBox binder CFC. in a ColdBox app, this is /config/WireBox.cfc. Alternatively, you can use the mapDSL() call in the configure() method.
/config/WireBox.cfc
1
component extends="coldbox.system.ioc.config.Binder" {
2
3
function configure(){
4
wirebox = {
5
// DSL Namespace registrations
6
customDSL = {
7
ortus = "path.model.dsl.MyDSL"
8
}
9
};
10
11
// Or here...
12
mapDSL("ortus","path.model.dsl.MyDSL");
13
}
14
}
Copied!
If you want to register a custom DSL namespace from a module, you can make the same call via the binder reference that is provided to your ModuleConfig.cfc.
ModuleConfig.cfc
1
component {
2
function configure() {
3
binder.mapDSL("ortus","path.model.dsl.MyDSL");
4
}
5
}
Copied!
Now I can use the ortus DSL Namespace in my mappings DSL and even my annotations, isn't that cool!
1
// inject it into a CFC
2
property name="funky" inject="ortus:funkyObject";
3
4
// map it in your WireBox Binder
5
map("Luis")
6
.toDSL("ortus:funkyObject");
Copied!

Dynamic Custom DSL Registration

Injectors allow you to register custom DSLs at runtime by using the registerDSL() method on any injector.
1
// Register Custom DSL
2
controller.getWireBox()
3
.registerDSL( namespace="javaloader", path="app.model.JavaLoaderDSL" );
Copied!
Last modified 2yr ago