|
From: <jue...@we...> - 2004-05-28 14:58:32
|
Let's take "UserCredentialsDataSourceAdapter" then - OK, Thomas?
=20
It's finished including javadocs and test suite, just waiting for a name =
that we agree on...
=20
Juergen
=20
________________________________
Von: spr...@li... im Auftrag =
von Colin Sampaleanu
Gesendet: Fr 28.05.2004 15:23
An: spr...@li...
Betreff: Re: [Springframework-developer] Re: [Springframework-user] JNDI =
dataSource with separate user/pas sword/schema strings
Hmm... I would probably go for adapter...
j=FCrgen h=F6ller [werk3AT] wrote:
>Hmm... you've got a point there. So votes please: =
"UserCredentialsDataSourceProxy" or "UserCredentialsDataSourceAdapter"? =
Or maybe a different, even better name?
>
>Juergen
>
>P.S.: Let's move this to the developer list.
>
>
>________________________________
>
>Von: spr...@li... im Auftrag von =
Thomas Risberg
>Gesendet: Fr 28.05.2004 13:39
>An: spr...@li...
>Betreff: Re: [Springframework-user] JNDI dataSource with separate =
user/pas sword/schema strings
>
>
>
>Don't want to nit pick about the naming, but I think it looks like an
>Adapter as well as a Proxy.
>
>JdbcTemplate
>|
>|
>getConnection()
>|
>|
>v
>UserCredentialsDataSource
>|
>|
>getConnection(username, password)
>|
>|
>v
>DataSource
>
>Thomas
>
>
>j=FCrgen h=F6ller [werk3AT] wrote:
>
>=20
>
>>Regarding the naming: IMO, such a DataSource is a "proxy" rather than =
an "adapter", as it exposes the same interface as the target.
>>
>>Juergen
>>
>>
>>________________________________
>>
>>Von: spr...@li... im Auftrag von =
j=FCrgen h=F6ller [werk3AT]
>>Gesendet: Fr 28.05.2004 10:20
>>An: spr...@li...
>>Betreff: Re: [Springframework-user] JNDI dataSource with separate =
user/pas sword/schema strings
>>
>>
>>
>>I consider that a good idea! We've actually discussed it before, =
exactly for that purpose.
>>
>>So I've just added a "UserCredentialsDataSourceProxy" to our =
jdbc.datasource package, taking "targetDataSource", "username" and =
"password" as bean properties. On "getConnection()" calls, it simply =
delegates to the "getConnection(username, password)" method of the =
target DataSource with the given user credentials.
>>
>>Additionally, there's also the option of setting thread-bound =
credentials, via the "setCredentialsForCurrentThread(username, =
password)" method". The application needs to make sure that such =
thread-bound credentials are removed at the end of the operation, via =
the "removeCredentialsFromCurrentThread()" method.
>>
>>If noone objects, this will be part of 1.0.2, as it arguably is a =
simple and straightforward addition that does not affect any other code.
>>
>>Juergen
>>
>>
>>________________________________
>>
>>Von: spr...@li... im Auftrag von =
Thomas Risberg
>>Gesendet: Fr 28.05.2004 05:04
>>An: spr...@li...
>>Betreff: Re: [Springframework-user] JNDI dataSource with separate =
user/pas sword/schema strings
>>
>>
>>
>>This has come up before and we should figure out the best recommended
>>solution. We could use a custom datasource adapter that has a =
reference
>>to the real datasource and adds username/password to the get =
connection
>>call. This username/password could be set via DI or stored in a =
thread
>>local in the case of each invocation having their own =
username/password
>>combo.
>>
>>Thomas
>>
>>
>>Colin Sampaleanu wrote:
>>
>>
>>
>> =20
>>
>>>Robert,
>>>
>>>Your variant below will work actually, since Spring is not going to
>>>get the DataSource and connection from it, but rather Hibernate =
itself
>>>will get the DataSource from JNDI and do a getConnection(name, pass)
>>>(via its own DatasourceConnectionProvider class).
>>>
>>>As per my previous email, Spring has no ability to call
>>>getConnection(name, pass) on a dataSource, so you need to make sure
>>>that all your operations can be done via Hibernate code... To be =
safe,
>>>you probably should not use Spring's HibernateTransactionManager and
>>>DataSourceTransactionManager classes, since they make the DataSource
>>>(either set directly or in the case of the former also pulled out =
from
>>>the SessionFactory) bound to the current thread/transaction, and
>>>expose the ability to get a connection from it with DataSourceUtils,
>>>which has no ability to do anything more than a simple =
getConnection()
>>>call to get a connection. So you would probably want to run with
>>>JTATransactionManager.
>>>
>>>Juergen, I don't know if you've been following this thread, but we
>>>should think about enhaning Spring to allow specifying a name/pass =
and
>>>make it user getConnection(name, pass) in that case...
>>>
>>>Colin
>>>
>>>
>>>Loren, Robert wrote:
>>>
>>>=20
>>>
>>> =20
>>>
>>>>Greetings-
>>>>
>>>>Ok, now I've got this working.
>>>>So it seems that I now need something like
>>>>PropertyPlaceholderConfigurer,
>>>>only using JNDI.
>>>>
>>>>----------------------------------------
>>>>IN appcontext.xml:
>>>>
>>>> <!-- Hibernate SessionFactory -->
>>>> <bean id=3D"sessionFactory"
>>>>class=3D"org.springframework.orm.hibernate.LocalSessionFactoryBean">
>>>> <!--<property name=3D"dataSource"><ref
>>>>local=3D"dataSource"/></property>-->
>>>> <property name=3D"mappingResources">
>>>> <value>/WEB-INF/OurApp.hbm.xml</value>
>>>> </property>
>>>> <property name=3D"hibernateProperties">
>>>> <props>
>>>> <prop
>>>>key=3D"hibernate.dialect">${hibernate.dialect}</prop>
>>>> <prop
>>>>key=3D"hibernate.show_sql">${hibernate.showsql}</prop>
>>>> <prop
>>>>key=3D"hibernate.connection.username">${hibernate.connection.username=
}</prop
>>>>
>>>>
>>>>
>>>> <prop
>>>>key=3D"hibernate.connection.password">${hibernate.connection.password=
}</prop
>>>>
>>>>
>>>>
>>>> <prop
>>>>key=3D"hibernate.connection.datasource">${hibernate.connection.dataso=
urce}</
>>>>
>>>>prop>
>>>> </props>
>>>> </property>
>>>> </bean>
>>>>--------------------------------------
>>>>IN jdbc.properties:
>>>>
>>>>hibernate.dialect=3Dnet.sf.hibernate.dialect.DB2Dialect
>>>>hibernate.showsql=3Dtrue
>>>>hibernate.connection.username=3Dme
>>>>hibernate.connection.password=3Dmypassword
>>>>hibernate.connection.datasource=3Djdbc/mydatasource
>>>>
>>>>Let's see what I can find,
>>>>Rob
>>>>
>>>>-----Original Message-----
>>>>From: Loren, Robert [mailto:Rob...@ca...]
>>>>Sent: Thursday, May 27, 2004 7:16 PM
>>>>To: 'spr...@li...'
>>>>Subject: RE: [Springframework-user] JNDI dataSource with separate
>>>>user/pas sword/schema strings
>>>>
>>>>
>>>>Thanks for your reply, Colin.
>>>>
>>>>Yes, we do want the datasource to be setup by the admin in the
>>>>container,
>>>>then accessed by the app. In DB2, you can pass the username and =
password
>>>>to the getConnection() method of the datasource, and that is what
>>>>most of
>>>>our in-house code is doing. We then use the schema name in our =
queries
>>>>when connecting up. I guess it's the runtime use of these =
parameters,
>>>>through the session/template, that we're trying to emulate. If the
>>>>datasource could be injected with the user and password somehow, =
that
>>>>would be fine, but I don't see that as possible.
>>>>
>>>>Hibernate has properties such as "hibernate.connection.username" =
that
>>>>seem
>>>>available for the SessionFactory. I'm trying to get those to work =
with
>>>>strings at the moment. But if successful there, I'd like to somehow =
swap
>>>>them out with JNDI-located strings.
>>>>
>>>>Hope this gives you more,
>>>>Rob
>>>>
>>>>-----Original Message-----
>>>>From: Colin Sampaleanu [mailto:col...@ex...]
>>>>Sent: Thursday, May 27, 2004 6:47 PM
>>>>To: spr...@li...
>>>>Subject: Re: [Springframework-user] JNDI dataSource with separate
>>>>user/password/schema strings
>>>>
>>>>
>>>>Loren, Robert wrote:
>>>>
>>>>
>>>>
>>>> =20
>>>>
>>>> =20
>>>>
>>>>>Hi,
>>>>>
>>>>>We're looking to deploy into a WAS 5/DB2 environment with a
>>>>>Spring/Hibernate-based application.
>>>>>
>>>>>We're excited, but worried at this point, trying to figure out how
>>>>>to get
>>>>>a pooled data source wired up from WAS's JNDI store.
>>>>>
>>>>>It was very easy to wire the data source itself, using the
>>>>>JndiObjectFactoryBean from looking at the examples. However, our
>>>>>Architecture group wants us to store the name, password, and schema =
we
>>>>>
>>>>> =20
>>>>>
>>>>> =20
>>>>>
>>>>use
>>>>
>>>>
>>>> =20
>>>>
>>>> =20
>>>>
>>>>>externally to the data source itself.
>>>>>
>>>>>I'm looking for something similar to how the strings are stored in =
the
>>>>>jdbc.properties file for DriverManagerDataSource, only maybe using =
the
>>>>>JndiObjectFactoryBeans wired into the SessionFactory properties.
>>>>>
>>>>>Does anyone have sample code on how this might be configured? =
Should I
>>>>>maybe be posting this to the developer group?
>>>>>
>>>>>Thanks very much for any help in advance, and thanks for Spring,
>>>>>
>>>>>Rob
>>>>>
>>>>>
>>>>>
>>>>> =20
>>>>>
>>>>> =20
>>>>>
>>>>Rob,
>>>>
>>>>I'm a little confused about what you're trying to do, and about the
>>>>DataSource lifecycle you want to achieve. I presume that as opposed
>>>>to the normal scenario where a sysadmin or deployer sets up the one
>>>>datasource (which gets bound to JNDI) in the appserver, you would
>>>>like Spring to create the datasource, based on config params which
>>>>are provided by/to Spring?
>>>>
>>>>There is nothing stopping you from creating something like an Apache
>>>>DBCP Datasource, and using that. However, you are then going to give
>>>>up the much more robust WAS DataSource impl. which is integrated =
into
>>>>the container and the container's transaction manager.
>>>>
>>>>Can you provide more details?
>>>>
>>>>Regards,
>>>>Colin
>>>>
>>>>
>>>> =20
>>>>
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id149&alloc_id=8166&op=3Dick
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|