Results 1 to 5 of 5

Thread: Configuring object with per user info

  1. #1
    Join Date
    Aug 2004
    Posts
    10

    Default Configuring object with per user info

    Hi,

    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)

  2. #2
    Join Date
    Aug 2004
    Posts
    10

    Default

    Hum, apparently this isn't possible, or not that important

    Seriously, hasn't anybody run into this problem?

  3. #3
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Take a look at org.springframework.jdbc.datasource.UserCredential sDataSourceAdapter
    This class is an adapter that apply user credentials for current thread and use these credentials for each getConnection.
    You can create simillar adapters for LDAP...
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  4. #4
    Join Date
    Aug 2004
    Posts
    10

    Default

    Thank you, looks promising at first glance.
    I had a problem similar to this earlier, and solved it using webwork IoC (which seems kind of spartan compared to spring)

  5. #5
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    On a general basis, if you need to do per-user scoping if resource usage, one technique is to associate the user specific info as a threadlocal variable, and then use it later. If you look at the Acegi Security Framework for example, coming in, it binds a SecurityContext security context object to the current thread, and then that is later (in the call graph) able to be used to do actions that rely on that user specific data...
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  2. JBoss 3.2.6 & Spring Deployment issues
    By difranr in forum Container
    Replies: 2
    Last Post: Sep 18th, 2005, 10:08 PM
  3. Replies: 2
    Last Post: Aug 26th, 2005, 12:54 AM
  4. DefaultAdvisorAutoProxyCreator skipping beans
    By youngm in forum Container
    Replies: 6
    Last Post: Apr 12th, 2005, 04:29 PM
  5. Replies: 13
    Last Post: Dec 7th, 2004, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •