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
bb35e772
Commit
bb35e772
authored
Jul 24, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish "Make NarayanaRecoveryManagerBean conditional on missing bean"
Closes gh-9724
parent
d8a69547
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
NarayanaJtaConfiguration.java
...toconfigure/transaction/jta/NarayanaJtaConfiguration.java
+1
-1
JtaAutoConfigurationTests.java
...oconfigure/transaction/jta/JtaAutoConfigurationTests.java
+34
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/NarayanaJtaConfiguration.java
View file @
bb35e772
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfigurationTests.java
View file @
bb35e772
/*
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
@@ -44,6 +44,7 @@ import org.junit.rules.ExpectedException;
...
@@ -44,6 +44,7 @@ import org.junit.rules.ExpectedException;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
;
import
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration
;
import
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfigurationTests.CustomNarayanaRecoveryManagerConfiguration.CustomNarayanaRecoveryManagerBean
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.jta.XAConnectionFactoryWrapper
;
import
org.springframework.boot.jta.XAConnectionFactoryWrapper
;
import
org.springframework.boot.jta.XADataSourceWrapper
;
import
org.springframework.boot.jta.XADataSourceWrapper
;
...
@@ -55,6 +56,7 @@ import org.springframework.boot.jta.bitronix.PoolingConnectionFactoryBean;
...
@@ -55,6 +56,7 @@ import org.springframework.boot.jta.bitronix.PoolingConnectionFactoryBean;
import
org.springframework.boot.jta.bitronix.PoolingDataSourceBean
;
import
org.springframework.boot.jta.bitronix.PoolingDataSourceBean
;
import
org.springframework.boot.jta.narayana.NarayanaBeanFactoryPostProcessor
;
import
org.springframework.boot.jta.narayana.NarayanaBeanFactoryPostProcessor
;
import
org.springframework.boot.jta.narayana.NarayanaConfigurationBean
;
import
org.springframework.boot.jta.narayana.NarayanaConfigurationBean
;
import
org.springframework.boot.jta.narayana.NarayanaRecoveryManagerBean
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
...
@@ -294,6 +296,16 @@ public class JtaAutoConfigurationTests {
...
@@ -294,6 +296,16 @@ public class JtaAutoConfigurationTests {
assertThat
(
transactionManager
.
isRollbackOnCommitFailure
()).
isTrue
();
assertThat
(
transactionManager
.
isRollbackOnCommitFailure
()).
isTrue
();
}
}
@Test
public
void
narayanaRecoveryManagerBeanCanBeCustomized
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
();
this
.
context
.
register
(
CustomNarayanaRecoveryManagerConfiguration
.
class
,
JtaProperties
.
class
,
NarayanaJtaConfiguration
.
class
);
this
.
context
.
refresh
();
assertThat
(
this
.
context
.
getBean
(
NarayanaRecoveryManagerBean
.
class
))
.
isInstanceOf
(
CustomNarayanaRecoveryManagerBean
.
class
);
}
@Configuration
@Configuration
@EnableConfigurationProperties
(
JtaProperties
.
class
)
@EnableConfigurationProperties
(
JtaProperties
.
class
)
public
static
class
JtaPropertiesConfiguration
{
public
static
class
JtaPropertiesConfiguration
{
...
@@ -336,4 +348,25 @@ public class JtaAutoConfigurationTests {
...
@@ -336,4 +348,25 @@ public class JtaAutoConfigurationTests {
}
}
@Configuration
public
static
class
CustomNarayanaRecoveryManagerConfiguration
{
@Bean
public
NarayanaRecoveryManagerBean
customRecoveryManagerBean
(
RecoveryManagerService
recoveryManagerService
)
{
return
new
CustomNarayanaRecoveryManagerBean
(
recoveryManagerService
);
}
static
final
class
CustomNarayanaRecoveryManagerBean
extends
NarayanaRecoveryManagerBean
{
private
CustomNarayanaRecoveryManagerBean
(
RecoveryManagerService
recoveryManagerService
)
{
super
(
recoveryManagerService
);
}
}
}
}
}
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