Configuring object with per user info
I haven't tried to do this yet, but does anybody know the correct idiom for doing the following.
Normally when I make a data access object it gets passed a DataSource, which is configured with username etc gotten from eg. config file.
But what if I need my DAO to be configured for each user with their credentials?
And the DataSource was just an example, I mean how is this supposed to be done with any resource (some general pattern), like LDAP etc. so that each user gets the "Manager" configured to access the underlying resource with his own credentials.
A solution using servlet APIs would be fine, of course better if it's more general.
In WebWork this kind of works by using (http)session scoped objects.
It would also be nice if the resource would be created once per session (so that a possible connection would't be done on every request)