RE: [coldbox:12584] Singleton vs Application

Functionally I believe it’s the same. Just two different ways to skin the cat. When you set a component as a singleton, WireBox will stick it in CacheBox as an eternal object. Depending on what cache provider you are using with CacheBox, your object will mostly likely end up in the application or server scope anyway.

Thanks!

~Brad

Actually that’s not accurate.

Singletons in WireBox are modeled by the Singleton Scope which lives inside of the WireBox Injector, the injector manages their persistence and a singleton scope exists per Injector. Application scope means the object will be placed in the application scope directly. There is only one scope per Application.

So technically you can instantiate more than 1 injector and have different singleton regions.

CacheBox is another scope that allows for time persisted objects to exist and managed at the cache level.

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Out of curiosity, Luis, what is the use case for having multiple
Singletons created by different injectors?

Judah

Each injector controls different persistence levels and levels of visibility, maybe you are using a hierarchy of injectors where you need separation of persistence like relationships between a parent and child injector. You don’t want your singleton objects to intermix and override each other. You could have the child injector completely wire an object differently than the parent but using the same class.

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano