RE: [coldbox:17577] Of Singletons and Transfer of Payload

I think you misunderstand the meaning of “singleton”. There can only be one instance of a singleton object for the entire application. That means that if you expect to have more than one person logged into your site at once, you do not want the logged in user to be a singleton. I actually manually persist my logged in user object with the sessionStorage plugin, but you could also probably do it by setting up your mapping to be .into(this.SCOPES.SESSION);

As far as how to get the siteUser object populated, I would recommend a custom service method (perhaps just in getByCredentials) that populated the query directly into the session-scoped siteUser object in the first place (instead of a transient, or NOSCOPE user object)

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Yes…I thought that might be the case but the documentation, at least as I could not find, does not make a clear analogy between singleton and even pseudo application scope…but I thought that’s what the pattern suggested. So other than true application level objects that all users need to share, it sounds like only my service models needs to be singletons and the beans will generally be transient in some way.

But the getmemento technique is useful for getting object payloads and I found some good code to traverse inherited properties, so I think I’ll hang onto that anyway.

Thanks Brad for clearing that up.

Mike