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.
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!
The default namespace is not specifying one. This namespace is used to retreive either named mappings or full component paths.
When WireBox builds CFC instances, it is important to know the order of operations. This controls when injected dependencies are available for you to use.
Component is instantiated with createObject()
CF automatically runs the pseudo constructor (any code outside the a method declaration)
The init()
method is called (if it exists), passing any constructor args
Property (mixin) and setting injection happens
The onDIComplete()
method is called (if it exists)
Based on that order, you can see that injected dependencies (except constructor ones) are not available yet to use in the init()
and you must wait to use them in the onDIComplete()
method.
Talk and get objects from the current wirebox injector
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:
This DSL namespace interacts with the loaded LogBox instance.
This DSL namespace is only active if using CacheBox or a ColdBox application context.
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
DSL
Description
empty
Same as saying id. Get a mapped instance with the same name as defined in the property, argument or setter method.
id
Get a mapped instance with the same name as defined in the property, argument or setter method.
id:{name}
Get a mapped instance by using the second part of the DSL as the mapping name.
id:{name}:{method}
Get the {name} instance object, call the {method} and inject the results
model
Get a mapped instance with the same name as defined in the property, argument or setter method.
model:{name}
Get a mapped instance by using the second part of the DSL as the mapping name.
model:{name}:{method}
Get the {name} instance object, call the {method} and inject the results
@module
Get the object from a specific module. The name of the alias is from the property used
DSL
Description
wirebox
Get a reference to the current injector
wirebox:parent
Get a reference to the parent injector (if any)
wirebox:eventManager
Get a reference to injector's event manager
wirebox:binder
Get a reference to the injector's binder
wirebox:populator
Get a reference to a WireBox's Object Populator utility
wirebox:scope:{scope}
Get a direct reference to an internal or custom scope object
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:property:{name}
Retrieve one key of the properties structure
DSL | Description |
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. |
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 |
DSL | Description |
cachebox | Get a reference to the application's CacheBox instance |
cachebox:{name} | Get a reference to a named cache inside of CacheBox |
cachebox:{name}:{objectKey} | Get an object from the named cache inside of CacheBox according to the objectKey |
Interact with Java directly
DSL
Description
java:{class}
Get a reference or instantiate the java {class} for you.
DSL | Description |
coldbox | Get the coldbox controller reference |
DSL | Description |
coldbox:configSettings | Get a reference to the application's configuration settings |
coldbox:dataMarshaller | Get a reference to the application's data marshaller |
coldbox:flash | Get a reference to the application's flash scope object |
coldbox:fwSetting | Get a reference to the framework settings |
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: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:renderer | Get a reference to a ColdBox renderer object |
DSL | Description |
coldbox:fwSetting:{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 |
coldbox:moduleConfig:{module} | Inject the entire {module} configurations structure |