All pages
Powered by GitBook
1 of 7

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

CacheBox Namespace

This DSL namespace is only active if using CacheBox or a ColdBox application context.

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

property name="cacheFactory" inject="cacheBox";
property name="cache" inject="cachebox:default";
property name="data" inject="cachebox:default:myKey";

Model Object Namespace

The default namespace is not specifying one. This namespace is used to retreive either named mappings or full component paths.

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

// 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";

Injection DSL

Before we start building our objects, we need to understand how WireBox injects dependencies for us. You can define injections using the configuration inside the binder (like any other DI framework), but the easiest approach is to use our injection annotation and conventions (called the injection DSL). The injection DSL can be applied to cfproperty, cfargument, cffunction or called via getInstance() as we saw previously.

You can utilize the injection DSL by adding an attribute called inject to properties, arguments and functions. This attribute is like your code shouting, "Hey, I need something here. Hello! I need something!" That something might be another object, setting, cache, etc. The value of the inject attribute is a string that represents the concept of retrieving an object mapped in WireBox. It can be an object path, an object ID, a setting, a datasource, custom data, etc.

Info: If you don't like annotations or find them obtrusive, you don't have to use them :). Just leverage the WireBox binder to define dependencies instead.

Here are a few examples showing how to apply the injection DSL.

Property Annotation

property name="service" inject="MyService";

Constructor Argument Annotation

<cfargument name="setting" inject="MyService">
/**
* @myDAO.inject model:MyDAO
*/
function init(myDAO){
}

Setter Method Annotation

function setMyservice(MyService) inject="MyService"{
    variables.MyService = arguments.MyService;
}

You can learn more about the supported injection DSLs in the WireBox Injection DSL documentation.

LogBox Namespace

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}";

EntityService Namespace

This injection namespace comes from the cborm module extensions (https://github.com/ColdBox/cbox-cborm). It gives you the ability to easily inject base ORM services or binded virtual entity services for you:

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.

// Generic ORM service layer
property name="genericService" inject="entityService";
// Virtual service layer based on the User entity
property name="userService" inject="entityService:User";

ColdBox Namespace

This namespace is a combination of namespaces that are only active when used within a ColdBox application:

DSL

Description

coldbox

Get the coldbox controller reference

coldbox:flash

Get a reference to the application's flash scope object

coldbox:setting:{setting}

Get the coldbox application {setting} setting and inject it

coldbox:fwSetting:{setting}

Get a ColdBox setting {setting} and inject it

coldbox:setting:{setting}@{module}

Get the coldbox application {setting} from the {module} and inject it

coldbox:datasource:{alias}

Get a new datasource struct according to {alias}

coldbox:loaderService

Get a reference to the loader service

coldbox:requestService

Get a reference to the request service

coldbox:handlerService

Get a reference to the handler service

coldbox:interceptorService

Get a reference to the interceptor service

coldbox:moduleService

Get a reference to the ColdBox Module Service

coldbox:renderer

Get the ColdBox rendering engine reference

coldbox:dataMarshaller

Get the ColdBox data marshalling reference

coldbox:interceptor:{name}

Get a reference of a named interceptor {name}

coldbox:configSettings

Get the application's configuration structure

coldbox:fwSettings

Get the framework's configuration structure

coldbox:fwSetting:{setting}

Get a setting from the ColdBox settings instead of the Application settings

coldbox:moduleSettings:{module}

Inject the entire {module} settings structure

coldbox:moduleConfig:{module}

Inject the entire {module} configurations structure

// some examples
property name="moduleService" inject="coldbox:moduleService";
property name="producer" inject="coldbox:interceptor:MessageProducer";
property name="appPath" inject="coldbox:fwSetting:ApplicationPath";

WireBox Namespace

Talk and get objects from the current wirebox injector

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

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";