getInstance() now accepts either dsl or name via the first argument and initArguments as second argument


The de facto input to all inject attribtues has always been dsl which makes a lot of sense. As such, people always expect to be able to use namespaces like `coldbox:setting;foo` by default anywhere they ask WireBox for something. The notable exception to this is the getInstance() call, which uses "name" as the first argument so the following doesn't work

Now, this is possible by switching to named params like so:

I think defaulting to name back when this was called getModel() made more sense, but there's really no point in not just allowing dsl for everything at this point. If anyone wants to specifically get a model (the exception, not the rule) they can get the old behavior back with

This will also allow for a cleaner syntax when providing init args to your model. I recommend that the first param be set to dsl but the getIstance() get updated to check for "" and if it exists and dsl is not passed, then we just do

behind the scenes which will provide for very nice backwards compatibility since both of these existing ColdBox 5 use cases would continue to work out of the box with zero app changes which probably accounts for 95% of the use cases.

This will technically be a breaking change, so it needs to happen in ColdBox 6.


Luis Majano
May 1, 2020, 4:48 PM

I am reviewing ways to do this, since there is always a rabbit hole, because the get by dsl ultimately either returns an object from a factory or delgates back to getInstance() again with the appropriate name. So we can’t remove the name.

Luis Majano
May 1, 2020, 4:49 PM

I might just prefer a dsl check, that if the name is a dsl, then get by dsl than deprecating it.

Brad Wood
May 1, 2020, 5:00 PM

I don’t quite understand why you can’t remove the name since it just does a subset of what dsl already does.

Brad Wood
May 1, 2020, 5:51 PM

Did you see my comment? Also, I’m worried about what you have done based on your change to the ticket title. This wasn’t just about what the first argument accepted, this was about simplfying all the arguments to make positioanl arguments better. One of the goals of this ticket is to be able to do this:

If all you did was leave both name and dsl but made name more flexible, then this ticket is not complete.

Luis Majano
May 1, 2020, 6:48 PM

That’s a good point. I didn’t read that part. I will reopen and addresss



Luis Majano


Brad Wood




Fix versions

Affects versions