I was looking at your post on my phone over lunch, but looking closer at it now, I see the following lines:
mapDirectory(’/model.repositories’).asSingleton();
mapDirectory(’/model.services’).asSingleton();
You shouldn’t chain “asSingleton()” after “mapDirectory()”. asSingleton() will only apply to the last mapping which was processed, not all the mappings created from that directory.
I would recommend going the route of adding the singleton=true annotation in all your singleton CFCs. Your only other option is to map them all explicitly by name.
On a side note, Luis, what do you think about enhancing the WireBox binder so that asSingleton() and other chainable methods would work with mapDirectory()? If we changed currentMapping
to be an array of mappings, then mapDirectory() could append each mapping it creates and methods like asSingletion(), asEagerInit() could apply themselves to each mapping in the array. Just a thought.
Thanks!
~Brad