cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Cayenne with PerUserPoolDataSource
Date Mon, 04 Jun 2007 14:23:28 GMT
Hi Emilian,

> It these some way to make Cayenne use this (basically
> DataSource.getConnection(user,password) instead of
> DataSource.getConnection()) ?

Not out-of-the-box. But you can achieve that via a custom DataSource  
wrapper that channels DataSource.getConnection() to  
DataSource.getConnection(user,password):

class DataSourceDecorator implements DataSource {
   protected PerUserPoolDataSource delegate;

   public Connection getConnection() {
        // get user name and password via some custom mechanism, e.g.  
via a ThreadLocal...
        String userName = ...
        String password = ...
        return delegate.getConnection(userName, password);
   }

   .....
}


Such custom DataSource can be installed in runtime via a custom  
DataSourceFactory that can be configured for the DataNode in the  
Modeler:

http://cayenne.apache.org/doc/api/org/apache/cayenne/conf/ 
DataSourceFactory.html

Andrus


On Jun 4, 2007, at 4:16 PM, Emilian Bold wrote:

> Hy,
>
> I would like to use Cayenne with something like PerUserPoolDataSource
> [1]. Basically I would like separate database-connections for
> particular users and not generic data-source-wide user /passwords.
>
> It these some way to make Cayenne use this (basically
> DataSource.getConnection(user,password) instead of
> DataSource.getConnection()) ?
>
> I would also like to know of any other way to have a per-user pool
> with Cayenne, if any.
>
> Thanks,
> Emilian Bold
>
>
> 1.http://jakarta.apache.org/commons/dbcp/apidocs/org/apache/commons/ 
> dbcp/datasources/PerUserPoolDataSource.html
>
> -- 
> Emilian Bold
> +40 740235562
> http://www.emilianbold.ro
>
> Java and NetBeans Platform-loving consulting services from  
> Timisoara, Romania.
>


Mime
View raw message