[ColdBox 3.7.0] Using wirebox to inject a structure of objects.

Is there currently a way to use the mapping DSL to define a structure that contains several objects and then map that structure to some value so that it can be injected into another object?

I would like to use a structure to define a mapping of names to repository objects and inject that structure into a component that can then lookup a repository dynamically, by name.


Hmm, my first thought is for you to wrap that whole structure into a repo service that takes care of collecting all the repos, storing them in a structure, and finding the correct one. Then just inject the service and call its methods to get your repo.

If you really want to do it your way, I would recommend you write a simple provider class that gathers the repos and wraps them in a structure. You define a provider with the .asProvider() DSL. WireBox will create the provider class and call its get() method. That will allow you to do some building of your own before returning the final result. Just inject the provider object and WireBox will call it.




ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Thanks for the suggestion Brad. I ended up implementing a factory component that is responsible for constructing the structure in wirebox.cfc as is suggested in the accepted answer here: http://stackoverflow.com/questions/11660640/what-is-coldspring-map-list-eqv-in-wirebox