ColdSpring and ColdBox IOCObjectCaching
This weekend I had a ColdSpring singletons caching problem. Like all caching problems, sometimes they occur, sometimes they do not......pfff......very difficult to reproduce.
ColdSpring threw errors on the method addBeanToSingletonCache in abstractBeanFactory.cfc. This method tries to store a singleton object in cache and if already exists, throws an error.
I asked Luis for help on this and he came up with the following answer/solution:
It seems that ColdSpring 1.1 had errors of that sort. I would try the 1.2 nightly build. What happens is that ColdSpring caches whenever a bean says singleton=true. Now, you can go into ColdBox advanced mode and use IOCObjectCaching. This basically means that all objects produced from ColdSpring become cached in the coldbox cache. So for example, in ColdSpring you say singleton=false, so ColdSpring just produces it, then on the cfcomponent metadata, you set the cacheTimeout=0 so it becomes a singleton in the coldbox cache. Then whenever you call for it from the ioc plugin, you just get it from the ColdBox cache and not ColdSpring anymore.
Luis' solution works like a charm. All caching is done by ColdBox now!!

you always rock man. Thats really cool way to cache the coldspring objects.
Now the SecurityService has a dependency on the UserService and the UserService can act on its own. If you set the singleton=false on the UserService, and you ask for it, Coldpsring creates it for you, gives it to you, ColdBox caches it and wallah. Cool right. Well, now you ask for a securityService, then Coldspring has to recreate the UserService because its not a singleton in the factory anymore.
You see the problem. So, you now have a problem that the IoC factory has to create the user service twice. Sometimes this is negligible. You just have to be aware of it.