cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pascal Robert <prob...@druide.com>
Subject Re: Redacting db user name and password from XML
Date Fri, 19 Jan 2018 15:00:57 GMT
I confirm this behaviour, and I switched back to XMLPoolingDataSourceFactory.

> Le 18 janv. 2018 à 03:59, Andrus Adamchik <andrus@objectstyle.org> a écrit :
> 
> Ah, mystery solved. Looking at the code, more specifically to use properties for a given
DataSource Cayenne would expect you to specify at least DB URL and DB driver. Username/password
are optional.
> 
> Andrus
> 
> 
>> On Jan 18, 2018, at 11:46 AM, Nikita Timofeev <ntimofeev@objectstyle.com> wrote:
>> 
>> Hi all,
>> 
>> Made some research, and here is what I've found.
>> 
>> Cayenne do switch to System properties (defined via -D or with DI
>> binding) automatically but it do so only when all properties are
>> defined.
>> 
>> So this code will work as expected, and use overridden DataSource properties:
>> 
>> ServerRuntime cayenneRuntime =
>> ServerRuntime.builder().addConfig("cayenne-project.xml")
>>       .addModule(binder -> ServerModule.contributeProperties(binder)
>>               .put(Constants.JDBC_DRIVER_PROPERTY, "com.mysql.jdbc.Driver")
>>               .put(Constants.JDBC_URL_PROPERTY,
>> "jdbc:mysql://localhost:3306/test")
>>               .put(Constants.JDBC_USERNAME_PROPERTY, "user")
>>               .put(Constants.JDBC_PASSWORD_PROPERTY, "password"))
>>       .build();
>> 
>> While this will ignore password and use DataSource properties from XML:
>> 
>> ServerRuntime cayenneRuntime =
>> ServerRuntime.builder().addConfig("cayenne-project.xml")
>>       .addModule(binder -> ServerModule.contributeProperties(binder)
>>               .put(Constants.JDBC_PASSWORD_PROPERTY, "password"))
>>       .build();
>> 
>> I will add some information to logs, so at least it wouldn't be
>> surprising as it is now.
>> But maybe we should change this to enable override of separate properties.
>> 
>> On Thu, Jan 18, 2018 at 8:27 AM, Andrus Adamchik <andrus@objectstyle.org> wrote:
>>> 
>>> 
>>>> On Jan 17, 2018, at 11:05 PM, Pascal Robert <probert@druide.com> wrote:
>>>> 
>>>> Ahhh… If I change the factory in the node definition to org.apache.cayenne.configuration.server.PropertyDataSourceFactory,
it does read the command-line properties.
>>> 
>>> That should sorta happen automatically. We are still looking why it doesn't.
>>> 
>>> Andrus
>>> 
>> 
>> 
>> 
>> -- 
>> Best regards,
>> Nikita Timofeev
> 


Mime
View raw message