Merge branch '1.5.x'

pull/9534/merge
Andy Wilkinson 7 years ago
commit c45a351308

@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -119,6 +119,7 @@ public class NarayanaJtaConfiguration {
}
@Bean
@ConditionalOnMissingBean
public NarayanaRecoveryManagerBean narayanaRecoveryManager(
RecoveryManagerService recoveryManagerService) {
return new NarayanaRecoveryManagerBean(recoveryManagerService);

@ -43,6 +43,7 @@ import org.junit.rules.ExpectedException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
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.jta.XAConnectionFactoryWrapper;
import org.springframework.boot.jta.XADataSourceWrapper;
@ -54,6 +55,7 @@ import org.springframework.boot.jta.bitronix.PoolingConnectionFactoryBean;
import org.springframework.boot.jta.bitronix.PoolingDataSourceBean;
import org.springframework.boot.jta.narayana.NarayanaBeanFactoryPostProcessor;
import org.springframework.boot.jta.narayana.NarayanaConfigurationBean;
import org.springframework.boot.jta.narayana.NarayanaRecoveryManagerBean;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@ -284,6 +286,16 @@ public class JtaAutoConfigurationTests {
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
@EnableConfigurationProperties(JtaProperties.class)
public static class JtaPropertiesConfiguration {
@ -326,4 +338,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);
}
}
}
}

Loading…
Cancel
Save