Clearing singletons

33 visualizações
Ir para a primeira mensagem não lida

Jamie Salvatori

não lida,
30/07/2014, 19:22:2030/07/14
para col...@googlegroups.com
From time to time, we have to make small changes to CFCs that are loaded as singletons on our production server. We don't want to do a framework reinit on the production site, so what's the simplest programmatic way to clear a particular singleton and have it reloaded?

Would it be something like:

wirebox.getScopes()["SINGLETON"].getSingletons().remove(keyOfSingletonToRemove)

Has anybody implemented something like this? Or is there a better or more accepted way to do this on a production server?

TIA
Jamie

br...@bradwood.com

não lida,
30/07/2014, 19:27:4030/07/14
para col...@googlegroups.com
The injector has a method called clearSingletons()  so just do 
 
wirebox.clearSingletons();
 
I've never cleared a single singleton, but your code below will probably work.
 
However, PLEASE NOTE, that if you have injected a reference to your singleton into another CFC, that CFC will still keep its original reference.  
 
Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------
--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Harkirat

não lida,
21/11/2017, 19:24:0821/11/17
para ColdBox Platform


"However, PLEASE NOTE, that if you have injected a reference to your singleton into another CFC, that CFC will still keep its original reference." 

Is there a way to clear the references to the singletons that have been injected?

br...@bradwood.com

não lida,
21/11/2017, 19:27:4521/11/17
para col...@googlegroups.com
You could wrap every single injection in a provider.
 
property name="myService" inject="provider:myService";
 
It's a little messy but it would work because it asks WireBox for the instance every time.  

Thanks!

~Brad

ColdBox/CommandBox Developer Advocate
 
 
--------- Original Message ---------

Harkirat Singh

não lida,
21/11/2017, 19:45:5721/11/17
para col...@googlegroups.com
Thanks!

You received this message because you are subscribed to a topic in the Google Groups "ColdBox Platform" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/coldbox/pbwSFxo8dEU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to coldbox+u...@googlegroups.com.

To post to this group, send email to col...@googlegroups.com.
Responder a todos
Responder ao autor
Reencaminhar
0 mensagens novas