Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
The injection DSL is a domain specific language that denotes what to inject in the current placeholder: property, argument, or method via the inject annotation. This injection DSL not only can it be used via annotations but also via our mapping DSL whenever a dsl argument can be used. This DSL is constructed by joining words separated by a : colon. The first part of this string is what we will denote as the injection DSL Namespace.
inject="{namespace}:extra:extra:extra"Every cfproperty can be annotated with our injection annotations:
@inject : The injection DSL
@scope : The visibility scope to inject the dependency into. By default it injects into variables scope
You can also use annotated constructor arguments with the inject annotation.
Caution In full script components, annotating inline arguments is broken in Adobe ColdFusion 9. You will have to annotate them via the alternative annotation syntax in ColdFusion 9 via the javadocs style comments.
You can also annotate setter methods with the inject annotation to provide injections
WireBox offers a wide gamut of annotation namespaces you can use in your CFML applications and ColdBox applications. However, we took it a step further and allowed you to create your own custom DSL namespaces making your annotations come alive!
property name="service" inject="id:MyService";
property name="TYPES" inject="id:CustomTypes" scope="this";
property name="roles" inject="id:RoleService:getRoles" scope="instance";<--- Via tag based annotations --->
<cffunction name="init" returntype="any" output="false">
<cfargument name="myService" inject="UserService">
<cfargument name="cache" inject="cachebox:default">
</cffunction>
// Via script but alternative method as inline annotations are broken in ACF
/**
* Init
* @myService.inject UserService
* @cache.inject cachebox:default
*/
function init(required myService, required cache){
}<--- Via tag based annotations --->
<cffunction name="setService" returntype="any" output="false" inject="UserService">
<cfargument name="service">
</cffunction>
function setService(required service) inject="UserService"{
variables.service = arguments.service;
}DSL
Description
coldbox:asyncManager
The global Async Manager
coldbox:appScheduler
The global application scheduler object
coldbox:configSettings
Get a reference to the application's configuration settings
coldbox:coldboxSettings
The global ColdBox internal settings struct
coldbox:dataMarshaller
Get a reference to the application's data marshaller
DSL
Description
coldbox:coldboxSetting:{setting}
Get a setting from the ColdBox settings instead of the Application settings
coldbox:setting:{setting}
Get the coldbox application {setting} setting and inject it
coldbox:setting:{setting}@{module}
Get the coldbox application {setting} from the {module} and inject it
coldbox:interceptor:{name}
Get a reference of a named interceptor {name}
coldbox:moduleSettings:{module}
Inject the entire {module} settings structure
DSL
Description
coldbox:moduleSettings:{module}:setting
Inject a single setting from a module
DSL
Description
coldbox
Get the coldbox controller reference
// some examples
property name="logbox" inject="logbox";
property name="rootLogger" inject="logbox:root";
property name="logger" inject="logbox:logger:model.com.UserService";
property name="moduleService" inject="coldbox:moduleService";
property name="producer" inject="coldbox:interceptor:MessageProducer";
property name="producer" inject="interceptor:MessageProducer";
property name="appPath" inject="coldbox:fwSetting:ApplicationPath";coldbox:flash
Get a reference to the application's flash scope object
coldbox:handlerService
Get a reference to the handler service
coldbox:interceptorService
Get a reference to the interceptor service
coldbox:loaderService
Get a reference to the loader service
coldbox:moduleService
Get a reference to the ColdBox Module Service
coldbox:renderer
Get a reference to a ColdBox renderer object
coldbox:requestContext
Get a reference to the current transient request context
coldbox:requestService
Get a reference to the request service
coldbox:router
Get a reference to the application router object
coldbox:routingService
Get a reference to the routing service
coldbox:schedulerService
Get a reference to the scheduler service
coldbox:moduleConfig:{module}
Inject the entire {module} configurations structureF
You can also request Java objects from the injection dsl.
DSL
Description
java:{class}
Get a reference to the passed in class
property name="duration" inject="java:java.time.Duration";In order to use this namespace you will need the cborm module installed in your application: install cborm
Gives you the ability to easily inject base ORM services or binded virtual entity services for you:
DSL
Description
Inject object providers, please refer to our in this guide.
entityService
Inject a BaseORMService object for usage as a generic service layer
entityService:{entity}
Inject a VirtualEntityService object for usage as a service layer based off the name of the entity passed in.
// Generic ORM service layer
property name="genericService" inject="entityService";
// Virtual service layer based on the User entity
property name="userService" inject="entityService:User";DSL
Description
provider
Build an object provider that will return the mapping according to the property, method or argument name.
provider:{name}
Build an object provider that will return the {name} mapping.
provider:{injectionDSL}
Build an object provider that will return the object that the {injectionDSL} refers to
// using id
property name="timedService" inject="provider:TimedService";
// using DSL
property name="timedService" inject="provider:logbox:logger:{this}";This DSL namespace interacts with the loaded LogBox instance.
DSL
Description
logbox
Get a reference to the application's LogBox instance
logbox:root
Get a reference to the root logger
logbox:logger:{category name}
Get a reference to a named logger by its category name
logbox:logger:{this}
Get a reference to a named logger using the current target object's path as the category name
property name="logbox" inject="logbox";
property name="log" inject="logbox:root";
property name="log" inject="logbox:logger:myapi";
property name="log" inject="logbox:logger:{this}";The executor namespace is both available in ColdBox and WireBox standalone and it is used to get references to created asynchronous executor thread pools.
DSL
Description
executor
Inject an executor using the property name as the key
executor:{name}
Inject an executor by name
property name="coldbox-tasks" inject="executor";
property name="taskExecutor" inject="executor:myTasks";DSL
Description
coldbox:appScheduler
Get a reference to the global application scheduler
coldbox:asyncManager
Get a reference to the ColdBox Async Manager
coldbox:configSettings
Get the application's configuration structure
coldbox:coldboxSettings
Get the framework's configuration structure
coldbox:dataMarshaller
Get the ColdBox data marshaling reference
DSL
Description
coldbox:interceptor:{name}
coldbox:moduleSettings:{module}
Inject the entire {module} settings structure
coldbox:moduleConfig:{module}
Inject the entire {module} configurations structure
coldbox:coldboxSetting:{setting}
Get a ColdBox setting {setting} and inject it
coldbox:setting:{setting}
Get the ColdBox application {setting} setting and inject it
DSL
Description
coldbox:moduleSettings:{module}:{setting}
Get a module setting. Very similar to the 3rd level dsl
DSL
Description
coldbox
Get the ColdBox controller reference
// some examples
property name="moduleService" inject="coldbox:moduleService";
property name="producer" inject="coldbox:interceptor:MessageProducer";
property name="appPath" inject="coldbox:coldboxSetting:ApplicationPath";coldbox:flash
Get a reference to the application's flash scope object
coldbox:handlerService
Get a reference to the handler service
coldbox:interceptorService
Get a reference to the interceptor service
coldbox:loaderService
Get a reference to the loader service
coldbox:moduleService
Get a reference to the ColdBox Module Service
coldbox:moduleConfig
Get a reference to the entire modules configuration struct
coldbox:renderer
Get the ColdBox rendering engine reference
coldbox:requestService
Get a reference to the request service
coldbox:requestContext
Get a reference to the current request context object in the request.
coldbox:router
Get a reference to the application global router.cfc
coldbox:routingService
Get a reference to the Routing Service
coldbox:schedulerService
Get a reference to the Scheduler Service
coldbox:setting:{setting}@{module}
Get the ColdBox application {setting} from the {module} and inject it
id
Get a mapped instance with the same name as defined in the property, argument or setter method.
model
Get a mapped instance with the same name as defined in the property, argument or setter method.
DSL
Description
model:{name}
Get a mapped instance by using the second part of the DSL as the mapping name.
id:{name}
Get a mapped instance by using the second part of the DSL as the mapping name.
DSL
Description
model:{name}:{method}
Get the {name} instance object, call the {method} and inject the results
id:{name}:{method}
Get the {name} instance object, call the {method} and inject the results
DSL
Description
empty
Same as saying id. Get a mapped instance with the same name as defined in the property, argument or setter method.
// Let's assume we have mapped a few objects called: UserService, SecurityService and RoleService
// Empty inject, use the property name, argument name or setter name
property name="userService" inject;
// Using the name of the mapping as the value of the inject
property name="security" inject="SecurityService";
// Using the full namespace
property name="userService" inject="id:UserService";
property name="userService" inject="model:UserService";
// Simple factory method
property name="roles" inject="id:RoleService:getRoles";DSL
Description
wirebox:asyncManager
Get a reference to the Async Manager
wirebox:binder
Get a reference to the injector's binder
wirebox:eventManager
Get a reference to injector's event manager
wirebox:objectMetadata
Inject the target object's metadata struct
wirebox:parent
Get a reference to the parent injector (if any)
DSL
Description
wirebox:child:{name}
Inject a child injector by name
wirebox:property:{name}
Retrieve one key of the properties structure
wirebox:scope:{scope}
Get a direct reference to an internal or custom scope object
DSL
Description
wirebox:child:{name}:{id}
Inject the id from the named child injector
wirebox:child:{name}:{dsl}
Inject the dsl from the named child injector
DSL
Description
wirebox
Get a reference to the current injector
property name="beanFactory" inject="wirebox";
property name="settings" inject="wirebox:properties";
property name="singletonCache" inject="wirebox:scope:singleton";
property name="populator" inject="wirebox:populator";
property name="binder" inject="wirebox:binder";
// Child Injectors
property name="categoryService" inject="wirebox:child:childInjector"property name="categoryService" inject="wirebox:child:childInjector:CategoryService"
property name="categoryService" inject="wirebox:child:childInjector:{DSL}"wirebox:properties
Get the entire properties structure the injector is initialized with. If running within a ColdBox context then it is the structure of application settings
wirebox:populator
Get a reference to a WireBox's Object Populator utility
wirebox:targetId
The target ID used when injecting the object