Of Singletons and Transfer of Payload

Ok, maybe I don’t need to be doing this, but I wanted to toss this out to the group to see if this makes sense.

I have a user object, service and dao to support the user table interaction and everything but the user object itself is noted as a singleton type. I do this because by it’s very nature, I could often have several user objects (one for me the actual physical user but perhaps another user object for my proxy actions against another account or a small collection of user objects derived from a “get all” kind of query).

Now, I wirebox map “siteuser” as a singleton scoped user object that represents me for the session, the person logged in.

However, since the service/dao objects are designed to return user objects, I assumed there would be no good way to “replace” the “siteuser” instance of user with the user instance gathered from the service when I try logging in so I created a base class for user that has a get/set memento set of methods that will scrape out the current property settings of the object and allow me to simple “set” them into another instance…so for example (abbreviated):

newuser = userService.getByCredentials(username,passcode);
if (newuser.IsValid()) {

So, is that necessary? Generally I see most of my services being singletons but not the objects (think beans) that they return…but being only a little while into CB, I was thinking it was definitely worth tossing this idea out to make sure there is not a simpler way, or is there something I’m overlooking…I get confused often.

Thanks for any input.

Mike Craig