Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
a580e3a3
Commit
a580e3a3
authored
Jul 29, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.2.x' into 2.3.x
Closes gh-22641
parents
5dd7780a
72551242
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
8 deletions
+36
-8
build.gradle
spring-boot-project/spring-boot-autoconfigure/build.gradle
+1
-0
XADataSourceAutoConfiguration.java
...oot/autoconfigure/jdbc/XADataSourceAutoConfiguration.java
+16
-7
XADataSourceAutoConfigurationTests.java
...utoconfigure/jdbc/XADataSourceAutoConfigurationTests.java
+19
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/build.gradle
View file @
a580e3a3
...
@@ -153,6 +153,7 @@ dependencies {
...
@@ -153,6 +153,7 @@ dependencies {
testImplementation
(
"ch.qos.logback:logback-classic"
)
testImplementation
(
"ch.qos.logback:logback-classic"
)
testImplementation
(
"commons-fileupload:commons-fileupload"
)
testImplementation
(
"commons-fileupload:commons-fileupload"
)
testImplementation
(
"com.atomikos:transactions-jms"
)
testImplementation
(
"com.atomikos:transactions-jms"
)
testImplementation
(
"com.ibm.db2:jcc"
)
testImplementation
(
"com.jayway.jsonpath:json-path"
)
testImplementation
(
"com.jayway.jsonpath:json-path"
)
testImplementation
(
"com.squareup.okhttp3:mockwebserver"
)
testImplementation
(
"com.squareup.okhttp3:mockwebserver"
)
testImplementation
(
"com.sun.xml.messaging.saaj:saaj-impl"
)
testImplementation
(
"com.sun.xml.messaging.saaj:saaj-impl"
)
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/XADataSourceAutoConfiguration.java
View file @
a580e3a3
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
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 @@
...
@@ -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;
...
@@ -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 {
...
@@ -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
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/XADataSourceAutoConfigurationTests.java
View file @
a580e3a3
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
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.
...
@@ -19,10 +19,14 @@ package org.springframework.boot.autoconfigure.jdbc;
...
@@ -19,10 +19,14 @@ package org.springframework.boot.autoconfigure.jdbc;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
javax.sql.XADataSource
;
import
javax.sql.XADataSource
;
import
com.ibm.db2.jcc.DB2XADataSource
;
import
org.hsqldb.jdbc.pool.JDBCXADataSource
;
import
org.hsqldb.jdbc.pool.JDBCXADataSource
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.autoconfigure.AutoConfigurations
;
import
org.springframework.boot.jdbc.XADataSourceWrapper
;
import
org.springframework.boot.jdbc.XADataSourceWrapper
;
import
org.springframework.boot.test.context.FilteredClassLoader
;
import
org.springframework.boot.test.context.runner.ApplicationContextRunner
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.boot.test.util.TestPropertyValues
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
...
@@ -60,6 +64,20 @@ class XADataSourceAutoConfigurationTests {
...
@@ -60,6 +64,20 @@ class XADataSourceAutoConfigurationTests {
assertThat
(
dataSource
.
getUser
()).
isEqualTo
(
"un"
);
assertThat
(
dataSource
.
getUser
()).
isEqualTo
(
"un"
);
}
}
@Test
void
createNonEmbeddedFromXAProperties
()
{
new
ApplicationContextRunner
().
withConfiguration
(
AutoConfigurations
.
of
(
XADataSourceAutoConfiguration
.
class
))
.
withUserConfiguration
(
FromProperties
.
class
)
.
withClassLoader
(
new
FilteredClassLoader
(
"org.h2.Driver"
,
"org.hsqldb.jdbcDriver"
))
.
withPropertyValues
(
"spring.datasource.xa.data-source-class-name:com.ibm.db2.jcc.DB2XADataSource"
,
"spring.datasource.xa.properties.user:test"
,
"spring.datasource.xa.properties.password:secret"
)
.
run
((
context
)
->
{
MockXADataSourceWrapper
wrapper
=
context
.
getBean
(
MockXADataSourceWrapper
.
class
);
XADataSource
xaDataSource
=
wrapper
.
getXaDataSource
();
assertThat
(
xaDataSource
).
isInstanceOf
(
DB2XADataSource
.
class
);
});
}
@Test
@Test
void
createFromClass
()
throws
Exception
{
void
createFromClass
()
throws
Exception
{
ApplicationContext
context
=
createContext
(
FromProperties
.
class
,
ApplicationContext
context
=
createContext
(
FromProperties
.
class
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment