|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2012-2019 the original author or authors. |
|
|
|
* Copyright 2012-2020 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -13,9 +13,11 @@ |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* limitations under the License. |
|
|
|
* limitations under the License. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.autoconfigure.jdbc; |
|
|
|
package org.springframework.boot.autoconfigure.jdbc; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import javax.sql.DataSource; |
|
|
|
import javax.sql.DataSource; |
|
|
|
import javax.sql.XADataSource; |
|
|
|
import javax.sql.XADataSource; |
|
|
|
import javax.transaction.TransactionManager; |
|
|
|
import javax.transaction.TransactionManager; |
|
|
|
@ -28,6 +30,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.DataSourceBeanCreationException; |
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|
|
|
import org.springframework.boot.context.properties.bind.Bindable; |
|
|
|
import org.springframework.boot.context.properties.bind.Bindable; |
|
|
|
import org.springframework.boot.context.properties.bind.Binder; |
|
|
|
import org.springframework.boot.context.properties.bind.Binder; |
|
|
|
@ -102,11 +105,17 @@ public class XADataSourceAutoConfiguration implements BeanClassLoaderAware { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ConfigurationPropertySource getBinderSource(DataSourceProperties dataSourceProperties) { |
|
|
|
private ConfigurationPropertySource getBinderSource(DataSourceProperties dataSourceProperties) { |
|
|
|
MapConfigurationPropertySource source = new MapConfigurationPropertySource(); |
|
|
|
Map<Object, Object> properties = new HashMap<Object, Object>(); |
|
|
|
source.put("user", dataSourceProperties.determineUsername()); |
|
|
|
properties.putAll(dataSourceProperties.getXa().getProperties()); |
|
|
|
source.put("password", dataSourceProperties.determinePassword()); |
|
|
|
properties.computeIfAbsent("user", (key) -> dataSourceProperties.determineUsername()); |
|
|
|
source.put("url", dataSourceProperties.determineUrl()); |
|
|
|
properties.computeIfAbsent("password", (key) -> dataSourceProperties.determinePassword()); |
|
|
|
source.putAll(dataSourceProperties.getXa().getProperties()); |
|
|
|
try { |
|
|
|
|
|
|
|
properties.computeIfAbsent("url", (key) -> dataSourceProperties.determineUrl()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
catch (DataSourceBeanCreationException ex) { |
|
|
|
|
|
|
|
// Continue as not all XA DataSource's require a URL
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
MapConfigurationPropertySource source = new MapConfigurationPropertySource(properties); |
|
|
|
ConfigurationPropertyNameAliases aliases = new ConfigurationPropertyNameAliases(); |
|
|
|
ConfigurationPropertyNameAliases aliases = new ConfigurationPropertyNameAliases(); |
|
|
|
aliases.addAliases("user", "username"); |
|
|
|
aliases.addAliases("user", "username"); |
|
|
|
return source.withAliases(aliases); |
|
|
|
return source.withAliases(aliases); |
|
|
|
|