[coldbox 3.5.3] Referencing datasource bean in wirebox config.cfc

I am sure this is a simple one and please direct me to the appropriate documentation if it is out there…I have datasources setup by environment in the ColdBox config.cfc; in my Wirebox binder I want to map a service and pass in the datasource name as an argument but based on the environment setting:

map(“Service”).to(“model.xyz.Service”).initWith(dsn=???); what is the syntax for setting dsn = to the ColdBox datasource using getDatasource(“DSN_alias”)?

Thanks for the help.


Returns a struct of all the datasources in your config.cfc.

Thanks for the reply, Aaron. It seems that I don’t have access to ColdBox in my Wirebox.cfc (binder). Any attempts to reference ‘controller’ in it throws a ‘variable CONTROLLER is undefined’ error.

Ah, my bad. That is how to reference the controller in a modules config.cfc.

How are you defining the datasource in the environment config, like this?

// datasource settings

datasources = {

“system”:{ name:“datasource_name”, dbType:“mysql”}


If so, try this:

I appreciate the advice, Phil. Does your example work for you because when attempt this I get an error that property datasources does not exist; it is as if ColdBox is not available to the Wirebox binder so I cannot call CBX functions nor reference settings set in the CBX config.cfc.

Why would that be? I am pretty sure the documentation said that CBX is available to Wirebox and in the CBX Lifecycle diagrams it appears that Wirebox is instantiated AFTER CBX is loaded. Maybe this is happening because I am in the Wirebox config(binder).cfc?