Handler caching, inject object problem


I have a question regarding cached handlers and injected components.

I have a component, which is operating as a store.


component scope=“session” hint=“this store can store some objects…”{

LightboxBasketStore function init(){
return this;



To check when my handler or store were created, I added a createDate.
My handler got the store injected:

property name=“LBStore” inject=“id:LightboxBasketStore@aki”;


When I disable handler caching in my Coldbox.cfc [coldbox.handlerCaching = false;] my handler is created on each request, but my store keeps the same. So with different sessions on different browsers, each user has its own store. (Correct)

Now I want my handler to be persistent, with own storage for each user. I enable handler caching. Now the handler is not created on each request. So in defferent browsers, I get the same handler, but as well the same store. (wrong!)

Did I misunderstand something? Do I need to inject the store into session scope? I expected it to be created for each user, because the store itself hast the ‘scope=“session”’ attribute.

Hope to get help soon,
thx in advance. Andy

This is what is known as scope widening. We talk about that exact issue in the Wirebox docs.

Opps, wasn’t done with that message yet :slight_smile:

We talk about the issue in the Wirebox docs. http://wiki.coldbox.org/wiki/WireBox.cfm#Scope_Widening_Injection

You solve it with a provider, which is outlined in the docs. Let me know if that doesn’t make sense after reading that I can explain more throughly.


Yes, read the article Curt mentioned. Basically, when you inject a volatile object like a transient or session scope object into a singleton. That object gets absorbed into the singleton due to java hard references.

Therefore, you can only inject a provider of those type of objects or retrieve the object.

Luis Majano
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano