Wirebox DSL: model:{name}:{method}

Hello Guys,

I’ve been reading about the autowire DSL


Which seems great, but when is the method actually called? Is it invoked just once and then the cached version passed in each time?

Is it called on the first time it’s referenced per-request? or every time you reference it?



I believe the method is called once per injection. That means if you were injecting it into a transient the method is called once for each transient it is injected into. The result of that method is stored in the variable scope you specified. If you injected into a singleton, the method would be called once when the singleton was first created.

Thanks Brad, I understand.


Since we are on this topics what about this update

Model:mapping:method:{arg1=val1, arg=val2}

I was thinking that this morning Luis! Would be a nice edition i expect, although have no specific use case myself for it at the moment.


The next thing you know, you'll end up needing to do something with nested DSL like this:

Model:mapping:method:{arg1={coldbox:setting:mySetting}, arg2={model:myDAO}, arg3={this}}

I guess it will boil down to whether or not you want people to be able to do everything with DSL that they can do with a mapping.

On a slightly different topic, what do you think about passing a reference to the method as opposed to passing the return value? We created a wrapper around our util library that uses onMissingMethod to return a reference to methods in the util CFC so we can inject a single utility method into a CFC and access it as utilityMethodName() instead of utilityLibrary.utilityMethodName().