Atomikos Forum

Datasource XAProperties Lookup / Override configuration

Hi am currently using Atomikos for XA transactions for my application based on Spring. Am new to both Spring and also Atomikos. Am trying to configure multiple datasources, however, i want the connection details to be picked from property file.

My Current Configuration
<bean id="datasource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">

<property name="xaProperties">      
        <props>
            <prop key="user">${jdbc.username}</prop>
            <prop key="password">${jdbc.password}</prop>
            <prop key="URL">${jdbc.url}</prop>
        </props>
          </property>   
</bean>

now how can these placeholders be referenced ? How will the property file be referenced for the properties (jbdc.username, jdbc.url, jdbc.password) ?

Can i have some sample example or code snippted for this.
Thanks in advance.
Shindhur
shindhur Send private email
Friday, August 14, 2015
 
 
Hi,

Have a look at the PropertyPlaceholderConfigurer in Spring. See http://www.codejava.net/frameworks/spring/reading-properties-files-in-spring-with-propertyplaceholderconfigurer-bean for an example.

HTH
Guy Pardon Send private email
Tuesday, August 18, 2015
 
 
Hi Guy Pardon,

Thanks a lot for your reply. But in my case, its the nested properties that are to be read. Does your post hold good even in case of reading nested properties?

<bean id="datasource" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">

<property name="xaProperties">     
        <props>
            <prop key="user">${jdbc.username}</prop>

Does the ${jdbc.username} nested under user under xaProperties be read correctly ?
shindhur Send private email
Thursday, August 20, 2015
 
 
Hi,

I don't think this would work for nested properties - thanks for pointing that out. You might want to avoid setting xaProperties and instead inject the xaDataSource directly (which can then be configured in Spring with Spring's property placeholder).

HTH
Guy Pardon Send private email
Thursday, August 20, 2015
 
 
Also, the actual requirement is we have a proprietary application, whose startup script would use -D to override the properties from property file placed in config location.

Is there a way we can override the above properties, during application startup with properties from external file.

-DOverrideFile="TestFile.prop"
shindhur Send private email
Thursday, August 20, 2015
 
 
Doesn't my previous post on setting the XADataSource directly help?

Thanks
Guy Pardon Send private email
Thursday, August 20, 2015
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics